如何测试 Wireshark 解剖器?
当你为 Wireshark 编写解析器时,你如何测试它?对于一个不平凡的协议来说,在 UI 中查找视觉输出是不够的。
有没有好的方法对解析器进行单元测试?
编辑:
协议帧的结构是动态的。解析者必须以某种方式解释内容。
例如,如果第五个字段为 1,则字节数组将作为第六个字段。如果是两个,则有一个双数组,如果是三个,则必须添加一个以零结尾的字符串。
这在日常工作捕获中通常不会发生。这就是为什么您需要合成捕获数据,即使是“不可能”的内容。
When you write a dissector for Wireshark, how do you test it? Looking for the visual output in the UI is not sufficient for a none-trivial protocol.
Is there a good way for unit testing of the dissector?
EDIT:
The structure of protocol frames is dynamic. The dissector must somehow interpret the content.
For example if the fifth field is one a byte array follows as sixth field. If it's two you have a double array and if it's three you have to add a zero terminated string.
This usually never happens in a daily work capture. That's why you need a synthetic capture data even with "impossible" content.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
为了测试 Wireshark 解析器,我发现这很有用:
text2pcap
生成 pcap 文件tshark
运行解析器这可以改进通过过滤 XML 输出,因为 PDML 还包括数据包字节,如果有效负载很大或/和复杂,这可能会很烦人。
wireshark 可执行文件的建议参数是:
要提取解析器输出,将 XPATH 表达式与 .NET CLR 类 XmlNode 结合使用非常有用。这可以通过以下方式完成:
To test a Wireshark dissector I found this useful:
text2pcap
tshark
This can be improved by filtering the XML output since the PDML also includes the packet bytes, what can be annoying if the payload is large or/and complex.
The suggested arguments to the wireshark executables are
To extract the dissector output it's useful to use an XPATH expression with the .NET CLR class XmlNode. This can be done e.g. this way:
您可以使用 Scapy 或 PacketSender 等工具来生成测试数据包。
You can use something like Scapy or PacketSender to generate test packets.
我想我已经是老派了。解析器的主要目的是将数据转换为人类可读的形式,因此我通过让人类阅读它来测试我的解析器。
我想您可以通过从
file->export
导出到 txt 或 pdml 来进行更多自动化测试,或者在插件 DLL 周围实现某种测试包装器。I guess I'm old fashioned. A dissector's primary purpose is transforming data to a human readable form, so I tested mine by having humans read it.
I suppose you could do more automated testing by exporting to txt or pdml from
file->export
, or implementing some sort of test wrapper around your plugin DLL.您可以解析 tshark 的输出。
You could parse the output of tshark.
只是为了更新帖子。
来源: https://ask.wireshark.org/questions/36721/tshark -用于插件测试
Just for updating the post.
source: https://ask.wireshark.org/questions/36721/tshark-for-plugin-testing