This is a static, read-only archive of Wireshark Q&A. Older questions and answers from October 2017 and earlier can be found at osqa-ask.wireshark.org.
This question is closed: the question is answered, right answer was accepted on Sep 13 '25.
0

How to decompress zlib format package in dissector?

asked Sep 13 '25

I wrote a dissector. I need to decompress zlib format package when analyzing data. I have tried:

  1. local zlib = require("zlib") - got an error saying the package was not found;
  2. local zlib = require("zlib1") - got an error saying it was not a valid dll.

Currently, I am using a solution of calling Python code, but this is very inefficient. Some of my code is as follows:

local compressed_data = buffer(40, data_length - 36)  
local compressed_hex = tostring(compressed_data:bytes():tohex())  
local handle = io.popen("python -c \"import zlib,binascii,sys;print(zlib.decompress(binascii.unhexlify(sys.argv[1])).decode('utf-8'))\" " .. compressed_hex, "r")  
local content = handle:read("*a")  
handle:close()

Could you please tell me how to solve this problem?

1 Answer

1

answered Sep 13 '25

If running a newer/current version of Wireshark, have you looked at:

WSDG: 13.6.3. TvbRange

13.6.3.28. tvbrange:uncompress_zlib(name)

Given a TvbRange containing zlib compressed data, decompresses the data and returns a new TvbRange containing the uncompressed data. Since: 4.3.0

Comments

Thank you very much for your solution. I have solved this problem by using tvbrange:uncompress_zlib(name).

function p_xxxx_proto.dissector(tvb, pinfo, tree)

local subtree = tree:add(p_xxxx_proto, tvb:range(offset), "xxxxxxxxxx")

local compressed_data = tvb:range(40, data_length - 36)

subtree:add(f_data, compressed_data:uncompress_zlib(compressed_data:string()))

User 50223 ( Sep 13 '25 )
cc-by-sa Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.