我正在分析一个非常大的 PCAP,其中包含许多 HTTP 事务,其中一些是我感兴趣的。我正在使用 tshark
使用 Lua 脚本来查询与过滤器匹配的所有数据包。
tshark -X lua_script:filter.lua -r some.pcap -q
到现在为止还挺好。但是,我专门寻找名称为
tcp.stream
的数据包的 TCP 流号的值。在 Wireshark 里面。谁能说出我需要对 filter.lua
进行哪些更改?打印那个?-- filter.lua
do
local function init_listener()
local tap = Listener.new("http","http contains someKeyValue && tcp.port eq 1234")
function tap.reset()
end
function tap.packet(pinfo,tvb,ip)
print("Found my packet ... now what?")
end
function tap.draw()
end
end
init_listener()
end
关于
pinfo
的文档, tvb
和 ip
是即将到来的。
最佳答案
您可以通过 Field
访问 TCP 流号.
local tcp_stream = Field.new("tcp.stream").value
Field
的值是当前数据包的值。您无需创建新的 Field
每一次。这允许您制作 Field
一个常量并创建一个返回当前数据包的 TCP 流号的函数。也可以调用Field
获取 FieldInfo
的值可能包含其他有用信息的值。你想要
filter.lua
看起来像:-- filter.lua
do
local function init_listener()
local get_tcp_stream = Field.new("tcp.stream")
local tap = Listener.new("http","http contains someKeyValue && tcp.port eq 1234")
function tap.reset()
end
function tap.packet(pinfo,tvb,ip)
print(tostring(get_tcp_stream()))
end
function tap.draw()
end
end
init_listener()
end
https://www.wireshark.org/docs/wsdg_html_chunked/lua_module_Field.html#lua_class_Field
关于lua - 如何通过监听器获取 TCP 流号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42695944/