7

bplistsに基づいており、かなり成功しているSafariリモートデバッグプロトコル用のディセクタを作成しようとしています(現在のコードはhttps://github.com/andydavies/bplist-dissectorにあります)。

しかし、私はパケットを再組み立てするのに苦労しています。

通常、プロトコルは次のパケットの長さを含む4バイトのパケットを送信し、次にbplistを含むパケットを送信します。

残念ながら、iOSシミュレータからの一部のパケットはこの規則に従わず、4バイトがbplistパケットの先頭、または前のbplistパケットの末尾にタグ付けされているか、データが複数のbplistです。

次のように使用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バイトに強制的に分析することですが、それでも機能しません。4バイトのパケットの後にxバイトのパケットが続きます。

前面の余分な4バイトを管理する他の方法を考えることもできますが、プロトコルにはパケットの終わりから32バイトのルックアップテーブルが含まれているため、パケットをbplistに正確に接続する方法が必要です。

キャップの例を次に示します。http : //www.cloudshark.org/captures/2a826ee6045b#338は、bplistサイズがデータの先頭にあり、データに複数のplistがあるパケットの例です。

私はこれを正しく行っていますか(SOに関する他の質問、および私がそうであるように見えるWebの周りの例を見て)、またはより良い方法がありますか?

4

1 に答える 1

5

TCP Dissector packet-tcp.cには tcp_dissect_pdus() があります。

TCP ストリーム内の PDU を分析するためのループ。では、PDU は、PDU の長さを決定するのに十分な情報を含む固定長のデータ チャンクと、その後に続く PDU の残りの部分で構成されていると想定しています。

lua apiにはそのような機能はありませんが、それを行う方法の良い例です。

もう1つの例。私はこれを1年前にテストに使用しました:

local slicer = Proto("slicer","Slicer")
function slicer.dissector(tvb, pinfo, tree)
    local offset = pinfo.desegment_offset or 0

    local len = get_len() -- for tests i used a constant, but can be taken from tvb

    while true do
        local nxtpdu = offset + len

        if nxtpdu > tvb:len() then
            pinfo.desegment_len = nxtpdu - tvb:len()
            pinfo.desegment_offset = offset
            return
        end

        tree:add(slicer, tvb(offset, len))

        offset = nxtpdu

        if nxtpdu == tvb:len() then
             return
        end
    end
end
local tcp_table = DissectorTable.get("tcp.port")
tcp_table:add(2506, slicer)
于 2013-01-18T11:44:17.423 に答える