A ZIP file is a sequence of local file headers and data, followed by a central directory and an end-of-central-directory record (PK 05 06). Each member has its own compression method (store, Deflate, Deflate64, bzip2, LZMA, Zstandard, XZ, PPMd and legacy Shrink/Reduce/Implode), CRC-32 and optional encryption (ZipCrypto or WinZip AES). ZIP64 extensions lift the 4 GiB and 65,535-entry limits, and archives can be split into volumes.
Where it is used
General file exchange; the container for Office Open XML, ODF, JAR, APK and EPUB files.
Software distribution and backups.
History
Created by Phil Katz at PKWARE in 1989; the APPNOTE specification is maintained by PKWARE.
ZIP64 was added in 2001.
Status today
Universal; supported natively by Windows, macOS and Linux tools.
Structures read by the implementation
Offsets are in bytes from the start of the buffer named in each heading. Field names are taken from the implementation and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.
CentralEntry.TryRead buffer h · ZipArchiveReader.cs
ZipArchiveReader.ReadCore buffer e · ZipArchiveReader.cs
Offset
Size
Type
Field
Notes
0x0
2
u16 LE
–
0x4
2
u16 LE
Disk
0x6
2
u16 LE
Cd Disk
0xA
2
u16 LE
Total
0xC
4
u32 LE
Cd Size
0x10
4
u32 LE
Cd Offset
0x14
2
u16 LE
Comment Length
struct.TrySignedDescriptor buffer d · ZipArchiveReader.cs
Offset
Size
Type
Field
Notes
0x4
4
u32 LE
Crc
0x8
4
u32 LE
–
0x8
8
u64 LE
–
0xC
4
u32 LE
–
0x10
8
u64 LE
–
struct.TryUnsignedDescriptor buffer d · ZipArchiveReader.cs
Offset
Size
Type
Field
Notes
0x0
4
u32 LE
Short32
0x0
4
u32 LE
Long64
0x4
4
u32 LE
–
0x4
8
u64 LE
–
0x8
4
u32 LE
Short32
0xC
8
u64 LE
Long64
ZipExtraFields.TryFind buffer extra · ZipFormat.cs
Offset
Size
Type
Field
Notes
(pos + 2)
2
u16 LE
Size
pos
2
u16 LE
Field Id
ZipLocalHeader.TryRead buffer h · ZipFormat.cs
Offset
Size
Type
Field
Notes
0x0
4
u32 LE
–
0x4
2
u16 LE
Version Needed
0x6
2
u16 LE
Flags
0x8
2
u16 LE
Method
0xA
2
u16 LE
Dos Time
0xC
2
u16 LE
Dos Date
0xE
4
u32 LE
Crc32
0x12
4
u32 LE
Compressed
0x16
4
u32 LE
Uncompressed
0x1A
2
u16 LE
Name Length
0x1C
2
u16 LE
Extra Length
ZipLocalHeader.TryRead buffer z64 · ZipFormat.cs
Offset
Size
Type
Field
Notes
p
8
u64 LE
Uncompressed
p
8
u64 LE
Compressed
ZipText.UnicodePathFromExtra buffer field · ZipFormat.cs
Offset
Size
Type
Field
Notes
0x0
1
u8
–
0x1
4
u32 LE
Name Crc
Other fields read
Read in
Offset
Size
Type
Field
Notes
ZipByteReader.TryReadUInt32
0x0
4
u32 LE
Value
ZipByteReader.TryReadUInt64
0x0
8
u64 LE
Value
Constants
General ZipArchiveReader
Name
Value
Type
Notes
FirstSearchChunk
64 * 1024
int
—- Apple iWork ——————————————————————– DocumentProperties
Name
Value
Type
Notes
MaxIndexZipSize
512 * 1024 * 1024
int
General ZipEntryDataStream
Name
Value
Type
Notes
Sector
ErrorMarker.PatternLength
int
General ZipSignatures
Name
Value
Type
Notes
LocalFileHeader
0x04034B50
uint
PK 03 04
DataDescriptor
0x08074B50
uint
PK 07 08
CentralDirectory
0x02014B50
uint
PK 01 02
DigitalSignature
0x05054B50
uint
PK 05 05
Zip64EndOfCentralDir
0x06064B50
uint
PK 06 06
Zip64Locator
0x07064B50
uint
PK 06 07
EndOfCentralDir
0x06054B50
uint
PK 05 06
ArchiveExtraData
0x08064B50
uint
PK 06 08 (central directory encryption)
LocalHeaderSize
30
int
CentralHeaderSize
46
int
EndOfCentralDirSize
22
int
Zip64LocatorSize
20
int
Zip64EndOfCentralDirMinSize
56
int
Zip64ExtraId
0x0001
ushort
UnicodePathExtraId
0x7075
ushort
Info-ZIP Unicode Path
FlagEncrypted
0x0001
ushort
FlagDataDescriptor
0x0008
ushort
FlagStrongEncryption
0x0040
ushort
FlagUtf8
0x0800
ushort
General ZipCrc32
Name
Value
Type
Notes
Table
BuildTable()
uint[]
General ZipText
Name
Value
Type
Notes
Utf8
new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: false)
Encoding
General ZipMethods
Name
Value
Type
Notes
Stored
0
ushort
Deflated
8
ushort
Aes
99
ushort
—————————————————————— Shrink (method 1) Bits
Name
Value
Type
Notes
Free
-1, Root = -2, Max = 8192
int
Encrypted entries: find the password once (known keys, then a prompt), checked by fully decrypting and decoding the smallest encrypted file against its CRC (or WinZip AES HMAC). ZipArchiveModule
Structures and constants were extracted from: Carving/Plugins/Zip/ZipArchiveInfo.cs, Carving/Plugins/Zip/ZipArchiveReader.cs, Carving/Plugins/Zip/ZipCarver.cs, Carving/Plugins/Zip/ZipEntryDataStream.cs, Carving/Plugins/Zip/ZipFormat.cs, Carving/Plugins/Zip/ZipLegacy.cs, Carving/Plugins/Zip/ZipParts.cs, Modules/FileSystems/ZipArchiveModule.cs. Prose sections are a summary from public sources; verify details before relying on them.