linux过滤端口抓包_Linux抓包工具tcpdump使用总结,WireShark的过滤用法
tcpdump與WireShark是Linux下的兩個常用,功能強(qiáng)大的抓包工具,下面列出這兩個工具的簡單用法。
tcpdump用法
tcpdump用法:
sudo tcpdump -i ens33 src 192.168.0.19 port 80 -xx -Xs 0 -w test.cap
sudo tcpdump -i ens33 src port 80 -xx -Xs 0 -w test.cap
參數(shù)說明:
-i: 指定網(wǎng)卡
src: 指明包的來源
port: 指明端口號
-xx: 指抓到的包以16進(jìn)制顯示
-X: 指以ASCII碼顯示
-s 0: 指明抓整個包
-w: 寫到文件中
WireShark過慮用法
【W(wǎng)ireShark中的邏輯運(yùn)算】
與: and 或 &&
或: or 或 ||
非: not 或!
WireShark中的判斷語句
等于: eq 或 ==
大于: gt 或 >
小于: lt 或 <
大于等于: ge 或 >=
小于等于: le 或 <=
不等于: ne 或 !=
組合符(小括號)
()
包含與正由表達(dá)式匹配運(yùn)算符
contains
matches
注意:matches 后的關(guān)鍵字是不區(qū)分大小寫的,contains后面的關(guān)鍵字區(qū)分大小寫。
【協(xié)議過濾】
在表達(dá)式輸入框中輸入?yún)f(xié)議名稱即可。
注意:協(xié)議名稱為小寫,大寫會報錯
http
udp
tcp
arp
icmp
smtp
pop
dns
ip
ssl
ftp
telnet
ssh
rdp
rip
ospf
捕獲多種協(xié)議,只需要對協(xié)議進(jìn)行邏輯組合
http or udp
排除某種協(xié)議的數(shù)據(jù)包
not arp not tcp
【http域名與url過濾】
按內(nèi)容長度過濾
http.content_length <= 100
http.content_length_header <= 100
針對數(shù)據(jù)包內(nèi)容的過濾
匹配http請求中含有/api/member/health/check 的請求信息
http.request.uri matches "/api/member/health/check"
查詢url中包含/api/member/home/test.html? 字符串的信息
http.request.uri contains "/api/member/home/test.html?"
按域名過濾
http.host == "jd.com" #精確過濾
http.host contains "jd.com" #模糊過慮
過濾請求的uri,取值是域名后的部分
http.request.uri=="/online/setpoint"
過濾完整的url
http.request.full_uri=="https://passport.jd.com/uc/login"
按http響應(yīng)的狀態(tài)過慮
http.response.code==302
http.response.code==401
過濾所有的http響應(yīng)包
http.request==1
http.response==1
過濾所有請求方式為POST或GET的http請求包,注意POST或GET為大寫
http.request.method==GET
http.request.method==POST
過濾含有指定cookie的http數(shù)據(jù)包
http.cookie contains userid
過濾http頭中server字段含有nginx字符的數(shù)據(jù)包
http.server contains "nginx"
過濾content_type是text/html的http響應(yīng)
http.content_type == "text/html"
過濾content_type是application/json的http響應(yīng)
http.content_type == "application/json"
過濾content_encoding是gzip的http包
http.content_encoding == "gzip"
過濾所有含有http頭中含有server字段的數(shù)據(jù)包
http.server
過濾HTTP/1.1版本的http包,包括請求和響應(yīng)
http.request.version == "HTTP/1.1"
過濾http響應(yīng)中的phrase
http.response.phrase == "OK"
【ip與端口過濾】
按目標(biāo)地址過濾
ip.dst==192.168.0.19
按源地址過濾
ip.src==192.168.0.26
按目標(biāo)地址或源地址過濾
ip.addr==192.168.0.19
按目標(biāo)端口或源端口過濾
tcp.port==1935
udp.port==2365
按源端口過濾
tcp.srcport==2365
udp.srcport==2365
按目標(biāo)端口過濾
tcp.dstport==1935
udp.dstport==1935
【數(shù)據(jù)過濾】
按包長度過濾
tcp.length < 300
udp.length < 300
過濾指定長度的udp數(shù)據(jù)包
udp.length == 20
過濾指定長度的tcp數(shù)據(jù)包
tcp.length == 20
過濾data部分長度為8的數(shù)據(jù)包
data.len==8
過濾指定內(nèi)容的數(shù)據(jù)包
data.data == 00:08:30:03:00:00:00:00
【捕獲經(jīng)過指定ip的數(shù)據(jù)包】
抓取192.168.0.1 收到和發(fā)出的所有數(shù)據(jù)包
host 192.168.0.9
源地址192.168.0.1發(fā)出的所有數(shù)據(jù)包
src host 192.168.0.9
目標(biāo)地址192.168.0.1收到的所有數(shù)據(jù)包
dst host 192.168.0.9
根據(jù)主機(jī)名過濾
src host hostnam
根據(jù)MAC地址過濾
ether host 80:05:09:03:E4:35
網(wǎng)絡(luò)過濾,過濾整個網(wǎng)段
net 192.168.0
src net 192.168
dst net 192
【MAC地址過濾】
過濾目標(biāo)或源地址是00:11:22:33:44:55的數(shù)據(jù)包
eth.addr== 00:11:22:33:44:55
過濾源地址是00:11:22:33:44:55的數(shù)據(jù)包
eth.src== 00:11:22:33:44:55
過濾目標(biāo)地址是00:11:22:33:44:55的數(shù)據(jù)包
eth.dst== 00:11:22:33:44:55
【組合過濾】
捕獲udp源端口等于3457,源ip等于3457,或者udp目標(biāo)端口等于1091,目標(biāo)ip等于192.168.0.10的數(shù)據(jù)包
(upd.srcport==3457 and ip.src=192.168.0.9) or (upd.dstport==1091 and ip.dst=192.168.0.10)
抓取所有目的網(wǎng)絡(luò)是192.168,但目的主機(jī)不是192.168.0.2 的TCP數(shù)據(jù)
(tcp) and ((dst net 192.168) and (not dst host 192.168.0.2))
抓取所有目標(biāo)MAC 地址是80:05:09:03:E4:35 的ICMP 數(shù)據(jù)
(icmp) and ((ether dst host 70:03:09:15:F4:12))
icmp && eth.dst==70:03:09:15:F4:12
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的linux过滤端口抓包_Linux抓包工具tcpdump使用总结,WireShark的过滤用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 孙权是怎么死的 孙权到底是怎么死的
- 下一篇: 统信uos系统考试题_离Windows更