0

How can I make a v1.0 zip archive, so that when ran against file returns

Zip archive data, at least v1.0 to extract

When I create a zip file with the zip command line utility or Xarchiver, file returns

Zip archive data, at least v2.0 to extract
4

You can create version 1 ZIP archives using Info-Zip’s zip 1.1, which is still available (download zip11.zip). You’ll need to build it from source (make sysv on a Linux system); then you’ll be able to use the newly-built zip to create old-format archives:

$ ./zip -9 test.zip zip.c
adding zip.c (imploded 70%)
$ file test.zip
test.zip: Zip archive data, at least v1.0 to extract
$ unzip -v test.zip
Archive:  test.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
   25825  Implode    7749  70% 10-21-1991 13:33 e1f47bfc  zip.c
--------          -------  ---                            -------
   25825             7749  70%                            1 file

This uses the “implode” or “shrink” algorithms for compression (it uses whichever is better with any given file), rather than the “deflate” algorithm used in version 2 of the format.

1

It seems that the v2.0 zip utility was the first to support compression. Zip archives that require 'at least v1.0 to extract' can be created by passing -0 (no compression) to the zip utility.

-1

You can directly modify the magic byte of the zip file that identifies it as a v2.0 zip file:

$ file foo.zip
foo.zip: Zip archive data, at least v2.0 to extract
$ printf '\x0a' | dd of=foo.zip bs=1 seek=4 count=1 conv=notrunc
1+0 records in
1+0 records out
1 byte copied, 9.7214e-05 s, 10.3 kB/s
$ file foo.zip
foo.zip: Zip archive data, at least v1.0 to extract
$ 

I found the byte's value (0x0a) and location (4th byte) to change by looking up the source for file:

$ apt-get source file
$ grep -R 'at least v1.0'
file-5.30/magic/Magdir/archive:>>>4     byte            0x0a            \b, at least v1.0 to extract

You might corrupt your zip file, but file will report what you want.

  • That's clearly not a solution, because it will still need zip v2.0 or greater to extract files... – dirkt Sep 27 '18 at 7:08
  • @dirkt but OP never asked to be able to extract the files. – drewbenn Sep 27 '18 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.