防火墙 IP 分片测试套件 - Linux 版本
概述
本测试套件基于 fragroute 工具,用于测试防火墙对 IP 分片的处理能力和安全性。
测试环境
-
**Fragroute 主机**: 192.168.1.2
-
**DUT (防火墙)**: 192.168.1.1
-
**目标 PC**: 192.168.2.2
测试拓扑
+--------mgt network---------+-----------------------+
| | |
| | |
| | |
ens160:10.9.105.143 | ens160:10.9.105.142
| | |
Fragroute ens192:192.168.1.2 -- DUT -- target ens192: 192.168.2.2
系统要求
-
Linux 操作系统(Ubuntu/Debian/CentOS/RHEL)
-
Root 或 sudo 权限
-
网络连接正常
快速开始
1. 安装依赖
```bash
sudo bash install_dependencies.sh
- 运行测试前检查
bash#
bash pre_test_checklist.sh
- 执行完整测试套件
bash#
sudo bash run_tests.sh
- 或者使用快速启动脚本
bash#
sudo bash quick_start.sh
目录结构
plaintext
testcase/
├── configs/ # fragroute 配置文件
│ ├── normal_frag_256.conf
│ ├── normal_frag_512.conf
│ ├── tiny_frag_8.conf
│ ├── large_frag_2000.conf
│ ├── overlap_frag.conf
│ ├── ooo_frag.conf
│ ├── teardrop.conf
│ ├── flood.conf
│ └── invalid_frag.conf
├── logs/ # 测试日志
├── captures/ # 抓包文件
├── install_dependencies.sh # 依赖安装脚本
├── pre_test_checklist.sh # 测试前检查脚本
├── main.sh # 主测试执行脚本
├── run_single_test.sh # 单个测试执行脚本
├── quick_start.sh # 快速启动脚本
├── test_results.csv # 测试结果
└── README.md # 本文档
单独运行测试用例
查看所有可用测试
bash#
./run_single_test.sh
运行特定测试
bash#
正常分片测试(256字节)
sudo ./run_single_test.sh normal_256
微小分片测试
sudo ./run_single_test.sh tiny_8
Teardrop 攻击测试
sudo ./run_single_test.sh teardrop
查看结果
测试结果 CSV
bash#
cat test_results.csv
测试报告
bash#
cat test_report.txt
执行日志
bash#
tail -f logs/test_execution.log
分析抓包文件
bash#
使用 tcpdump 查看
tcpdump -r captures/test_name_timestamp.pcap
使用 Wireshark 图形界面查看
wireshark captures/test_name_timestamp.pcap
配置说明
修改网络接口
编辑 run_tests.sh,修改以下行:
bash#
INTERFACE="eth0" # 改为你的网卡名称,如 ens33, enp0s3 等
查看可用网卡:
bash#
ip addr show
修改 IP 地址
编辑脚本中的以下变量:
bash#
DUT_IP="192.168.1.1"
TARGET_IP="192.168.2.2"
FRAGROUTE_IP="192.168.1.2"
自定义 fragroute 配置
编辑 configs/ 目录下的 .conf 文件:
conf
分片大小
ip_frag <size> [old|new]
乱序
order random|reverse
延迟(毫秒)
delay first|last|random <ms>
丢弃概率
drop first|last|random <prob-%>
TCP 分段
tcp_seg <size> [old|new]
TTL 值
ip_ttl <ttl>
服务类型
ip_tos <tos>
参考资料
fragroute 官方文档
IP Fragmentation Attacks
测试 Checklist: firewall_ip_fragmentation_test_checklist.md
版本历史
v1.0 (2026-04-27): Linux 版本,支持自动化测试和结果记录
plaintext
tcp 部分未完成,静待后续。
完整代码下载https://download.csdn.net/download/dangdanding/92889523