Artificial truth

The more you see, the less you believe.

[archives] [latest] | [homepage] | [atom/rss/twitter]

Decompressing a multi-stream zlib archive in Python
Tue 16 June 2020 — download

Today while reversing a custom PyInstaller bundle, I needed to decompress a multi-stream zlib compressed archive, and since I spent way too much time trying to understand how I was supposed to do it, here is the resulting snippet in Python:

import sys
import zlib

with open(sys.argv[1], 'rb') as f:
    stream = f.read()
    while stream:
        dco = zlib.decompressobj()
        dec = dco.decompress(stream)
        print('[+] found stream with len %d' % len(dec)))
        stream = dco.unused_data