ZipBomb | A simple implementation of ZipBomb in Python | Compression library
kandi X-RAY | ZipBomb Summary
kandi X-RAY | ZipBomb Summary
This is for the people who watch Silicon Valley. In Season 3 Episode 7, Gilfoyle sends a sort of recursive program to Gavin Belson’s laptop and cellphone which forces him to shut down the power at Hooli. Watch here. Such a program is called a zip bomb. What it is basically is a huge file with dummy data compressed to many levels to generate a very small compressed file. For example in a test run, this script of mine generates a compressed file of size 30.58 KB which when decompressed is actually 10000000000 GB. This is done to drain out a computer’s memory until it shuts down. Read More on Wikipedia. This is a small script written in Python which generates such a zip bomb.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Creates a zip file with n_copies .
- Generate a dummy file .
- Compress infile to outfile .
- Returns the size of the file
- Get filename without extension .
- Get the extension from a name .
ZipBomb Key Features
ZipBomb Examples and Code Snippets
Community Discussions
Trending Discussions on ZipBomb
QUESTION
I am using this function call, because when I read a trusted file, It results in zipbomb error.
ZipSecureFile.setMinInflateRatio(double ratio)
...ANSWER
Answered 2017-Oct-19 at 08:59A zip bomb detection works the following way:
While uncompressing it checks the ratio compressedBytes/uncompressedBytes
and if this falls below a special amount (MinInflateRatio
), then a bomb was detected.
So if the ratio compressedBytes/uncompressedBytes
is 0.01d
for example, then that means that the compressed file is 100 times smaller than the uncompressed one whithout information lost. In other words, the compressed file stores the same information in only 1% of the file size, the uncompressed one needs. This is really unlikely using real life data.
To show how unlikely it is we could take a look (in a popular scientific manner) on how compression works:
Let's have the string
"This is a test for compressing having long count of characters which always occurs the same sequence."
This needs 101 bytes. Let's say this string occurs 100,000 times in the file. Then uncompressed it would need 10,100,000 bytes. A compression algorithm would give that string a ID and would storing the string only once mapping it to that ID and would storing 100,000 times the ID where the string occurs in the file. That would need 101 bytes + 1 byte (ID) + 100,000 bytes (IDs) = 100,102 bytes. And this would have a ratio compressedBytes/uncompressedBytes
of 0.009911089d
for example.
So if we set the MinInflateRatio
to lower than 0.01d
, then we accept such unlikely data compression rates.
Also we can see, that the ratio compressedBytes/uncompressedBytes
can only be 0
if compressedBytes
is 0. But this would mean that there are no bytes to uncompress. So a MinInflateRatio
of 0.0d
can never be reached nor be undershot. So with a MinInflateRatio
of 0.0d
all possible ratios will be accepted.
Of course a MinInflateRatio
of -1.0d
also can never be reached nor be undershot. So using this also all possible ratios will be accepted.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ZipBomb
You can use ZipBomb like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page