如何通过侦听器获取 TCP 流编号?
How to get the TCP stream number with a listener?
我正在分析一个非常大的 PCAP,其中包含许多 HTTP 事务,我对其中一些感兴趣。我将 tshark
与 Lua 脚本一起使用,本质上是查询与过滤器匹配的所有数据包。
tshark -X lua_script:filter.lua -r some.pcap -q
到目前为止一切顺利。但是,我正在专门寻找数据包的 TCP 流编号的值,它在 Wireshark 中以名称 tcp.stream
出现。谁能说出我需要对 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
成为常量并创建一个函数 returns 当前数据包的 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
我正在分析一个非常大的 PCAP,其中包含许多 HTTP 事务,我对其中一些感兴趣。我将 tshark
与 Lua 脚本一起使用,本质上是查询与过滤器匹配的所有数据包。
tshark -X lua_script:filter.lua -r some.pcap -q
到目前为止一切顺利。但是,我正在专门寻找数据包的 TCP 流编号的值,它在 Wireshark 中以名称 tcp.stream
出现。谁能说出我需要对 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
.
local tcp_stream = Field.new("tcp.stream").value
Field
的值是当前数据包的值。您不需要每次都创建一个新的 Field
。这允许您使 Field
成为常量并创建一个函数 returns 当前数据包的 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