当我关闭Wireshark时,如何使Wireshark Lua解析器协议首选项保存并持久化?

所以我写了一种惊人的解析器,它并没有做太多,但它极大地提高了我的工作效率。

我的唯一问题是我暴露了一些偏好设置,并且它们在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.dissectorbufferpinfotree--获取协议字段的当前值
        local full_uri_value = full_uri_from_request()
        if full_uri_value then
                local value = tostringfull_uri_valuelocal本程序添加= tree:addhttp_query_params_proto,“Query Param1”)
                local本程序添加= tree:addhttp_query_params_proto,“Query Param2”)
                local本程序添加= tree:addhttp_query_params_proto,“Query Param3”)
                __query_param1_str = string.findvaluep1.value1 ..“=([^&]+)”)
                __query_param2_str = string.findvaluep1.value2 ..“=([^&]+)”)
                __query_param3_str = string.findvaluep1.value3 ..“=([^&]+)”)
                if query_param1_str then
                        subtreeaddquery_param1query_param1_strend

                if query_param2_str then
                        subtreeaddquery_param2query_param2_strend
                if query_param3_str then
                        subtreeaddquery_param3query_param3_strend
        end
end

--将我们的协议注册为“postdissector”
register_postdissectorhttp_query_params_proto
点赞
用户3395060
用户3395060

如果你已经打开一个控制台并从命令行启动了 Wireshark,在更改你的 http.query_parameters.param 设置之后,保存并关闭 Wireshark,然后重新启动它,你会看到如下内容:

......偏好设置行1829:没有这样的偏好设置 “http.query_parameters.value2”(应用您的首选项一次应该删除这个警告)

这是一个问题:Wireshark 会打印出它找到的保存的偏好设置文件中不理解或不知道的偏好设置。

编辑:请不要就此问题提交错误报告。问题是,你使用了一个已经存在的协议名称作为偏好设置:"http"。换句话说,由于你主要是给偏好设置命名 http.query...,Wireshark 认为它应该属于 http 协议模块,但是 _真正_的 http 模块对它一无所知,因此 Wireshark 在下次尝试从偏好设置文件中读取时打印了该错误。

长话短说:改变你的原型名称、字段等等的名称,以避免与真实协议名称发生冲突。

2014-03-08 04:49:19