Whireshark Lua解析器不显示树形结构
2019-4-1 10:29:40
收藏:0
阅读:101
评论:1
我有一个包,包含了尾随数据,例如ixia时间戳尾随器。我尝试编写一个与ixia-packet_trailer插件类似的Wireshark解析器。https://raw.githubusercontent.com/boundary/wireshark/master/epan/dissectors/packet-ixiatrailer.c
但我想用Lua编写,因为它最容易更改。
我将Lua编写为启发式函数,使用函数is_my_trailer(如Wireshark Lua解析器插件表错误中建议的),现在它停止在以太网树中显示尾随器,所以我相信它能够识别模式0xae12,但它不显示我的"my trailer"树形结构
-- 声明我们的协议
local my_trailer_proto = Proto("my_trailer","my Trailer")
-- 头字段
local timestamp = ProtoField.uint64 ("my_trailer_proto.timestamp", "timestamp", base.HEX)
local proto_flag = ProtoField.uint8 ("my_trailer_proto.proto_flag", "protoFlag", base.HEX)
local msg_id = ProtoField.uint16("my_trailer_proto.msg_id" , "msdId" , base.HEX)
my_trailer_proto.fields = { timestamp, proto_flag, msg_id }
-- 此数据包是否包含尾随器
local function is_my_trailer(buffer,pinfo,tree)
local length = buffer:len()
if length < 12 then return 1 end
local type = buffer(length-12, 2):uint()
if type == 0xae12 then return true end
return false
end
function my_trailer_proto.dissector(buffer, pinfo, tree)
length = buffer:len()
if length == 0 then return end
local subtree = tree:add(my_trailer_proto, buffer(), "my trailer")
-- Header
subtree:add(timestamp, buffer(length-10,8))
subtree:add(proto_flag, buffer(length-3,1))
subtree:add(msg_id, buffer(length-2,2))
pinfo.cols.protocol = my_trailer_proto.name
pinfo.cols.protocol:set("proto_flag")
pinfo.cols.info:set("proto_flag: " .. proto_flag)
end
my_trailer_proto:register_heuristic("eth.trailer", is_my_trailer)
这里有一个带尾随器的pcap文件示例https://transfernow.net/87kwt2k0dne7
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

你忘记了一行关键的代码:
if type == 0xae12 then return true end return false应该改为:
if type == 0xae12 then my_trailer_proto.dissector(buffer, pinfo, tree) return true end return false你还有另一个错误。这行是一个错误:
pinfo.cols.info:set("proto_flag: " .. proto_flag)应该改为:
pinfo.cols.info:set("proto_flag: " .. buffer(length-3,1):uint())