Wireshark数据为ASCII

时间:2019-06-05 10:38:55

标签: lua wireshark-dissector

我正在轮询一个远程示波器,答案是“几乎”纯ASCII:

image_packet

“几乎”是因为4字节的标头80 00 00 1515是ASCII消息的长度,在这种情况下为21个字节)不允许我将有效载荷解码为ASCII列数据(既不设置为Custom/data.data也不设置为Custom/data.text):

image_column_appearance

Edit > Preferences > Protocols > Data已被设置为Show data as text

我想像在Follow TCP Stream中那样读取ASCII文本,在该文本中可以正确解码,并将无效的ASCII码更改为.

enter image description here

是否可以在不编写解剖器的情况下删除前4个字节? 我不了解Lua,也不知道如何编写解剖器:10.3. Example: Dissector written in Lua远远超出我的理解。 欢迎提供任何指向我可以轻松适应的已发布解决方案的指针。

谢谢

1 个答案:

答案 0 :(得分:1)

MikaS tutorial之后(非常容易,制作精良!),我写了这个LUA解剖器:

    yokogawa_protocol = Proto("YokogawaWT3000",  "Yokogawa WT3000 Protocol")

    message_header0 = ProtoField.int32("yokogawa_protocol.message_header0", "messageHeader0", base.DEC)
    message_header1 = ProtoField.int32("yokogawa_protocol.message_header1", "messageHeader1", base.DEC)
    message_header2 = ProtoField.int32("yokogawa_protocol.message_header2", "messageHeader2", base.DEC)
    message_length = ProtoField.int32("yokogawa_protocol.message_length", "messageLength", base.DEC)
    message_ascii  = ProtoField.string("yokogawa_protocol.message_ascii", "messageAscii", base.ASCII)

    yokogawa_protocol.fields = { message_header0, message_header1, message_header2, message_length, message_ascii }

    function yokogawa_protocol.dissector(buffer, pinfo, tree)
      length = buffer:len()
      if length == 0 then return end

      pinfo.cols.protocol = yokogawa_protocol.name

      local subtree = tree:add(yokogawa_protocol, buffer(), "Yokogawa WT3000 Protocol Data")

      subtree:add(message_header0, buffer(0,1)) -- fixed h80
      subtree:add(message_header1, buffer(1,1)) -- fixed h00
      subtree:add(message_header2, buffer(2,1)) -- fixed h00
      subtree:add(message_length, buffer(3,1))  -- ascii length
      subtree:add(message_ascii, buffer(4, length-4)) -- ascii text
    end

    local tcp_port = DissectorTable.get("tcp.port")
    tcp_port:add(10001, yokogawa_protocol)

右键单击messageAscii,然后单击"Apply as Column",让我在新列中查看每封邮件的解码值。

谢谢大家