当我关闭Wireshark时,如何使Wireshark Lua解析器协议首选项保存并持久化?
2014-3-8 4:56:13
收藏:0
阅读:172
评论:1
所以我写了一种惊人的解析器,它并没有做太多,但它极大地提高了我的工作效率。
我的唯一问题是我暴露了一些偏好设置,并且它们在wireshark关闭/启动时不会保留。
前提:Lua脚本必须在插件目录中...
1. 打开wireshark,编辑>首选项>协议>http.查询参数...
2. 将Param1 Value设置为“aaa”,单击确定。 (它将正确地影响解析。)
3. 关闭wireshark,再次启动,该值又变成其他值。
我的解析器:
-- Written by Eitam Doodai
-- trivial postdissector example
-- 声明要读取的某些字段
full_uri_from_request = Field.new(“http.request.full_uri”)
-- 声明我们的(伪)协议
http_query_params_proto = Proto(“http.query_parameters”,“HTTP查询参数后分析器”)
-- 为我们的“protocol”创建字段
query_param1 = ProtoField.string(“http.query_parameters.param1”,“PARAM1”)
query_param2 = ProtoField.string(“http.query_parameters.param2”,“PARAM2”)
query_param3 = ProtoField.string(“http.query_parameters.param3”,“PARAM3”)
-- 将字段添加到协议中
http_query_params_proto.fields = {query_param1}
http_query_params_proto.fields = {query_param2}
http_query_params_proto.fields = {query_param3}
-- 添加喜好
local p1 = http_query_params_proto.prefs
p1.value1 = Pref.string(“Param1 Value”,“123”,“Param key to extract”)
p1.value2 = Pref.string(“Param2 Value”,“456”,“Param key to extract”)
p1.value3 = Pref.string(“Param3 Value”,“789”,“Param key to extract”)
-- 创建一个函数以“后解剖”每个帧
function http_query_params_proto.dissector(buffer,pinfo,tree)
--获取协议字段的当前值
local full_uri_value = full_uri_from_request()
if full_uri_value then
local value = tostring(full_uri_value)
local本程序添加= tree:add(http_query_params_proto,“Query Param1”)
local本程序添加= tree:add(http_query_params_proto,“Query Param2”)
local本程序添加= tree:add(http_query_params_proto,“Query Param3”)
_,_,query_param1_str = string.find(value,p1.value1 ..“=([^&]+)”)
_,_,query_param2_str = string.find(value,p1.value2 ..“=([^&]+)”)
_,_,query_param3_str = string.find(value,p1.value3 ..“=([^&]+)”)
if query_param1_str then
subtree:add(query_param1,query_param1_str)
end
if query_param2_str then
subtree:add(query_param2,query_param2_str)
end
if query_param3_str then
subtree:add(query_param3,query_param3_str)
end
end
end
--将我们的协议注册为“postdissector”
register_postdissector(http_query_params_proto)
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的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 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
如果你已经打开一个控制台并从命令行启动了 Wireshark,在更改你的
http.query_parameters.param设置之后,保存并关闭 Wireshark,然后重新启动它,你会看到如下内容:这是一个问题:Wireshark 会打印出它找到的保存的偏好设置文件中不理解或不知道的偏好设置。
编辑:请不要就此问题提交错误报告。问题是,你使用了一个已经存在的协议名称作为偏好设置:"
http"。换句话说,由于你主要是给偏好设置命名http.query...,Wireshark 认为它应该属于http协议模块,但是 _真正_的http模块对它一无所知,因此 Wireshark 在下次尝试从偏好设置文件中读取时打印了该错误。长话短说:改变你的原型名称、字段等等的名称,以避免与真实协议名称发生冲突。