2013-10-19 259 views
1

我試圖寫一個lua Proto來解析我們的http私有協議。但是,當media_type改爲「application/octet-stream」時,Wireshark沒有進入我的解剖器功能。當media_type設置爲「text/html」時,一切都很正常。 應用程序/八位字節流是否有特殊處理? 我在這工作了將近一天,你能幫我一下嗎? THX很多Wireshark lua解剖器無法爲media_type = application/octet-stream加載

我的Wireshark的版本是1.10.2在Mac OSX上10.8.5

這裏是我的代碼

do 
    local myproto= Proto("myprotoProtocol","myproto Protocol") 
    local f_version= ProtoField.uint32("Version","Version",base.DEC) 
    myproto.fields = {f_version} 
    local data_dis = Dissector.get("data") 
    local function myproto_dissector(tvb,pkt,root) 
      print("enter myproto_dissector, tvb.len:"..tostring(tvb:len())) 
      if tvb:len() < 17 then return false end 
      pkt.cols.protocol = "myproto" 
      local t =root:add(myproto,tvb) 
      t:add(f_version,tvb(0,2)) 
      local version = tvb(0,2).uint() 
      print("version:"..tostring(version)) 
      return true 
    end 

    function myproto.dissector(tvb,pkt,root) 
      print("enter myproto.dissector") 
      if not myproto_dissector(tvb,pkt,root) then 
        data_dis:call(tvb,pkt,root) 
      end 
    end 

    local tbl= DissectorTable.get("media_type") 
    tbl:add("application/octet-stream",myproto) 
    --tbl:add("text/html",myproto) --text/html looks fine 
    print("adding myproto into DissectorTable") 
end 

我用tshark的調試 應用程序/八位字節流

$tshark -r test.pcapng |grep application/octet-stream 
108 40.536817000 10.8.0.14 -> 10.130.142.72 HTTP 418 POST /protocol?uid=101225&uid=101225&_t=1382115502 HTTP/1.1 (application/octet-stream) 
111 40.596037000 10.130.142.72 -> 10.8.0.14 HTTP 63 HTTP/1.1 200 OK (application/octet-stream) 
120 40.657143000 10.8.0.14 -> 10.130.142.72 HTTP 445 POST /protocol?uid=101225&uid=101225&_t=1382115502 HTTP/1.1 (application/octet-stream) 
124 40.729645000 10.130.142.72 -> 10.8.0.14 HTTP 63 HTTP/1.1 200 OK (application/octet-stream) 
219 41.810493000 10.8.0.14 -> 10.130.142.72 HTTP 488 POST /protocol?uid=101225&uid=101225&_t=1382115503 HTTP/1.1 (application/octet-stream) 
226 41.919401000 10.130.142.72 -> 10.8.0.14 HTTP 63 HTTP/1.1 200 OK (application/octet-stream) 

$tshark -r test.pcapng -X lua_script:canon.lua | grep myproto 
adding myproto into DissectorTable 

for text/html

$tshark -r test.pcapng -X lua_script:canon.lua | grep myproto 
adding myproto into DissectorTable 
enter myproto.dissector 
enter myproto_dissector, tvb.len:2 
enter myproto.dissector 
enter myproto_dissector, tvb.len:6 
enter myproto.dissector 
enter myproto_dissector, tvb.len:6 

也許這可能是wireshark當media_type不在解析表中列出的錯誤。 'application/octet-stream'尚未在表中列出。 當我在Wireshark中使用Lua-> evaluate之後,解析器表顯示了我的協議,'application/octet-stream'是亂碼。

當我在tshark中使用'print(tbl:get_dissector(「application/octet-stream」))'時,它顯示「MYPROTO」。看起來是正確的。

+0

我想我發現這個問題後,我修改了源代碼「wslua_proto.c」行1722 - 評「 g_free(圖案);」。因爲sub_dissectors-> hash_table只是將模式添加爲點,而不會在「packet.c」中複製副本。 –

+0

這個錯誤似乎是從v1.8開始引入的,1.6看起來很好。 http://anonsvn.wireshark.org/viewvc/trunk-1.6/epan/wslua/wslua_proto.c?revision=39927&view=markup –

+0

在trunk,1.10和1.8版本中,模式*是*重複的(請參閱聲明在'/ *做表插入* /'註釋之後在'dissector_add_string()'中調用'g_strdup()'作爲'g_hash_table_insert()'調用的第二個參數)。 – 2014-03-09 19:14:48

回答

0

請提交一個bug到Wireshark,在bugs.wireshark.org,無論是否有您的代碼更改,但最好有一個示例捕獲文件顯示問題(即使它只有一個或兩個包沒有問題)。

(我會作出這樣的評論,但我沒有足夠的積分,這樣做顯然)

相關問題