使用 tshark,我如何让它解码并显示应用层?
例如,我可以使用以下方法捕获和解码 snmp 流量:
sudo tshark -V -i lo -d udp.port==161,snmp
这将解码所有层,从物理层到应用层(输出截断):
Frame 120: 134 bytes on wire (1072 bits), ...
Interface id: 0
....
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00...
Destination: 00:00:00_00:00:00 ...
....
Internet Protocol Version 4, Src: 127.0.0.1...
Version: 4
....
User Datagram Protocol, Src Port: snmp (161), ....
Source port: snmp (161)
....
Simple Network Management Protocol
version: v2c (1)
community: public
....
(我只想从“简单网络管理协议(protocol)”开始解码)。
我考虑过的其他事情
我知道使用字段输出(例如-e snmp.community)。指定 snmp 的所有字段将永远...
我可以使用 pdml 输出,并使用 XSLT 转换结果。但是 pdml 输出很慢,使用 XSLT 似乎有点矫枉过正:
sudo tshark -V -T pdml -i lo -d udp.port==161,snmp
<proto name="udp" showname="User Datagram Protocol...
<field name="udp.srcport"...
<proto name="snmp" showname="Simple...
<field name="snmp.version" showname="version: v2c...
最佳答案
您可以使用 -O
选项,如帮助输出所示:
-O <protocols>
Only show packet details of these protocols, comma separated
$ tshark -i 4 -O snmp -q -V > snmp.txt
另见 TShark man-page :
-O
Similar to the-V
option, but causes TShark to only show a detailed view of the comma-separated list of protocols specified, rather than a detailed view of all protocols. Use the output of "tshark -G protocols
" to find the abbreviations of the protocols you can specify.
关于wireshark - tshark - 仅输出应用层解码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16891706/