Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to decompress zlib format package in dissector?

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?