Ubuntu 嗅探工具使用教程大全
一 工具总览与选型
二 快速上手 tcpdump
sudo apt-get update && sudo apt-get install -y tcpdumpsudo tcpdump -Dsudo tcpdump -i any -nsudo tcpdump -i eth0 -n-n(不解析主机名)、-v/-vv/-vvv(详细程度)、-X(显示数据链路/负载十六进制与 ASCII)。sudo tcpdump -i eth0 -w capture.pcaptcpdump -r capture.pcap -nhost 192.168.1.10port 80 or port 443tcp、udp、icmptcp and src host 192.168.1.10 and dst port 80-c 1000-Q in -i any -w cap.pcap -W 10 -C 10 -G 1-G 60 -W 5(每 60 秒一个文件,最多 5 个)sudo tcpdump -i any -A -s 0 'tcp port 80 and (tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420)'(匹配 GET/POST 等 HTTP 方法)sudo tcpdump -i any 'tcp[tcpflags] & tcp-syn != 0' -n三 Wireshark 图形化抓包与过滤
sudo add-apt-repository ppa:wireshark-dev/stable
sudo apt update
sudo apt install -y wireshark
http、dns、tlsip.addr == 192.168.1.10tcp.port == 443sudo tcpdump -i any -w bug.pcapwireshark bug.pcap四 Go 版 sniffer 按进程定位流量
sudo apt-get install -y libpcap-devgo install github.com/chenjiandongx/sniffer@latestsudo $GOPATH/bin/sniffer -i eth0(如未指定接口,会自动选择默认接口)。ip addr 或 ifconfig 查看。五 性能与带宽监控工具
sudo apt-get install -y iftopsudo iftop -i eth0 -n -Psudo apt-get install -y nloadnload eth0sudo apt-get install -y vnstatvnstat -l(实时)、vnstat -d(按日)、vnstat -m(按月)六 入侵检测与进阶
sudo apt-get install -y ossec-hids ossec-hids-clientsudo systemctl start ossec-hids && sudo systemctl enable ossec-hids/var/ossec/etc/ossec.conf(规则、日志收集、主动响应等)。tcp port 80 and host 10.0.0.5tcpdump -w 落盘,再用 Wireshark/tshark 深度分析。七 合规与安全提示