神探tcpdump第三招
2019獨角獸企業(yè)重金招聘Python工程師標準>>>
上篇文章說過,tcpdump會分成“選項”、“過濾表達式”和“輸出信息”三部分講解。
????截止到目前,我們一直在圍繞tcpdump的選項部分進行講解,已經(jīng)介紹過的選項包括-i選項、-nn選項、-c選項、-X選項、-e選項、-l選項。
???? 今天仍然不例外,我們繼續(xù)有關(guān)選項的內(nèi)容。
????==
????【-t選項】- 輸出時不打印時間戳
????這個選項非常好理解,直接看例子吧:
# tcpdump -i eth0 -c 1 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes 01:52:10.433391 ARP, Request who-has 116.255.247.61 tell 116.255.247.125, length 64 # tcpdump -i eth0 -c 1 -t tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes ARP, Request who-has 116.255.245.35 tell 116.255.245.62, length 64????【-v選項】- 輸出更詳細的信息
????加了-v選項之后,在原有輸出的基礎(chǔ)之上,你還會看到tos值、ttl值、ID值、總長度、校驗值等。
???? 至于上述值的含義,需要你專門去研究下IP頭、TCP頭的具體協(xié)議定義咯。
# tcpdump -i eth0 -c 1 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes 01:53:09.162644 IP 116.255.245.206.snapenetio > 221.223.255.234.54198: Flags [P.], seq 1443040202:1443040398, ack 3517061690, win 353, length 196 # tcpdump -i eth0 -c 1 -v tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes 01:52:57.902894 IP (tos 0x10, ttl 64, id 18293, offset 0, flags [DF], proto TCP (6), length 172) 116.255.245.206.snapenetio > 221.223.255.234.54198: Flags [P.], cksum 0x4dd9 (correct), seq 1443039302:1443039434, ack 3517061430, win 353, length 132????【-F選項】- 指定過濾表達式所在的文件
????還記得我們在第一招中所提到的命令么,我?guī)椭蠹一貞浺幌?#xff1a;
tcpdump -i eth0 -nn -X ‘port 53′ -c 1????這里面的’port 53′便叫做“過濾表達式”,用于設(shè)置我們抓包的條件的,只有滿足過濾條件的網(wǎng)絡(luò)包,才會被抓過來。
???? 當這個過濾條件非常復(fù)雜,或者我們需要將一個過濾條件固化下來復(fù)用的時候,就會想到把它存到一個文本文件中。
???? 此時,-F選項就會派上用場。請看例子:
# cat filter.txt port 53 # tcpdump -i eth0 -c 1 -t -F filter.txt tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes IP 116.255.245.206.54357 > ns.sc.cninfo.net.domain: 36720+ A? www.baidu.com. (31) 1 packets captured 6 packets received by filter 0 packets dropped by kernel????我們建立了一個filter.txt文本文件來存儲過濾表達式,然后通過-F來指定filter.txt,這樣tcpdump就會心知肚明地讀取filter.txt中的內(nèi)容作為過濾條件。
????==
????下一招,會使選項講解的最后一次,重點講講-w和-r兩個選項,敬請期待。
轉(zhuǎn)載于:https://my.oschina.net/leejun2005/blog/77472
總結(jié)
以上是生活随笔為你收集整理的神探tcpdump第三招的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一段基于Jsoup和Dom4j的海报爬取
- 下一篇: XSLT 学习一