常用的抓包工具

常用的抓包工具: tcpdump、sniffer

  • tcpdump的介绍和使用
    抓取源ip是10.10.10.59且目的端口是22,或源ip是10.10.10.68且目的端口是80的数据包。
tcpdump -i  eth0 -vnn 'src host 10.10.10.59 and dst port 22' or  ' src host 10.10.10.68 and dst port 80 '
tcpdump -i dump0 -c 20000  -nnve -w file
  • ethtool的介绍和使用
    在xgbe3网卡用sniffer功能开启抓包,
开启抓包:  ethtool --set-priv-flags xgbe3 sniffer on
进行抓包:  tcpdump -i dump0 -c 20000  -nnve -w file
关闭抓包:  ethtool --set-priv-flags xgbe3 sniffer off

使用案例: https://string.quest/read/3754545

常用的打流工具iperf:

iperf -c ip -p port -b 1G -t 86400 -i 2

开启大页coredump

echo 0xfff > /proc//coredump_filter

scapy的使用

https://blog.csdn.net/fageweiketang/article/details/103516566
安装scapy python setup.py install
运行scapy: ./run_scapy

image.png

from scapy.all import *
test_bytes = b'test'
udp_packet = IP(dst='1.2.3.4')/UDP(dport=4789)/Raw(load=test_bytes)
send(udp_packet)

在目标机器: 1.2.3.4上执行抓包命令: tcpdump -i eth0 -vnn 'src host 10.2.3.4 and dst port 4789' -c 10 -w test.pcap
tcp报文的构造和抓取

sendp(Ether()/IP(dst="1.2.3.4",ttl=(1,4)), iface="eth0")
sendp(Ether(dst='00:0B:84:00:0F:00)/ARP(hwsrc='ff:ff:ff:ff:ff:ff', psrc='1.2.3.4', hwdst='00:0B:84:00:0F:00', pdst='1.2.3.3')/'abc', iface='eth0')

tcpdump -i eth0 -vnn 'src host 1.2.3.4' -c 4 -nnve -w test_1.pcap

参考:
https://zhuanlan.zhihu.com/p/51002301
https://rattibha.com/thread/1446683409644851201
scapy怎么发vxlan报文: https://www.jianshu.com/p/a8bfe5ab2347

你可能感兴趣的:(常用的抓包工具)