使用lua为wireshark编写解析hj212-2017协议的插件

文章目录

前言

这是学习利用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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值