抓包分析工具

 

常用抓包工具有 tcpdump、ngrep、fiddler、wireshark、httpwatch、tshark等,以下简单介绍四种工具的使用方式:

种工具适用范围:

1、tcpdump:网络数据采集分析
2、ngrep: grep网络版,力求更多grep特征
3、fiddler:http协议调试代理工具
4、wireshark:图形化抓包工具
5、tshark: wireshark命令行版
6、httpwath:web报文
7、BurpSuite: web 报文
8、tcpflow:面向 TCP 流抓包

用法介绍
一、tcpdump

#抓取指定网卡eth1经过的所有包,并保存到/tmp/server0.pcap下

1 tcpdump -i eth1 -s 0 -w /tmp/server0.pcap


#抓取网卡eth0上的22端口tcp包,只抓取10个包

1 tcpdump -c 10 -nn -i eth0 tcp dst port 22


#如果你还想监视编址到指定端口的TCP或UDP数据包,那么执行以下命令

1 tcpdump -i eth0 host hostname and port 80


#如果想要获取主机10.0.0.1除了和主机10.0.0.2之外所有主机通信的ip包

1 tcpdump ip host 10.0.0.1 and ! 10.0.0.2


#想要截获所有10.0.0.1的主机收到的和发出的所有的数据包:

tcpdump host 10.0.0.1


#想要截获主机10.0.0.1主机10.0.0.2 或10.0.0.3的通信

tcpdump host 10.0.0.1 and 10.0.0.2 or 10.0.0.3

二、tshark

#实时抓取所有网卡上的rtp和rtcp流媒体包

tshark -i any -o "rtp.heuristic_rtp: TRUE" -R rtp\|\|rtcp


#实时打印当前mysql查询语句

tshark -s 512 -i eth0 -n -f 'tcp dst port 3306' -R 'mysql.query' -T fields -e mysql.query

三、ngrep

#抓取所有网卡上进过主机1.1.1.1,端口80并包含string字符的包

ngrep -pq -W byline string port 80 and host 1.1.1.1 -d any


#捕获字符串".flv",比如要查看在Web Flash 视频中的flv文件的下载地址

ngrep -d3 -N -q \.flv

四、tcpflow

# 过滤经过 10.0.0.1 的流量:

tcpflow -i any host 10.0.0.1


# 过滤从主机 10.0.0.1 发出的流量:

tcpflow -i any src host 10.0.0.1


# 过滤从主机 10.0.0.1 发出的流量并且端口号为 80:

tcpflow -i any src host 10.0.0.1 and port 80


# 过滤固定端口的流量:

tcpflow -i en0 any port 443 or port 80


# 过滤主机 10.0.0.1 端口为 80 或 443 的流量:

tcpflow -i en0 'host 10.0.0.1 and (port 80 or port 443)'

 

posted @ 2020-12-26 18:55  Buster_Hsueh  阅读(617)  评论(0编辑  收藏  举报