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