1

I was messing with Zip bombs today. I ran my python program to generate a 30TB zip bomb, and it threw the normal warning:

Warning: Using nested mode. The output may not be accurate.

This got me thinking: How would I check the full size of the zip file (Every file accounted for in the summary)? Are there any specific tools to do this?

EDIT: The answers to the suggested question do not apply. It returned a much smaller value, only like 60kb. It doesn't seem like it is recursive, and I cant find how to make it recursive.

5
  • 1
    Related: How to know how much space an uncompressed zip will take. also maybe this
    – thanasisp
    Dec 2, 2020 at 15:17
  • @eris-the-guest Try this command : ls -lh zipfilename.zip or for all zip files ls -lh *.zip Dec 2, 2020 at 15:27
  • Did not work. All it returned was 8.1 KB. Dec 2, 2020 at 15:38
  • 1
    @codeholic24 OP wants the size of the extracted content, not of the compressed content
    – Panki
    Dec 2, 2020 at 16:52
  • Having read this, I'd guess it's impossible to tell what size it's going to be without actually extracting.
    – Panki
    Dec 2, 2020 at 16:55

1 Answer 1

1

You can't do this for the general case, without decompressing some or almost all of the nested components. If you do it manually or try to make a script, consider doing it safely, under disk limitations.

For example, we create a big file, we zip it. And we zip it again, together with a small file.

yes 1 | head -c1G > file1
zip inner.zip file1
touch file2
zip outer.zip inner.zip file2

Now you can see, without decompressing anything, the size for the contents of the outer zip, which is small.

$ unzip -v outer.zip 
Archive:  outer.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
 1042294  Stored  1042294   0% 2020-12-04 10:13 7093703f  inner.zip
       0  Stored        0   0% 2020-12-04 10:13 00000000  file2
--------          -------  ---                            -------
 1042294          1042294   0%                            2 files

After you unzip it, you can see the size for the contents of any nested zips files.

$ unzip outer.zip 
$ unzip -v inner.zip 
Archive:  inner.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
1073741824  Defl:N  1042134 100% 2020-12-04 10:12 5aa3a8cc  file1
--------          -------  ---                            -------
1073741824          1042134 100%                            1 file

And this stack can have many levels of nesting, many different compressed files. So, if you are curious to calculate the total size, you should safely repeat these steps until the last level, or abort the process if you see a size that couldn't be handled.

1
  • 1
    Welp, the zip bomb would kill the hard drive of the IDE I use to make them. Oh well. Dec 4, 2020 at 13:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .