It is also possible to decompress it using standard shell-script + gzip, if you don't have, or want to use openssl or other tools.
The trick is to prepend the gzip magic number and compress method to the actual data from zlib.compress:
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" |cat - /tmp/data |gzip -dc >/tmp/out
Edits:
@d0sboots commented: For RAW Deflate data, you need to add 2 more null bytes:
→ "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00"
This Q on SO gives more information about this approach. An answer there suggests that there is also an 8 byte footer.
Users @Vitali-Kushner and @mark-bessey reported success even with truncated files, so a gzip footer does not seem strictly required.
@tobias-kienzler suggested this function for the bashrc:
zlibd() (printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - "$@" | gzip -dc)
It is also possible to decompress it using standard shell-script + gzip, if you don't have, or want to use openssl or other tools.
The trick is to prepend the gzip magic number and compress method to the actual data from zlib.compress:
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" |cat - /tmp/data |gzip -dc >/tmp/out
Edits:
@d0sboots commented: For RAW Deflate data, you need to add 2 more null bytes:
→ "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00"
This Q on SO gives more information about this approach. An answer there suggests that there is also an 8 byte footer.
Users @Vitali-Kushner and @mark-bessey reported success even with truncated files, so a gzip footer does not seem strictly required.
@tobias-kienzler suggested this function for the bashrc:
zlibd() (printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - "$@" | gzip -dc)
zlib-flate -uncompress < IN_FILE > OUT_FILE
I tried this and it worked for me.
zlib-flate can be found in package qpdf (in Debian Squeeze, Fedora 23, and brew on MacOS according to comments in other answers)
(Thanks to user @tino who provided this as a comment below the OpenSSL answer. Made into propper answer for easy access.)
Building openssl with zlib support (Kali Linux)
Zlib uncompression for an noob
Looks like zlib compressed data, here's more info how to deflate it: https://unix.stackexchange.com/questions/22834/how-to-uncompress-zlib-data-in-unix
More on reddit.comlinux - How to run zlib from terminal on Ubuntu? - Unix & Linux Stack Exchange
git - Uncompressing zlib file in command line - Stack Overflow
Hey everyone,
I have a file that's made up from zlib compressed data. I want to use openssl zlib -d to decompress the file but my openssl doesn't "support" zlib.
I found a website which explains how you can (re)build openssl with zlib enabled.
-
./config zlib in the openssl folder -> this will add ZLIB to the DEFINES
-
make (-DZLIB flag will be shown during the process)
-
make install
After walking through those steps zlib will, however, not be working. At first it didn't recognize zlib at all. Right now I get the following error when I try to run "openssl zlib".
openssl: relocation error: openssl: symbol BIO_f_zlib version OPENSSL_1_1_0 not defined in file libcrypto.so.1.1 with link time reference
Now, I'm kind of new to Linux so I'm not exactly sure where to go from here. If anyone could help me out, that'd be greatly appreciated!
i was playing ctf challenges and i stuck in this point can someone explain to me(this compression) and how i can uncompress this file .
$ file out.zlib out.zlib: zlib compressed data
Something like the following will print the raw content, including the "$type $length\0" header:
perl -MCompress::Zlib -e 'undef $/; print uncompress(<>)' \
< .git/objects/27/de0a1dd5a89a94990618632967a1c86a82d577
You can do this with the OpenSSL command line tool:
openssl zlib -d < $IN > $OUT
Unfortunately, at least on Ubuntu, the zlib subcommand is disabled in the default build configuration (--no-zlib --no-zlib-dynamic), so you would need to compile openssl from source to use it. But it is enabled by default on Arch, for example.
Edit: Seems like the zlib command is no longer supported on Arch either. This answer might not be useful anymore :(
You should install the development support files for zlib, try:
sudo apt-get install libz-dev
Other package names: zlib1g-dev.
If you've already zlib library, make sure you're compiling your code sources with -lz. See: missing zlib.h in ubuntu.
Install zlib from it's source, solve my similar error. Download last version from this then:
configure
make -j4
make install