Mar*_*wie 4 lua wireshark wireshark-dissector
我分析了一个非常大的PCAP,它持有许多HTTP事务,其中一些让我感兴趣.我使用tsharkLua脚本主要是查询匹配过滤器的所有数据包.
tshark -X lua_script:filter.lua -r some.pcap -q
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.但是,我正在寻找一个数据包的TCP流号的值,该值通过tcp.streamWireshark中的名称.任何人都可以说我需要进行哪些更改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
Run Code Online (Sandbox Code Playgroud)
什么文档pinfo,tvb并且ip 是是unforthcoming.
您可以通过a访问TCP流编号Field.
local tcp_stream = Field.new("tcp.stream").value
Run Code Online (Sandbox Code Playgroud)
该值Field是当前数据包的值.您不需要Field每次都创建新的.这允许您使Fielda成为常量并创建一个返回当前数据包的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
Run Code Online (Sandbox Code Playgroud)
https://www.wireshark.org/docs/wsdg_html_chunked/lua_module_Field.html#lua_class_Field