1. 程式人生 > >Wireshark實戰之抓包MySQL Java客戶端

Wireshark實戰之抓包MySQL Java客戶端

tcpdump ip host 210.27.48.1

tcpdump 與wireshark

Wireshark(以前是ethereal)是Windows下非常簡單易用的抓包工具。但在Linux下很難找到一個好用的圖形化抓包工具。還好有Tcpdump。我們可以用Tcpdump + Wireshark 的完美組合實現:在 Linux 裡抓包,然後在Windows 裡分析包。

tcpdump tcp -i eth1 -t -s 0 -c 100 and dst port ! 22 and src net 192.168.1.0/24 -w ./target.cap

(1)tcp: ip icmp arp rarp 和 tcp、udp、icmp這些選項等都要放到第一個引數的位置,用來過濾資料報的型別
(2)-i eth1 : 只抓經過介面eth1的包
(3)-t : 不顯示時間戳
(4)-s 0 : 抓取資料包時預設抓取長度為68位元組。加上-S 0 後可以抓到完整的資料包
(5)-c 100 : 只抓取100個數據包
(6)dst port ! 22 : 不抓取目標埠是22的資料包
(7)src net 192.168.1.0/24 : 資料包的源網路地址為192.168.1.0/24
(8)-w ./target.cap : 儲存成cap檔案,方便用ethereal(即wireshark)分析