网络抓包命令|wireshark抓包实用命令总结

Linux环境下抓包

可以使用tcpdump命令

tcpdump -i ens192 -w dataAll.pcap  port 8008 

这其中

  • ens192 指代网卡 可以通过ifconfig获取,也可以直接用 any 代替。意思是抓取全部网卡数据。例如:tcpdump -i any -w dataAll.pcap
  • dataAll.pcap 抓取的文件名
其他
  1. -i 设备名称 tcpdump -i lo //抓回环网口的包 tcpdump -i eth0 //抓eth0网卡的包
  2. -n 以数字显示主机及端口 tcpdump -n //以数字显示主机和端口 tcpdump -ni any //抓全部网卡的包
  3. -Q in|out|inout tcpdump -ni any -Q in //入包 tcpdump -ni any -Q out //出包 tcpdump -ni any -Q inout //入包和出包
  4. 过滤相关 host net port tcpdump -ni any port 80 //已数字显示端口和主机抓取全部网卡80端口的包 tcpdump -ni any host 192.168.38.133
    //过滤192.168.38.133的包 tcpdump -ni any host 192.168.38.133 and port 80
    //来自192.168.38.133访问80端口的包
  5. 传输方向关键字: src、dst、or src、dst and src tcpdump -ni any src 192.168.38.133 and dst 192.168.38.128 //来自IP1到IP2 tcpdump -ni any src 192.168.38.133 and dst 192.168.38.128 and port 80 tcpdump -ni any src 192.168.38.133 and dst 192.168.38.128 and port 80 or 81
  6. 协议关键字:fddi、ip、arp、rarp、tcp、udp等 fddi:FDDI(分布式光前数据接口网络)上的特定网络协议 rarp:
  7. 其它参数
    -c 监听的数据包数量
    -w file 将监听数据保存到文件中

windows环境下抓包

直接打开wireshark选择网卡就可以,这里不再赘述。

wireshark 抓包过滤实用命令

  • ip.dst == <目标IP地址>
  • ip.src == <源IP地址>
  • tcp.dstport == <目标端口号>
  • tcp.srcport == <源端口号>
  • tcp contains “xxx” 过滤tcp协议包中包含xxx字段的请求,通常可以用来过滤某个http请求

举例

  • 捕获IP地址为192.168.1.100,端口为80的流量:
ip.addr == 192.168.1.100 and tcp.port == 80
  • 捕获源IP地址为192.168.1.50,目的IP地址为192.168.1.100,端口为80的流量:
ip.src == 192.168.1.50 and ip.dst == 192.168.1.100 and tcp.port == 80
  • 捕获IP地址为192.168.1.100,端口为80或443的流量:
ip.addr == 192.168.1.100 and (tcp.port == 80 or tcp.port == 443)
  • tcp contains “ssoService/v1/tgtLogin”
  • tcp contains “tokenLogin”
  • tcp contains “serviceValidate”
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值