Analyzing properties of a ZIP file

17

8

I have a ZIP file, and I want to determine how it was compressed (the specific algorithm, properties used to apply that algorithm, etc.). How can I do this?

RCIX

Posted 2010-03-15T23:54:07.727

Reputation: 5 415

Answers

16

zipinfo (from InfoZIP) will tell you a lot about a file.

Sample output from zipinfo -v (using the "verbose" option -v):

Archive:  /tmp/test.zip
There is no zipfile comment.

End-of-central-directory record:
-------------------------------

  Zip archive file size:                     22341 (0000000000005745h)
  Actual end-cent-dir record offset:         22319 (000000000000572Fh)
  Expected end-cent-dir record offset:       22319 (000000000000572Fh)
  (based on the length of the central directory and its expected offset)

  This zipfile constitutes the sole disk of a single-part archive; its
  central directory contains 1 entry.
  The central directory is 88 (0000000000000058h) bytes long,
  and its (expected) offset in bytes from the beginning of the zipfile
  is 22231 (00000000000056D7h).


Central directory entry #1:
---------------------------

  tmp/bookmarks.html

  offset of local header from start of archive:   0
                                                  (0000000000000000h) bytes
  file system or operating system of origin:      Unix
  version of encoding software:                   3.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          no
  file last modified on (DOS date/time):          2010 Feb 20 16:22:48
  file last modified on (UT extra field modtime): 2010 Feb 20 16:22:47 local
  file last modified on (UT extra field modtime): 2010 Feb 20 15:22:47 UTC
  32-bit CRC value (hex):                         3e84c75c
  compressed size:                                22155 bytes
  uncompressed size:                              76774 bytes
  length of filename:                             18 characters
  length of extra field:                          24 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             text
  Unix file attributes (100600 octal):            -rw-------
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification/access times.
  - A subfield with ID 0x7875 (Unix UID/GID (any size)) and 11 data bytes:
    01 04 e8 03 00 00 04 e8 03 00 00.

  There is no file comment.

If that is not enough, please explain which information you need.


Note that zipinfo functionality is actually part of the unzip program (the two binaries are usually identical, or links to each other). You can invoke unzip -Z to get zipinfo's functionality. So if your installation should not have a zipinfo binary, you can use unzip -Z instead.

sleske

Posted 2010-03-15T23:54:07.727

Reputation: 19 887

This looks like what i need, but InfoZip's mirrors appear to be down and only the source is available at sourceforge... – RCIX – 2010-03-16T00:21:37.830

Ok, i figured it out. I first followed their FTP instructions (with a slight modification), but then i found you can grab what you need from ftp://ftp.info-zip.org/pub/infozip/win32/ . – RCIX – 2010-03-16T04:08:29.717

Sorry, i still need help: zipinfo doesn't appear in the archive i downloaded :( – RCIX – 2010-03-16T07:40:04.377

@RCIX: Sorry, no idea where you can get Windows binaries. I use Linux, where it's part of all distributions :-). Just post a new question to ask about windows binaries. – sleske – 2010-03-16T09:46:48.637

@RCIX, @sleske: Seems zipinfo is merged into unzip. Download unz*xn-x64.exe and use unzip.exe -Zv FILENAME.zip – Ivan Chau – 2016-08-19T02:53:37.683

@IvanChau: Yes, apparently zipinfo has always been part of unzip. Thanks for pointing this out; I edited my answer. – sleske – 2016-08-19T08:20:59.013

What's the zipinfo command to get the level of detail that you show in your answer?. – Jaime Hablutzel – 2019-04-20T14:43:46.493

@JaimeHablutzel: I used option -v. Answer edited, thanks for pointing this out. – sleske – 2019-04-24T21:58:02.543

11

The zipinfo command can actually be run on Windows by using the unzip -Z command, as stated in the info-zip archive's documentation.

Make a "zipinfo.bat" batch file with this command inside:

unzip.exe -Zsvh %1

and you have zipinfo running on Windows.

fred78800

Posted 2010-03-15T23:54:07.727

Reputation: 111

1This command works on CentOS/Linux too, obviously after removing .exe – Aditya Kumar Pandey – 2013-06-26T12:44:59.870