【问题标题】:How can I get a wireshark Lua dissector protocol preferences to save and persist when I close wireshark?当我关闭wireshark时,如何获取wireshark Lua解析器协议首选项以保存和保留?
【发布时间】:2014-03-08 14:01:38
【问题描述】:

所以我写了我只能称之为令人敬畏的解剖器。作用不大,却大大提高了我的工作效率。

我唯一的问题是我暴露了一些偏好,他们不会坚持通过wireshark关闭/启动。

I.E. :

先决条件:Lua 脚本必须在插件目录中...

  1. 打开 wireshark,编辑 > 首选项 > 协议 > http.queryparameters...
  2. 将 Param1 值设置为“aaa”,单击“确定”。 (会影响正常解剖。)
  3. 关闭wireshark,重新启动,值又是别的东西了。

我的解剖器:

-- Written by Eitam Doodai
-- trivial postdissector example
-- declare some Fields to be read
full_uri_from_request = Field.new("http.request.full_uri")

-- declare our (pseudo) protocol
http_query_params_proto = Proto("http.query_parameters","HTTP Query Parameters Postdissector")

-- create the fields for our "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")

-- add the field to the protocol
http_query_params_proto.fields = {query_param1}
http_query_params_proto.fields = {query_param2}
http_query_params_proto.fields = {query_param3}

-- Add prefs
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")

-- create a function to "postdissect" each frame
function http_query_params_proto.dissector(buffer,pinfo,tree)
        -- obtain the current values the protocol fields
        local full_uri_value = full_uri_from_request()
        if full_uri_value then
                local value = tostring(full_uri_value)
                local subtree = tree:add(http_query_params_proto,"Query Param1")
                local subtree = tree:add(http_query_params_proto,"Query Param2")
                local subtree = 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

-- register our protocol as a postdissector
register_postdissector(http_query_params_proto)

【问题讨论】:

    标签: lua wireshark wireshark-dissector


    【解决方案1】:

    如果您打开控制台并从命令行启动wireshark,在您更改http.query_parameters.param 设置之一后,保存并关闭wireshark,然后重新启动它,您将看到如下内容:

    ...preferences line 1829: No such preference "http.query_parameters.value2" (applying your preferences once should remove this warning)
    

    这是一个问题:wireshark 打印出它在保存的首选项文件中找到的首选项,但它不理解/不知道。

    编辑:不要打开关于此的错误。问题是您使用的协议名称已经存在,首选项:“http”。换句话说,由于您基本上将首选项命名为http.query...,因此wireshark 认为它应该属于http 协议模块,但real http 模块对此一无所知,因此,wireshark 会在下次尝试从首选项文件中读取时打印该错误。

    长话短说:更改 Proto 和字段的名称等,以免与真正的协议名称发生冲突。

    【讨论】:

    • Precious,即使问了这个问题,我也一直在努力,几乎要放弃了——你真的帮助了我。 (我知道这个评论在 SO 层面上是无用的,但作为一个人,我倾向于。)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-11
    相关资源
    最近更新 更多