虚拟机端口重放UDP报文

参考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

  1. 重写目标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

  1. 重写源ipmac地址

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

  1. 更新数据包的校验和

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

注意改为桥接模式

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值