不忘初心 继续前进网站怎么做,营销型网站建设的注意事项,wordpress 表单数据,订阅号可以做网站链接吗最终效果如下#xff1a;
参考文档#xff1a;https://mika-s.github.io/topics/ 此参考文档中7个例子教我们如何编写lua脚本去识别我们自定义的协议
安装Wireshark
https://www.wireshark.org/上下载安装包安装即可。我的安装路径是D:\Install\Wireshark#xff0c;在W…最终效果如下
参考文档https://mika-s.github.io/topics/ 此参考文档中7个例子教我们如何编写lua脚本去识别我们自定义的协议
安装Wireshark
https://www.wireshark.org/上下载安装包安装即可。我的安装路径是D:\Install\Wireshark在Wireshark的菜单帮助-关于-文件夹中有安装位置
要解析的协议
本次要解析的协议是UDP协议在UDP基础上封装了一层应用层协议。协议明细如下
编写脚本前需要明确的几个对象 Proto协议对象有一个name的属性在构造函数第一个参数时传入,决定了这里显示什么配合函数中的赋值 ProtoField协议字段有如下方法 uint8/int8(filter_string,display_name,display_type)uint16/int16(filter_string,display_name,display_type)uint32/int32(filter_string,display_name,display_type)
编写插件脚本
lua文件的位置有两种位置可以放
任意位置此时需要在init.lua中添加dofile把lua文件添加进去plugins文件夹此时wireshark启动时自动执行按CtrShiftL会重新加载 我们采用第2中方式 在D:\Install\Wireshark\plugins中新建一个test.lua文件 在lua脚本中添加如下代码
--协议对象 构造函数第一个参数显示在协议列第二个参数协议描述
local my_requestProto(myrequst,my custom request)-- 要显示的字段构造函数第一个参数用于上方搜索栏过滤的 第二个参数显示在下方协议中的字段 第三个字段显示十进制还是十六进制
local time_secondProtoField.uint8(myrequst.time_second,秒,base.HEX)
local time_minuteProtoField.uint8(myrequst.time_minute,分,base.HEX)
local time_hourProtoField.uint8(myrequst.time_hour,时,base.HEX)
local time_dayProtoField.uint8(myrequst.time_day,天,base.HEX)
local time_monthProtoField.uint8(myrequst.time_month,月,base.HEX)
local time_yearProtoField.uint8(myrequst.time_year,年,base.HEX)local groupProtoField.uint8(myrequst.group,组,base.HEX)local cmdProtoField.uint16(myrequst.cmd,命令,base.DEC)local lenProtoField.uint32(myrequst.length,body长度,base.DEC)-- 将字段添加到协议对象
my_request.fields{time_second,time_minute,time_hour,time_day,time_month,time_year,group,cmd,len}-- 此方法返回bool,返回true表示自定义的协议验证通过会传入三个参数
-- buffer:包去掉继承协议之后的内容。比如继承udp那udp的报文就被去掉了buffer只表示udp的应用层内容
-- pinfo:显示抓包内容列表的信息。赋值协议名称时会用到
-- tree:下方的树结构
local function checker(buffer,pinfo,tree)local lengthbuffer:len()if length26 thenreturn falseend-- 头判断if buffer(0,1):uint()~0x48 orbuffer(1,1):uint()~0x54 orbuffer(2,1):uint()~0x56 orbuffer(3,1):uint()~0x58 orbuffer(4,1):uint()~0x41 orbuffer(5,1):uint()~0x58 orbuffer(6,1):uint()~0x42 orbuffer(7,1):uint()~0x58 orbuffer(8,1):uint()~0x49 orbuffer(9,1):uint()~0x58 thenreturn falseend-- 赋值协议列pinfo.cols.protocolmy_request.name--字段解析local subtreetree:add(my_request,buffer(),我自定义的请求)subtree:add(time_second,buffer(10,1))subtree:add(time_minute,buffer(11,1))subtree:add(time_hour,buffer(12,1))subtree:add(time_day,buffer(13,1))subtree:add(time_month,buffer(15,1))subtree:add(time_year,buffer(16,1))subtree:add(group,buffer(18,1))subtree:add_le(cmd,buffer(19,1))subtree:add(len,buffer(21,4))return true
end
-- 注册让wireshark解析包的时候会调用checker
my_request:register_heuristic(udp,checker)
保存lua脚本之后按CtrShiftL就可以看到效果啦