I'm coding Wireshark Dissector lua script now.
How to convert userdata to hex string?
I want to get output like this 0102030405060708000a0b0c0d0e0f10
I can convert hex string using tostring.
But it omits long data.
Output Image
How to convert userdata to hex string without omit long data?
proto = Proto("Test", "My Test Protocol")
function proto.dissector(buffer, pinfo, tree)
print(tostring(buffer()))
-- "userdata"
-- print(type(buffer()))
end
tcp_table = DissectorTable.get("tcp.port")
tcp_table:add(1234, proto)
Environment
- Wireshark 3.2.1
I'm not very familiar with Wireshark, but from a quick look into the manual I get that buffer is a Tvb
and
buffer()is equivalent tobuffer:range()which returns a TvbRangeThere is a Tvb:__tostring function which claims to
Printing a TvbRange is truncated to 24 bytes.
I'd try to get a ByteArray from your Tvb and obtain the hex string of that ByteArray using
So your code might look something like