How to create minimum size (empty) zip file, which has 22B?
Solution 1
Here you go:
50 4b 05 06 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00
That has the MD5 signature you provided.
If you have Info-ZIP's zip, you can create it thusly:
zip empty.zip anyfile
zip -d empty.zip anyfile
That adds "anyfile" to a new zip file, and then deletes it from the zip file, leaving it empty.
Solution 2
An easier-to-use version for copying-and-pasting into the shell:
echo UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA== | base64 -d > empty.zip
This just prints the base64
'd version of the empty zip file (created by creating a zip file with a single file then deleting that single file from the zip file), and reverse the encoding with base64 -d
and writes the output to empty.zip
.
If the version of base64
that ships with your machine doesn't use the same syntax as above, here's a more-portable but less-terse alternative:
echo UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA== | openssl enc -d -base64 > empty.zip
Solution 3
With Info-Zip (standard zip/unzip installation on Ubuntu 20.04), you will have to use the -i "*"
option. If it's not present, zip will complain and exit with error code 1 on creation. Counter-intuitively, its behaviour changes with -i "*"
.
mkdir /tmp/mytest
cd /tmp/mytest
zip -r mytest.zip . -i "*"
mytest.zip
will be the empty zip file you desire.
Solution 4
with this .bat
script you can create empty.zip
file under windows:
@echo off
del /q /f empty.zip >nul 2>nul
certutil -decode "%~f0" empty.zip
-----BEGIN CERTIFICATE-----
UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA==
-----END CERTIFICATE-----
Related videos on Youtube
mirekbarton
Updated on July 13, 2022Comments
-
mirekbarton almost 2 years
I´m trying to solve some security problem with file, whose MD5 hash is 76cdb2bad9582d23c1f6f4d868218d6c.
I don't have that file, but based on internet MD5 searches, I think, it is minimum size zip file. I found one example and its content is exactly same like minimum size zip file.
Is it possible to create such minimum size zip file (22 B) with Linux (or Windows) command?
BTW: Recently, I solved similar task with gzip file:
gzip -n EmptyFileName
-
Yona Appletree over 8 yearsArguably, directly echoing the bytes to a file is a simpler method of creation:
echo -n '\x50\x4b\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' > empty.zip
-
Mark Adler about 6 yearsMatched for me. Might depend on your shell.
-
Mark Adler about 6 yearsI had to use
-D
instead of-d
on my system. You can useecho -n
to avoid the newline, however you don't need to. Just useecho
.base64
doesn't care about the newline. -
harry about 6 years@MarkAdler Thanks.
echo -n
isn't portable, but I completely forgot thatbase64
doesn't care about line endings. I'm not sure what's the most portable way of doing base64 decode, perhaps viaopenssl
but that's not available oob on macOS any longer, I think. -
Mark Adler about 6 yearsI have the latest macOS, and the openssl command from LibreSSL 2.2.7 is there. It also has base64.
-
Tom Cornebize almost 6 years@MahmoudAl-Qudsi It works with zsh. With bash or sh, you have to add the
-e
option:echo -ne '\x50\x4b\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' > empty.zip
-
harry almost 6 yearsThanks, @MarkAdler; added an openssl-based variant to the answer.