Wireshark lua解析器无法为媒体加载\u type=应用程序/八位字节流
我正试图编写一个lua协议来解析http上的私有协议。但是当媒体类型为应用程序/八位字节流时,Wireshark没有进入我的剖析器函数。当媒体类型设置为text/html时,一切看起来都很好。 应用程序/八位字节流是否有特殊处理? 我花了将近一天的时间,你能帮我吗? Thx很多 我的wireshark版本是mac osx 10.8.5上的1.10.2 这是我的密码Wireshark lua解析器无法为媒体加载\u type=应用程序/八位字节流,lua,wireshark,media-type,Lua,Wireshark,Media Type,我正试图编写一个lua协议来解析http上的私有协议。但是当媒体类型为应用程序/八位字节流时,Wireshark没有进入我的剖析器函数。当媒体类型设置为text/html时,一切看起来都很好。 应用程序/八位字节流是否有特殊处理? 我花了将近一天的时间,你能帮我吗? Thx很多 我的wireshark版本是mac osx 10.8.5上的1.10.2 这是我的密码 do local myproto= Proto("myprotoProtocol","myproto Protocol")
do
local myproto= Proto("myprotoProtocol","myproto Protocol")
local f_version= ProtoField.uint32("Version","Version",base.DEC)
myproto.fields = {f_version}
local data_dis = Dissector.get("data")
local function myproto_dissector(tvb,pkt,root)
print("enter myproto_dissector, tvb.len:"..tostring(tvb:len()))
if tvb:len() < 17 then return false end
pkt.cols.protocol = "myproto"
local t =root:add(myproto,tvb)
t:add(f_version,tvb(0,2))
local version = tvb(0,2).uint()
print("version:"..tostring(version))
return true
end
function myproto.dissector(tvb,pkt,root)
print("enter myproto.dissector")
if not myproto_dissector(tvb,pkt,root) then
data_dis:call(tvb,pkt,root)
end
end
local tbl= DissectorTable.get("media_type")
tbl:add("application/octet-stream",myproto)
--tbl:add("text/html",myproto) --text/html looks fine
print("adding myproto into DissectorTable")
end
用于文本/html
$tshark -r test.pcapng -X lua_script:canon.lua | grep myproto
adding myproto into DissectorTable
enter myproto.dissector
enter myproto_dissector, tvb.len:2
enter myproto.dissector
enter myproto_dissector, tvb.len:6
enter myproto.dissector
enter myproto_dissector, tvb.len:6
可能是wireshark的错误,因为它的媒体类型不在剖析器表中表中尚未列出“应用程序/八位字节流”。
在Wireshark中使用Lua->evaluate之后,解析器表显示了我的协议,如图所示,“应用程序/八位字节流”在mess代码中
当我在tshark中使用“printtbl:get_dissectorapplication/octet stream”时,它显示了MYPROTO。看起来是正确的。请向Wireshark提交一个bug,无论是否更改代码,但最好使用一个示例捕获文件来显示问题,即使只有一个或两个数据包也可以
我本想对此发表评论,但我没有足够的理由这么做显然我认为我在修改源代码wslua_proto.c第1722行-comment g_freepattern;后发现了问题;。因为sub_dissectors->hash_表只是将模式添加为point,而没有在packet.c中复制副本。这个错误似乎是从v1.8、1.6开始引入的。在trunk、1.10和1.8版本中,模式是重复的,请参见dissector_add_string中/*do the table insertion*/注释后的语句;它调用g_strdup作为g_hash_table_insert调用的第二个参数。
$tshark -r test.pcapng -X lua_script:canon.lua | grep myproto
adding myproto into DissectorTable
enter myproto.dissector
enter myproto_dissector, tvb.len:2
enter myproto.dissector
enter myproto_dissector, tvb.len:6
enter myproto.dissector
enter myproto_dissector, tvb.len:6