ZIPDETAILS(1p)
okay bestie listen UP π this is ZIPDETAILS(1p) from the User Contributed Perl Documentation, and it's literally the tool that shows you what's actually inside a zip file. no cap. and this is part 1 of a long one, so buckle in π
β¨ NAME β¨
zipdetails β display the internal structure of zip files π¦
πΈ SYNOPSIS πΈ
zipdetails [options] zipfile.zip
π DESCRIPTION π
so this program makes a detailed report on the internal structure of zip files. for every single item of metadata inside a zip file, it spits out:
- the offset into the zip file where that item lives.
- a textual representation of the item.
- an optional hex dump of the item.
β οΈ real talk: this program assumes you already understand how zip files are built internally. you should have a copy of the zip file definition, APPNOTE.TXT <https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT>, open in another tab to actually understand what it's telling you. iykyk.
π Default Behaviour π
by default the program expects you to hand it a well-formed zip file. it navigates the zip file by first parsing the zip "Central Directory" at the end of the file. if the "Central Directory" is found, it then walks sequentially through the zip records starting at the beginning of the file. (for other ways to process, go peep "Advanced Analysis".)
if the program finds any structural or portability issues with the zip file, it prints a message right at the point it finds the issue and/or in a summary at the end of the output report. and like β even though the set of issues it can detect is exhaustive, do not assume this program can find all the possible issues in a zip file. there are likely edge conditions that still need to be addressed. π
if you have suggestions for use-cases where this could be enhanced, please consider creating an enhancement request (see "SUPPORT"). π«Ά
π Date & Time fields π
date/time fields found in zip files are displayed in local time. use the --utc option to display these fields in Coordinated Universal Time (UTC).
π Filenames & Comments π
filenames and comments are decoded/encoded using the default system encoding of the host running zipdetails. when the system encoding cannot be determined, cp437 will be used.
the exceptions are:
- when the "Language Encoding Flag" is set in the zip file, the filename/comment fields are assumed to be encoded in UTF-8.
- the definition for the metadata field implies UTF-8 charset encoding.
see "Filename Encoding Issues" and "Filename & Comment Encoding Options" for ways to control the encoding of filename/comment fields. β¨
π OPTIONS π
π General Options π
-h,--helpβ display help.--redactβ obscure filenames and payload data in the output. super handy for the use case where the zip file contains sensitive data that cannot be shared. π--scanβ pessimistically scan the zip file looking for possible zip records. can be error-prone. for very large zip files this option is slow. consider using the--walkoption first. see "Advanced Analysis Options".--utcβ by default, date/time fields are displayed in local time. use this option to display them in Coordinated Universal Time (UTC).-vβ enable Verbose mode. see "Verbose Output".--versionβ display version number of the program and exit.--walkβ optimistically walk the zip file looking for possible zip records. see "Advanced Analysis Options".
π Filename & Comment Encoding Options π
see "Filename Encoding Issues".
--encoding nameβ use encoding name when reading filenames/comments from the zip file. when this option is not specified, the default system encoding is used.--no-encodingβ disable all filename & comment encoding/decoding. filenames/comments are processed as byte streams. this option is not enabled by default.--output-encoding nameβ use encoding name when writing filenames/comments to the display. by default the system encoding will be used.--language-encoding,--no-language-encodingβ modern zip files set a metadata entry in zip files, called the "Language encoding flag", when they write filenames/comments encoded in UTF-8. occasionally some applications set the "Language Encoding Flag" but write data that is not UTF-8 in the filename/comment fields of the zip file. this will usually result in garbled text being output for the filenames/comments. π to deal with this use-case, set the--no-language-encodingoption and, if needed, set the--encoding nameoption to the encoding actually used. default is--language-encoding.--debug-encodingβ display extra debugging info when a filename/comment encoding has changed.
π Message Control Options π
--messages,--no-messagesβ enable/disable the output of all info/warning/error messages. disabling messages means that no checks are carried out to check that the zip file is well-formed. default is enabled.--exit-bitmask,--no-exit-bitmaskβ enable/disable exit status bitmask for messages. default disabled. bitmask values are:1for info,2for warning and4for error.
π Default Output π
by default zipdetails outputs each metadata field from the zip file in three columns.
- the offset, in hex, to the start of the field relative to the beginning of the file.
- the name of the field.
- detailed information about the contents of the field. the format depends on the type of data:
- Numeric Values β if the field contains an 8-bit, 16-bit, 32-bit or 64-bit numeric value, it will be displayed in both hex and decimal β for example
"002A (42)". note that zip files store most numeric values in little-endian encoding (there are a few rare instances where big-endian is used). the value read from the zip file will have the endian encoding removed before being displayed. next, there's an optional description of what the numeric value means. - String β if the field corresponds to a printable string, it will be output enclosed in single quotes.
- Binary Data β the term Binary Data is just a catch-all for all other metadata in the zip file. this data is displayed as a series of ascii-hex byte values in the same order they are stored in the zip file.
- Numeric Values β if the field contains an 8-bit, 16-bit, 32-bit or 64-bit numeric value, it will be displayed in both hex and decimal β for example
for example, assuming you have a zip file, test,zip, with one entry:
$ unzip -l test.zip
Archive: test.zip
Length Date Time Name
--------- ---------- ----- ----
446 2023-03-22 20:03 lorem.txt
--------- -------
446 1 file
running zipdetails gives this output:
$ zipdetails test.zip
0000 LOCAL HEADER #1 04034B50 (67324752)
0004 Extract Zip Spec 14 (20) '2.0'
0005 Extract OS 00 (0) 'MS-DOS'
0006 General Purpose Flag 0000 (0)
[Bits 1-2] 0 'Normal Compression'
0008 Compression Method 0008 (8) 'Deflated'
000A Modification Time 5676A072 (1450614898) 'Wed Mar 22 20:03:36 2023'
000E CRC F90EE7FF (4178503679)
0012 Compressed Size 0000010E (270)
0016 Uncompressed Size 000001BE (446)
001A Filename Length 0009 (9)
001C Extra Length 0000 (0)
001E Filename 'lorem.txt'
0027 PAYLOAD
0135 CENTRAL HEADER #1 02014B50 (33639248)
0139 Created Zip Spec 1E (30) '3.0'
013A Created OS 03 (3) 'Unix'
013B Extract Zip Spec 14 (20) '2.0'
013C Extract OS 00 (0) 'MS-DOS'
013D General Purpose Flag 0000 (0)
[Bits 1-2] 0 'Normal Compression'
013F Compression Method 0008 (8) 'Deflated'
0141 Modification Time 5676A072 (1450614898) 'Wed Mar 22 20:03:36 2023'
0145 CRC F90EE7FF (4178503679)
0149 Compressed Size 0000010E (270)
014D Uncompressed Size 000001BE (446)
0151 Filename Length 0009 (9)
0153 Extra Length 0000 (0)
0155 Comment Length 0000 (0)
0157 Disk Start 0000 (0)
0159 Int File Attributes 0001 (1)
[Bit 0] 1 'Text Data'
015B Ext File Attributes 81ED0000 (2179792896)
[Bits 16-24] 01ED (493) 'Unix attrib: rwxr-xr-x'
[Bits 28-31] 08 (8) 'Regular File'
015F Local Header Offset 00000000 (0)
0163 Filename 'lorem.txt'
016C END CENTRAL HEADER 06054B50 (101010256)
0170 Number of this disk 0000 (0)
0172 Central Dir Disk no 0000 (0)
0174 Entries in this disk 0001 (1)
0176 Total Entries 0001 (1)
0178 Size of Central Dir 00000037 (55)
017C Offset to Central Dir 00000135 (309)
0180 Comment Length 0000 (0)
#
# Done
β Verbose Output β
if the -v option is present, the metadata output is split into the following columns:
- the offset, in hex, to the start of the field relative to the beginning of the file.
- the offset, in hex, to the end of the field relative to the beginning of the file.
- the length, in hex, of the field.
- a hex dump of the bytes in the field in the order they are stored in the zip file.
- a textual description of the field.
- information about the contents of the field. see the description in the "Default Output" for more details.
here's the same zip file, test.zip, dumped using the zipdetails -v option:
$ zipdetails -v test.zip
0000 0003 0004 50 4B 03 04 LOCAL HEADER #1 04034B50 (67324752)
0004 0004 0001 14 Extract Zip Spec 14 (20) '2.0'
0005 0005 0001 00 Extract OS 00 (0) 'MS-DOS'
0006 0007 0002 00 00 General Purpose Flag 0000 (0)
[Bits 1-2] 0 'Normal Compression'
0008 0009 0002 08 00 Compression Method 0008 (8) 'Deflated'
000A 000D 0004 72 A0 76 56 Modification Time 5676A072 (1450614898) 'Wed Mar 22 20:03:36 2023'
000E 0011 0004 FF E7 0E F9 CRC F90EE7FF (4178503679)
0012 0015 0004 0E 01 00 00 Compressed Size 0000010E (270)
0016 0019 0004 BE 01 00 00 Uncompressed Size 000001BE (446)
001A 001B 0002 09 00 Filename Length 0009 (9)
001C 001D 0002 00 00 Extra Length 0000 (0)
001E 0026 0009 6C 6F 72 65 Filename 'lorem.txt'
6D 2E 74 78
74
0027 0134 010E ... PAYLOAD
0135 0138 0004 50 4B 01 02 CENTRAL HEADER #1 02014B50 (33639248)
0139 0139 0001 1E Created Zip Spec 1E (30) '3.0'
013A 013A 0001 03 Created OS 03 (3) 'Unix'
013B 013B 0001 14 Extract Zip Spec 14 (20) '2.0'
013C 013C 0001 00 Extract OS 00 (0) 'MS-DOS'
013D 013E 0002 00 00 General Purpose Flag 0000 (0)
[Bits 1-2] 0 'Normal Compression'
013F 0140 0002 08 00 Compression Method 0008 (8) 'Deflated'
0141 0144 0004 72 A0 76 56 Modification Time 5676A072 (1450614898) 'Wed Mar 22 20:03:36 2023'
0145 0148 0004 FF E7 0E F9 CRC F90EE7FF (4178503679)
0149 014C 0004 0E 01 00 00 Compressed Size 0000010E (270)
014D 0150 0004 BE 01 00 00 Uncompressed Size 000001BE (446)
0151 0152 0002 09 00 Filename Length 0009 (9)
0153 0154 0002 00 00 Extra Length 0000 (0)
0155 0156 0002 00 00 Comment Length 0000 (0)
0157 0158 0002 00 00 Disk Start 0000 (0)
0159 015A 0002 01 00 Int File Attributes 0001 (1)
[Bit 0] 1 'Text Data'
015B 015E 0004 00 00 ED 81 Ext File Attributes 81ED0000 (2179792896)
[Bits 16-24] 01ED (493) 'Unix attrib: rwxr-xr-x'
[Bits 28-31] 08 (8) 'Regular File'
015F 0162 0004 00 00 00 00 Local Header Offset 00000000 (0)
0163 016B 0009 6C 6F 72 65 Filename 'lorem.txt'
6D 2E 74 78
74
016C 016F 0004 50 4B 05 06 END CENTRAL HEADER 06054B50 (101010256)
0170 0171 0002 00 00 Number of this disk 0000 (0)
0172 0173 0002 00 00 Central Dir Disk no 0000 (0)
0174 0175 0002 01 00 Entries in this disk 0001 (1)
0176 0177 0002 01 00 Total Entries 0001 (1)
0178 017B 0004 37 00 00 00 Size of Central Dir 00000037 (55)
017C 017F 0004 35 01 00 00 Offset to Central Dir 00000135 (309)
0180 0181 0002 00 00 Comment Length 0000 (0)
#
# Done
π΅οΈβοΈ Advanced Analysis
okay bestie, so picture this: your zip file is lowkey corrupt or just built weird β like, the "Central Directory" metadata at the end of the file is missing or half-there. π In that case you've got two choices: the --walk option or the --scan option, and both of them go hunting for any zip metadata that's still kicking around in the file. πβ¨
When either one of these options is turned on, this program skips the whole "read the "Central Directory" at the end" first step and instead just scans the zip file sequentially from the top, looking for zip metadata records. Fr, it can be a lil error prone, but for the most part it will find any zip file metadata still present in the file.
So what's the difference between the two? It's all about how aggressive the sequential scan is, bestie: --walk is optimistic, while --scan is pessimistic. Periodt.
To really get the difference you gotta know a lil about how zip file metadata is structured. Under the hood, a zip file uses a series of 4-byte signatures to flag the start of each of the metadata records it uses. When --walk or --scan is enabled, both work identically at first: they scan the file from the beginning, looking for any of these valid 4-byte metadata signatures. And when a 4-byte signature is found, both options blindly assume they've found a valid metadata record and display it. π
--walk
The --walk option is the optimist of the duo β it assumes it found a real zip metadata record, so it starts the scan for the next record directly after the record it just output. No backtracking, no drama. πΆβοΈ
--scan
The --scan option is the pessimist π
β it assumes that 4-byte signature sequence might have been a false-positive, so before it starts scanning for the next record, it rewinds to the location in the file directly after the 4-byte sequence it just processed. Which means it will rescan data that's already been processed. For very large zip files, --scan can be really really slow, so try the --walk option first, bestie. π
Important Note: π¨ if the zip file you're processing contains one or more nested zip files, and the outer zip file uses the"STORE"compression method, the--scanoption will display the zip metadata for both the outer and inner zip files. iykyk.
π€ Filename Encoding Issues
Sometimes when you're displaying the contents of a zip file the filenames (or comments) come out looking garbled. So this section walks through the why and the mitigations you can apply to work around these issues. Buckle up. π
Background
When zip files were first created back in the 1980's, there was no Unicode or UTF-8, bestie. Nobody was stressing about character set encoding interoperability β it wasn't a major concern. π¦
At first, the only official encoding supported in zip files was IBM Code Page 437 (aka "CP437"). As time went on, users in locales where "CP437" wasn't appropriate stored filenames in the encoding native to their locale. If you were running a system that matched the locale of the zip file, all was well. πΈ If not? You had to post-process the filenames after unzipping. π
Now fast forward to the introduction of Unicode and UTF-8. The approach that all major zip implementations use now is setting the "Language encoding flag" (also known as "EFS") in the zip file metadata to signal that a filename/comment is encoded in UTF-8. β¨
To ensure maximum interoperability when sharing zip files, store 7-bit filenames as-is in the zip file. For anything else, the "EFS" bit needs to be set and the filename gets encoded in UTF-8. And although this rule is kept to for the most part, there are exceptions out there in the wild. π
Dealing with Encoding Errors
The most common filename encoding issue is when the "EFS" bit is not set and the filename is stored in a character set that doesn't match the system encoding. This mostly impacts legacy zip files that predate the introduction of Unicode. πΌ
To deal with it you first need to know what encoding was used in the zip file. So like, if the filename is encoded in "ISO-8859-1", you can display the filenames using the --encoding option, like this:
zipdetails --encoding ISO-8859-1 myfile.zip
A less common variation of this is when the "EFS" bit is set β signalling that the filename will be encoded in UTF-8 β but the filename isn't actually encoded in UTF-8. π Sneaky. To deal with that scenario, use the --no-language-encoding option along with the --encoding option. π«Ά
π« LIMITATIONS
The following zip file features are not supported by this program:
- Multi-part/Split/Spanned Zip Archives.
This program cannot give an overall report on the combined parts of a multi-part zip file. π
The best you can do is run with either the --scan or --walk options against the individual parts. Some will contain zipfile metadata which will be detected, and some will only contain compressed payload data.
- Encrypted Central Directory
When pkzip Strong Encryption is enabled in a zip file, this program can still parse most of the metadata in the zip file. π The exception is when the "Central Directory" of a zip file is also encrypted β this program cannot parse any metadata from an encrypted "Central Directory".
- Corrupt Zip files
When "zipdetails" encounters a corrupt zip file, it will do one or more of the following:
- Display details of the corruption and carry on
- Display details of the corruption and terminate
- Terminate with a generic message
Which of the above is output is dependent on the severity of the corruption.
π TODO
JSON/YML Output
Output some of the zip file metadata as a JSON or YML document. π
Corrupt Zip files
Although the detection and reporting of most of the common corruption use-cases is present in "zipdetails", there are likely to be other edge cases that need to be supported.
If you have a corrupt Zip file that isn't being processed properly, please report it (see "SUPPORT"). π
π SUPPORT
General feedback/questions/bug reports should be sent to <https://github.com/pmqs/zipdetails/issues>. π
π SEE ALSO
The primary reference for Zip files is APPNOTE.TXT <https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT>. π
If you need to investigate the extra fields that are used in zip files, the "appnote" document covers a lot of them. The Info-ZIP zip distribution, available at <https://infozip.sourceforge.net/>, contains additional extra field definitions β look for the file "extrafld.txt". π
For details of WinZip AES encryption see AES Encryption Information: Encryption Specification AE-1 and AE-2 <https://www.winzip.com/en/support/aes-encryption/>. π
The "zipinfo" program that comes with the info-zip distribution (<http://www.info-zip.org/>) can also display details of the structure of a zip file. π¦
π AUTHOR
Paul Marquess pmqs@cpan.org.
Β©οΈ COPYRIGHT
Copyright (c) 2011-2026 Paul Marquess. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie!! π this lil legend is perl v5.40.1, dated 2026-07-04 β go forth and ZIPDETAILS(1p) your way through every zip file you meet. slay. π
β¨
π¦ where this page comes from
- ubuntu stonking: libio-compress-perl 2.223-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms