kubleeka
kubleeka

Reputation: 11

How can I create a zip file that would decompress into an enormous file?

I want to create a .zip file that would, theoretically, decompress into a .txt file containing a terabyte of '7's. I obviously can't create the file and compress it myself without a terabyte of memory, so I'm looking for a way to create a .zip file of only a few '7's and modify it somehow.

I've been studying the zip standard and the hex dumps of some small, zipped files, but I haven't been able to pick out a pattern.

Upvotes: 0

Views: 26

Answers (1)

Mark Adler
Mark Adler

Reputation: 112502

Answering the title question, one way is to overlap zip entries. See David Fifield's zip bomb.

I obviously can't create the file and compress it myself without a terabyte of memory

You can certainly create a zip file with a giant entry, without having to have a file on your system with that entry, or need a large amount of memory. zip can take input from stdin:

    head -c 1099511627776 /dev/zero | tr \\0 7 | zip big.zip -

You'll need to be very patient, and have room for a gigabyte zip file.

Upvotes: 0

Related Questions