我想爲基於bplists的Safari遠程調試協議編寫解剖器,並且已經相當成功(當前代碼位於:https://github.com/andydavies/bplist-dissector)。在Lua Wireshark解剖器中重組數據包
雖然我遇到了難以重新組裝的數據包。
通常,協議從iOS模擬器發送一個數據包與包含下一個數據包的長度,然後用在bplist的分組的4個字節。
不幸的是一些數據包不遵循此慣例和四個字節要麼標記在bplist數據包的前面,要麼標記到前一個bplist數據包的末尾,或者數據是多個bplists。
我試着用desegment_len
和desegment_offset
如下重組它們:
function p_bplist.dissector(buf, pkt, root)
-- length of data packet
local dataPacketLength = tonumber(buf(0, 4):uint())
local desiredPacketLength = dataPacketLength + 4
-- if not enough data indicate how much more we need
if desiredPacketLen > buf:len() then
pkt.desegment_len = dataPacketLength
pkt.desegment_offset = 0
return
end
-- have more than needed so set offset for next dissection
if buf:len() > desiredPacketLength then
pkt.desegment_len = DESEGMENT_ONE_MORE_SEGMENT
pkt.desegment_offset = desiredPacketLength
end
-- copy data needed
buffer = buf:range(4, dataPacketLen)
...
什麼我試圖在這裏做的總是迫使大小字節是前四個字節的數據包被解剖但它不起作用,我仍然看到一個4字節的數據包,然後是一個x字節數據包。
我可以考慮管理前面額外四個字節的其他方法,但協議包含一個查找表,從數據包的末尾開始有32個字節,因此需要將數據包精確拼接成bplists。
下面是一個示例cap:http://www.cloudshark.org/captures/2a826ee6045b#338是一個數據包示例,其中bplist大小位於數據的起始位置,數據中有多個plist。
我是否正確地做了這項工作(看看其他問題,以及網絡上的示例,我似乎是這樣),還是有更好的方法?
感謝這幫助我進一步瞭解,不知何故,我沒有解碼所有的數據包,所以需要再看看! –
雖然這是一篇很老的文章,但對於未來,我認爲值得說明的是,從Wireshark 1.99.2開始,**是''tcp_dissect_pdus'的一個Lua API。看看這裏:[wireshark.org/docs](https://www.wireshark.org/docs/wsdg_html_chunked/lua_module_Proto.html#lua_fn_dissect_tcp_pdus_tvb__tree__size__func__func___desegment__) –