Zip Bombs
Last updated
Last updated
According to Wikipedia:
A zip bomb, also known as a decompression bomb or zip of death, is a malicious archive file designed to crash or render useless the program or system reading it.
...
A zip bomb allows a program to function normally, but, instead of hijacking the program's operation, creates an archive that requires an excessive amount of time, disk space, or memory to unpack.
As stated, a zip bomb is essentially a zip file that's tiny when compressed, but when uncompressed, it kills the system by inflating to consume a massive amount of memory.
It's important to note that a zip bomb may just be a simple zip file, but it can also be a straight-up program packed with said zip file payload. It can also be a fork bomb since that one eats up processor memory. Usually, with malware, the sky's the limit, be creative and design yours according to the target and objective.
Let's make the payload in bash this time. We'll create the "unpacking program" using a compiled language, like go
or rust
. We could also use C/C++ but honestly, it'll be too lengthy at that point, and too... complicated (also I'm lazy, but you're welcome to try and implement one and make a PR to include examples here )
If you just wanna use a pre-existing payload (which I recommend), you can just download one here.
Here's a (quite shitty) script to generate a payload:
Once we run this script with something like:
When this is uncompressed initially, it'll be something like 4 GB
in size. Let's now make a program to unzip this stuff a number of times (heck, you can also make it go on forever). I'll use golang
to create the unzipping program:
Woah! That's one big program, yeah, but it's really simple.
The unzipFile
function does exactly what its name suggests. Takes in a zip file and unzips it, while placing its contents into a specified dst
location.
The main function just handles the continuous unzipping of the payload. So here:
The last command will decompress the payload 2000 times, which, in this case, will consume a whopping 10 TB. Now comes the question... How do I transport this stuff over to the target in a single executable. To do this, you can use the traditional "packers" route, OR something like this:
Generate a suitable payload (I'll just use the one we generated before)
Next, we generate a simple program packing this stuff into a byte array using go-bindata
:
Since this file will also be included in the main
package, we can directly access the functions inside it, so we'll call the payload_500ZipBytes
function to get the byte array for our payload:
Now, we add a function call to placePayload
in the main
function before we start iterating and unzipping; do some cleaning up and build the final executable...
Let's run a test (also change the iterations
variable to 2):
Well, there it is folks, a simple zip bomb!
We can also run a simple test on virustotal
to check where our malware stands in terms of detection:
Well, well, that's quite something! It's passing with flying colors on the Linux detection, and as for the Windows build, a score of 4/70 is quite good! Usually, this may not be the same if we use packers (which, typically, you'll wanna do).
If you wanna know how to pack stuff using packers, check the section on Malware Packers
Here's the GitHub repository that contains all of the above code:
PS: I'll YET AGAIN be making one of those over-engineered packages for this, so look forward to it! I'll link it here as soon as it's done :)