Linux网络抓包-tcpdump

tcpdump - dump traffic on a network

tcpdump是linux上一个强大的抓包工具。

tcpdump常用抓包命令

tcpdump -v -i any -s 0 -w test.cap host 192.168.0.1 and port 5001
# -v : 打印详细输出
# -i : 指定网卡, 例如eth0, any代表所有网卡
# -s : 指定捕获的数据包的大小, 0代表不限制
# -w : 保存到文件 test.cap
# host : 过滤IP
# port : 过滤端口

nohup tcpdump -i eth0 host 192.168.0.1 -w /tmp/test.pcap -C 500 -W 5 &
# nohup : 后台抓包
# -C : 每隔500M生成一个文件
# -W : 保留最近生成的5个文件

tcpdump -r test.cap
# linux上查看抓包文件

Wireshark分析抓包

wireshark官网: https://www.wireshark.org/

过滤数据包

# 1.协议过滤
http
tcp
arp

# 2. IP过滤
ip.addr=192.168.0.1
ip.src==192.168.0.1
ip.dst==192.168.0.8

# 3. 端口过滤
tcp.port=8080
tcp.srcport=8080

# 4. http方法过滤
http.request.method=="GET"

# 5. 逻辑运算符 and or
ip.src==192.168.0.1 and http

搜索字符串

分组字节流-字符串-查找

追踪会话

右键点击一个数据包,选择跟踪选项,可以查看与该数据包相关的整个会话的数据流。

posted @ 2024-09-03 13:04  rustling  阅读(145)  评论(0)    收藏  举报