I want to to decompress raw data from a file in an exotic format, but I know that the compression method is the same that is used in a ZIP file (PKZIP).
In the file the PK\03\04 signature is missing. After that the data more or less fits the PKZIP header specs:
https://docs.fileformat.com/compression/zip/
Then the raw compressed data, and after that the End Record that looks damaged in a similar way. After adding the signature and valid file name characters and saving the buffer to a file, I was able to decompress it with 7zip. It showed an error dialog, but produced an uncompressed file. The resulting file contained the expected data.
I know that there is always one compressed file and the compression method is fixed. The file name is not important, so I guess it should be possible to process only the compressed data bytes after the header, ignoring the End Record as well.
Which Python package provides such functionality?
I want to ignore the ZIP headers and pass only the compressed data buffer to some function in Python (possibly specifying the compression method and some flags), and get the uncompressed data buffer back. No CRC check, no file names.
If the compression method is 8, then you can use Python's zlib module, passing wbits=-15
to either zlib.decompress()
or zlib.decompressobj()
.