如何访问Wireshark Lua解剖器中数据包的TLS版本/校验和校验和校验



我是Wireshark及其LUA API的新手。我需要写一个可以在端口443上捕获数据包的解剖器,修改一些内容,然后将其发送到目的地。我在这里找到了一个根据我的需要修改的脚本:

-- create myproto protocol and its fields
p_myproto = Proto ("myproto","My Protocol")
local f_command = ProtoField.uint16("myproto.command", "Command", base.HEX)
local f_data = ProtoField.string("myproto.data", "Data", FT_STRING)
 
p_myproto.fields = {f_command}
 
-- myproto dissector function
function p_myproto.dissector (buf, pkt, root)
    print ('packet captured')
  -- validate packet length is adequate, otherwise quit
  if buf:len() == 0 then return end
  pkt.cols.protocol = p_myproto.name
  local colss = pkt.cols
--pkt.cols.info:append(" " .. tostring(pkt.dst).." -> "..tostring(pkt.src))
print ("" .. tostring(pkt.dst))
print ("" .. tostring(pkt.src_port))
print ("" .. tostring(pkt.dst_port))
end
 
-- Initialization routine
function p_myproto.init()
end
 
-- register a chained dissector for port 8002
local tcp_dissector_table = DissectorTable.get("tcp.port")
dissector = tcp_dissector_table:get_dissector(443)
  -- you can call dissector from function p_myproto.dissector above
  -- so that the previous dissector gets called
tcp_dissector_table:add(443, p_myproto)

我可以访问DST,SRC,DST_PORT等字段等。整个列表可在此处找到。但是我在任何地方都找不到有关如何访问/修改数据包,选定的密码套件等校验和的任何参考,我知道它们存在于运输层上,但是我找不到任何可以允许我访问/修改的文档这些值。

我在做什么错?在这方面的任何帮助将不胜感激!

谢谢!

您可以使用A field extractor 访问您引用了,但在Wireshark显示过滤器参考页面上。

例如,如果您想要TCP校验和可以使用:

fe_tcp_checksum = Field.new("tcp.checksum")
...
function p_myproto.dissector (buf, pkt, root)
    ...
    f_tcp_checksum = fe_tcp_checksum().value
    ...
end

Wireshark Wiki提供了更多的LUA/示例。

最新更新