1.8 抓包工具tcpdum和tshark

#抓包工具tcpdump   安装yum install tcpdump

tcpdump  -nn

tcpdump -nn -c 100 指定抓包数量

tcpdump -nn -i eth1  指定网卡

tcpdump -nn port 22 指定端口

tcpdump -nn tcp and port 22 指定协议

tcpdump -nn tcp and port 80 and host 117.44.160.154  指定来源IP

tcpdump -nn tcp and port 80 and host 117.44.160.154 -w 1.cap  把包写入文件里,w选项是写入,ctrl+c结束

tcpdump -nn  -s0 tcp and port 80 and host 117.44.160.154 -w 1.cap  抓一个完整的包,用-s0

tcpdump -r 1.cap  查看包文件,只查看来源IP与目标IP,就是流向

tcpdump -nn tcp and port 80  -c 10 > 2.cap    把抓10个包重定向在2.cap,是流向不是内容


#另一个抓包工具wireshark   yum install -y wireshark

tshark -n -t a -R http.request -T fields -e "frame.time" -e "ip.src" -e "http.host" -e "http.request.method" -e "http.request.uri"


习题:

1. 使用tcpdump抓取eth1网卡端口号为80的包,命令是?

tcpdump -nn -i eth1 port 80


2. 用tcpdump抓取eth0网卡的包,但不需要ssh相关的包,只需要抓500个包并且存到文件1.cap中

tcpdump -nn -i eth0 -s0 not port 22 -c 500 -w 1.cap


总结

主要: wireshark抓包工具 tshark -n -t a -R http.request -T fields -e "frame.time" -e "ip.src" -e "http.host" -e "http.request.method" -e "http.request.uri"


你可能感兴趣的:(1.8)