前言
这是学习利用lua为wireshark编写插件的练手作。
其实谈不上解析HJ212协议,这里编写的插件是把HJ212协议识别出来,在wireshark中可以看到协议名称,方便查看。
继续对其解析,可以把datetime,MN,数据段等分别解析出来,值得继续研究。
对于wireshark的lua的使用,包括在wireshark中加载lua脚本,可以参看官网和文章最后的引用。
代码
-- 第一个参数协议名称,第二个参数协议描述,在wireshark protocal窗格显示为hj212-2017
local hj212_proto=Proto("hj212-2017","environment 212 protocal")
------------------------------------------------------------------------
-- 各参数的含义可以看参考中的两篇文章
function hj212_proto.dissector(tvb,pinfo,tree)
pinfo.cols.protocol = hj212_proto.name
data_len = tvb:len()
local d=tree:add(hj212_proto.name.."-Data")
d:append_text("("..data_len.." bytes of data)")
--
local data_dis = Dissector.get("data")
data_dis:call(tvb(0):tvb(), pinfo,d)
end
---------------------------------------------------------------
local tcp_port_table=DissectorTable.get("tcp.port")
-- 默认10086端口
tcp_port_table:add(10086,hj212_proto)
参考
https://blog.csdn.net/qq_40421919/article/details/103516694
https://blog.csdn.net/wangquan1992/article/details/100161021