小编And*_*ies的帖子

在Lua Wireshark解剖器中重新组装数据包

我正在尝试为基于bplists的Safari远程调试协议编写一个解剖器并且已经相当成功(当前代码在这里:https://github.com/andydavies/bplist-dissector).

虽然我在重新组装数据包时遇到了困难.

通常,协议发送一个包含4个字节的数据包,其中包含下一个数据包的长度,然后是包含bplist的数据包.

不幸的是,来自iOS模拟器的一些数据包不符合此约定,并且四个字节或者标记在bplist数据包的前面,或者标记在前一个bplist数据包的末尾,或者数据是多个bplists.

我试着用重组他们desegment_lendesegment_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 …
Run Code Online (Sandbox Code Playgroud)

lua wireshark wireshark-dissector

7
推荐指数
1
解决办法
4573
查看次数

标签 统计

lua ×1

wireshark ×1

wireshark-dissector ×1