⑴ 在linux上tshark怎麼過濾
抓Mysql包命令如下:
tshark -s 512 -i eth0 -n -f 'tcp dst port 3306' -R 'mysql.query' -T fields -e mysql.query
tshark -s 512 -i em1 -n -f 'tcp dst port 3306' -R 'mysql.query' -T fields -e mysql.query
過濾HTTP請求:
# tshark 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -R 'http.request.method == "GET" || http.request.method == "HEAD"'
輸出:
Running as user "root" and group "root". This could be dangerous.
Capturing on eth0
0.000000 123.126.68.27 -> 173.255.196.50 HTTP GET /grep.html HTTP/1.1
12.066470 123.126.68.27 -> 173.255.196.50 HTTP GET /pro_lang.html HTTP/1.1
-s 512 :只抓取前512個位元組數據
-i eth0 :捕獲eth0網卡
-n :禁止網路對象名稱解析
-f 'tcp dst port 3306' :只捕捉協議為tcp,目的埠為3306的數據包
-R 'mysql.query' :過濾出mysql.query
-T fields -e mysql.query :列印mysql查詢語句
tshark使用-f來指定捕捉包過濾規則,規則與tcpmp一樣,可以通過命令man pcap-filter來查得。
tshark使用-R來過濾已捕捉到的包,與界面板wireshark的左上角Filter一致。