wireshark - tshark - 仅输出应用层解码

标签 wireshark tcp tshark

使用 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/

相关文章:

c# - TCP/IP .NET 套接字效率

linux - tshark 中 pcap 的明文输出(使用 wireshark 的选项?)

.net - 如何检查 ldap 连接是否安全?

ssl - 解密由于 JMeter https 请求(例如通过 Wireshark)生成的 `Encrypted Alert` 数据包

c# - 为什么使用 wireshark 捕获一个 c# ssl 服务器/客户端程序得到 TCP 包?

tcp - BPF 过滤器 TCP 连接

tcp - 在哪里可以找到 WireShark 的 IP 分段示例 pcaps?

linux - 如何在 Linux 上设置最大 TCP 最大段大小?

networking - 将数据包写入输出文件时 tshark 显示过滤器不起作用

linux - 提取 pcap 文件中的字节范围