Skip to content

Instantly share code, notes, and snippets.

@NWPlayer123
Created March 19, 2018 01:45
Show Gist options
  • Save NWPlayer123/d998d256a565c81aff4acd5731a6852a to your computer and use it in GitHub Desktop.
Save NWPlayer123/d998d256a565c81aff4acd5731a6852a to your computer and use it in GitHub Desktop.
For bruteforce decompressing files that have multiple zlib chunks
#Very slow, loads whole file into memory to try decompression
from zlib import decompress
import sys
size = 0
with open(sys.argv[1], "rb") as f:
compressed = f.read()
total_size = f.tell()
output = ""
for i in range(total_size):
try: #if it decompresses, we hit a block
test = decompress(compressed[i:])
size += len(test)
output += test #add it to the output
except:
pass
print(size)
name = sys.argv[1].split(".")
name = name[:-1] + ["d"] + [name[-1]]
with open(".".join(name), "wb") as o:
o.write(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment