我有一个自定义协议,我正在wireshark中查看.我认为如果wireshark可以为我解读它,那么我将不需要解码十六进制.虽然我在我的程序日志中这样做,但wireshark使用时间信息捕获整个会话,因此它在那里更有用.
这可以轻松完成吗?
当您为Wireshark编写解剖器时,您如何测试它?在UI中寻找可视输出对于一个非平凡的协议是不够的.
解剖器的单元测试是否有好的方法?
编辑:
协议帧的结构是动态的.解剖器必须以某种方式解释内容.
例如,如果第五个字段是1,则字节数组作为第六个字段.如果它是两个你有一个双数组,如果它是三个你必须添加一个零终止字符串.
这通常不会发生在日常工作中.这就是为什么你需要合成捕获数据,即使是"不可能"的内容.
首先,我完全是Lua的新手,这是我第一次尝试编写wirehark解剖器.
我的协议很简单 - 一个2字节长的字段,后跟一个长度的字符串.
当我通过Lua控制台运行代码时,一切都按预期工作.
当代码添加到Wireshark插件目录时,我收到错误
Lua错误:[string"C:\ Users ...\AppData\Roaming\Wireshark ..."]:15:在糟糕的自我中调用'add'(数字预期,得到字符串)
第15行对应的是t:add(f_text...
直线.
任何人都可以解释执行方法之间的差异吗?
do
local p_multi = Proto("aggregator","Aggregator");
local f_len = ProtoField.int16("aggregator.length","Length",base.DEC)
local f_text = ProtoField.string("aggregator.text","Text")
p_multi.fields = { f_len, f_text }
local data_dis = Dissector.get("data")
function p_multi.dissector(buf,pkt,root)
pkt.cols.protocol = "Aggregator"
local len = buf(0,2):int()
local t = root:add(p_multi,buf(0,len+2))
t:add(f_len,buf(0,2),"Length: " .. buf(0,2):int())
t:add(f_text,buf(2,len),"Text: " .. buf(2,len):string())
end
local tcp_encap_table = DissectorTable.get("tcp.port")
tcp_encap_table:add(4321,p_multi)
end
Run Code Online (Sandbox Code Playgroud) 我在wireshark中打开了一个pcap,它显示了很多数据包作为"重新组装的pdu的tcp段".wireshark如何确定哪些tcp数据包是重组pdu的片段?我无法找到任何标题字段或其他任何wirehark可以确定这一点.
任何帮助将不胜感激.谢谢 !!!
network-programming packet-capture tcpdump wireshark wireshark-dissector
我正在尝试为基于bplists的Safari远程调试协议编写一个解剖器并且已经相当成功(当前代码在这里:https://github.com/andydavies/bplist-dissector).
虽然我在重新组装数据包时遇到了困难.
通常,协议发送一个包含4个字节的数据包,其中包含下一个数据包的长度,然后是包含bplist的数据包.
不幸的是,来自iOS模拟器的一些数据包不符合此约定,并且四个字节或者标记在bplist数据包的前面,或者标记在前一个bplist数据包的末尾,或者数据是多个bplists.
我试着用重组他们desegment_len
和desegment_offset
如下:
function p_bplist.dissector(buf, pkt, root)
-- length of data packet
local dataPacketLength = tonumber(buf(0, 4):uint())
local desiredPacketLength = dataPacketLength + 4
-- if not enough data indicate how much more we need
if desiredPacketLen > buf:len() then
pkt.desegment_len = dataPacketLength
pkt.desegment_offset = 0
return
end
-- have more than needed so set offset for next dissection
if buf:len() > desiredPacketLength then
pkt.desegment_len = DESEGMENT_ONE_MORE_SEGMENT
pkt.desegment_offset = desiredPacketLength
end …
Run Code Online (Sandbox Code Playgroud) 我正在遵循wireshark文档中给出的foo示例。我能够构建foo代码插件。我正在使用wireshark 3.0.1版本。在workroot文件夹中,我在gryphon之前更新了目标-PLUGIN_SRC_DIRS-plugins / epan / foo。
我可以看到我的代码可以构建,因为我遇到了一些编译错误,因此可以对其进行修复。
我的foo代码位于plugins / epan文件夹中。我正在运行自定义的Wireshark-sudo ./run/wireshark在这里,我什至在运行的Wirehark中甚至都看不到gryphon协议字段,这是一个惊喜。因此,为了测试这一点,我在该显示过滤器中键入foo或gryphon,它变成红色,并说foo既不是协议也不是协议字段。我正在使用Ubuntu 16.04 LTS进行构建。构建顺利。
这是packet-foo.c
#include "config.h"
#include <epan/packet.h>
#include "packet-foo.h"
static int proto_foo = -1;
static int dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_);
void
proto_register_foo(void)
{
proto_foo = proto_register_protocol (
"FOO Protocol", /* name */
"FOO", /* short name */
"foo" /* abbrev */
);
}
void
proto_reg_handoff_foo(void)
{
static dissector_handle_t foo_handle;
foo_handle = create_dissector_handle(dissect_foo, proto_foo);
dissector_add_uint("udp.port", FOO_PORT, foo_handle);
}
static int
dissect_foo(tvbuff_t *tvb, packet_info *pinfo, …
Run Code Online (Sandbox Code Playgroud) 如何在自定义Wireshark解剖器中识别丢失的UDP帧?
我为CQS提要编写了一个自定义解剖器(参考页面).收到此Feed时,我们的服务器之一存在差距.根据Wireshark的说法,从未收到过一些UDP帧.我知道帧已经发送,因为我们所有其他服务器都没有间隙.
CQS帧由多个消息组成,每个消息具有其自己的序列号.我的自定义解剖器向Wireshark提供以下数据:
cqs.frame_gaps - the number of gaps within a UDP frame (always zero)
cqs.frame_first_seq - the first sequence number in a UDP frame
cqs.frame_expected_seq - the first sequence number expected in the next UDP frame
cqs.frame_msg_count - the number of messages in this UDP frame
Run Code Online (Sandbox Code Playgroud)
我在自定义列中显示每个值,如此屏幕截图所示:wireshark screenshot http://img692.imageshack.us/img692/9484/wiresharkcqs.jpg
我尝试将代码添加到我的解剖器中,只需保存最后处理的序列号(作为本地静态),并在解剖器处理帧时标记间隙current_sequence != (previous_sequence + 1)
.这不起作用,因为可以按随机访问顺序调用解剖器,具体取决于您在GUI中单击的位置.所以你可以处理第10帧,然后是第15帧,然后第11帧,等等.
有没有办法让我的解剖器知道它前面的框架(或后面的框架)是否缺失?
解剖器用C语言编写.
(另请参阅serverfault.com上的配套文章)
我正在使用wireshark中的消息制造规范(MMS).该工具无法剖析ACSE图层.它没有显示任何错误,但它显示ACSE数据作为MMS的一部分,即,在表示层之后,显示MMS.如果有线路可以区分两个层,请提供帮助.
谢谢.
我需要在 Wireshark lua 解剖器中解剖一个位映射的八位字节。八位字节具有格式:
bit 0: Concatenation (0=No concatenation, 1=Concatenation)
bits 1..3: Reserved
bits 4..7: Version
Run Code Online (Sandbox Code Playgroud)
我已经成功地剖析了它:
Concatenation_F = ProtoField.uint8("Concatenation", "Concatenation", base.DEC, NULL, 0x1)
Version_F = ProtoField.uint8("Version", "Version", base.DEC, NULL, 0xF0)
my_protocol.fields = { Concatenation_F,
Version_F
}
<snip>
local Concatenation_range = buffer(0,1)
local Version_range = buffer(0,1)
local Concatenation = Concatenation_F:uint()
local Version = Version_range:uint()
subtree:add(Concatenation_F, Concatenation_range, Concatenation)
subtree:add(Version_F, Version_range, Version)
Run Code Online (Sandbox Code Playgroud)
那行得通,但我想展示 Concatenation 字段的含义,例如:
但要做到这一点,我需要获得 Concatenation 位的值。我怎样才能做到这一点?
我有一个使用wireshark捕获的pcap文件.假设pcap有6个包,编号从1到6,如下所示.现在我想编辑这个pcap文件,以便我以不同的顺序获取数据包.例如,如果原始pcap包是
1,2,3,4,5,6
Run Code Online (Sandbox Code Playgroud)
我想要一个新的pcap编辑后,现在数据包在顺序(例如)如下:
2,3,1,4,5,6
Run Code Online (Sandbox Code Playgroud)
类似地,我可以有一些其他订单,例如,2,4,5,6,1,3或任何其他订单.
任何人都可以让我知道我该怎么做?(可能使用wireshark或任何其他方法).任何帮助将不胜感激.谢谢
network-programming packet-capture tcpdump wireshark wireshark-dissector