参考1:Linux下Pcap包重放工具Tcpreplay的简单使用-腾讯云开发者社区-腾讯云
参考2:tcpreplay的使用方法_新雪兰的博客-CSDN博客
参考3: https://blog.csdn.net/zhaomax/article/details/82773381
- 安装
yum install epel-release
yum install tcpreplay
- 使用
1.tcpprep为要发送的test.pcap包创建缓存test.cache
// client 向客户端发送
tcpprep -a client -i test.pcap -o test.cache
2. tcprewrite重写目标ip、mac,源ip、mac
本机ip:192.168.0.111 mac:f8:94:c2:59:c9:82
虚拟机ip: 192.168.0.109 mac:00:0c:29:90:ae:23
-
重写目标ip和mac地址
tcprewrite --infile test.pcap --outfile test_1.pcap --dstipmap=0.0.0.0/0:192.168.11.158 --enet-dmac=D8:F3:BC:EA:E6:B7
-
重写源
ip
和mac
地址
tcprewrite --infile test_1.pcap --outfile test_2.pcap --srcipmap=0.0.0.0/0:192.168.11.140 --enet-dmac=00:e0:2b:68:01:bb
-
更新数据包的校验和
tcprewrite --infile test_2.pcap --outfile testFinal.pcap --fixcsum
3 . 完成数据重写后,tcpreplay
重放最终的数据包
// 需要root
// -i ens33 网卡
//tcpreplay -v -i ens33 -M 1000 testFinal.pcap
//tcpreplay -v -i ens33 -x 1 testFinal.pcap
tcpreplay -v -i enp7s0 -x 1 testFinal.pcap
cd tcpreplay/
tcpprep -a client -i test.pcap -o test.cache
tcprewrite --infile test.pcap --outfile test_1.pcap --dstipmap=0.0.0.0/0:192.168.11.158 --enet-dmac=D8:F3:BC:EA:E6:B7
tcprewrite --infile test.pcap --outfile test_1.pcap --dstipmap=0.0.0.0/0:192.168.11.158 --portmap=12345:22222 --enet-dmac=D8:F3:BC:EA:E6:B7
#安卓端的IP和安卓端的Mac地址
tcprewrite --infile test_1.pcap --outfile test_2.pcap --srcipmap=0.0.0.0/0:10.136.152.216 --enet-dmac=00:0c:29:7d:7f:a5
tcprewrite --infile test_2.pcap --outfile testFinal.pcap --fixcsum
tcpreplay -v -i ens33 -x 1 testFinal.pcap