xref: /freebsd/contrib/file/magic/Magdir/zip (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
1#------------------------------------------------------------------------------
2# $File: zip,v 1.8 2021/10/24 15:53:56 christos Exp $
3# zip:  file(1) magic for zip files; this is not use
4# Note the version of magic in archive is currently stronger, this is
5# just an example until negative offsets are supported better
6# Note:	All fields unless otherwise noted are unsigned!
7
8# Zip Central Directory record
90	name		zipcd
10>0	string		PK\001\002	Zip archive data
11!:mime	application/zip
12# no "made by" in local file header with PK\3\4 magic
13>>4	leshort		x		\b, made by
14>>4	use		zipversion
15>>4	use		ziphost
16# inside ./archive 1.151 called "at least" zipversion "to extract"
17>>6	leshort		x		\b, extract using at least
18>>6	use		zipversion
19# This is DOS date like: ledate 21:00:48 19 Dec 2001 != DOS 00:00 1 Jan 2010 ~ 0000213C
20>>12	ulelong		x		\b, last modified
21>>14	lemsdosdate	x		\b, last modified %s
22>>12	lemsdostime	x		%s
23# uncompressed size of 1st entry; FFffFFff means real value stored in ZIP64 record
24>>24	ulelong		!0xFFffFFff	\b, uncompressed size %u
25# inside ./archive 1.151 called "compression method="zipcompression
26>>10	leshort		x		\b, method=
27>>10	use		zipcompression
28
29# URL:		https://en.wikipedia.org/wiki/Zip_(file_format)
30# reference:	https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT (Version: 6.3.9)
31# Zip known compressions
320	name		zipcompression
33>0	leshort		0		\bstore
34>0	leshort		1		\bShrinking
35>0	leshort		6		\bImploding
36>0	leshort		7		\bTokenizing
37>0	leshort		8		\bdeflate
38>0	leshort		9		\bdeflate64
39>0	leshort		10		\bLibrary imploding
40#>0	leshort		11 		\bReserved by PKWARE
41>0	leshort		12		\bbzip2
42#>0	leshort		13 		\bReserved by PKWARE
43>0	leshort		14		\blzma
44#>0	leshort		15 		\bReserved by PKWARE
45>0	leshort		16		\bCMPSC (IBM z/OS)
46#>0	leshort		17 		\bReserved by PKWARE
47>0	leshort		18		\bIBM TERSE
48>0	leshort		19		\bIBM LZ77 (z/Architecture)
49>0	leshort		20		\bZstd (deprecated)
50>0	leshort		93		\bZstd
51>0	leshort		94		\bMP3
52>0	leshort		95		\bxz
53>0	leshort		96		\bJpeg
54>0	leshort		97		\bWavPack
55>0	leshort		98		\bPPMd
56>0	leshort		99		\bAES Encrypted
57>0	default		x
58>>0	leshort		x		\b[%#x]
59
60# Zip known versions
610	name		zipversion
62# The lower byte indicates the ZIP version of this file. The value/10 indicates
63# the major version number, and the value mod 10 is the minor version number.
64>0	ubyte/10	x		v%u
65>0	ubyte%10	x		\b.%u
66# >0	leshort		0x09		v0.9
67# >0	leshort		0x0a		v1.0
68# >0	leshort		0x0b		v1.1
69# >0	leshort		0x14		v2.0
70# >0	leshort		0x15		v2.1
71# >0	leshort		0x19		v2.5
72# >0	leshort		0x1b		v2.7
73# >0	leshort		0x2d		v4.5
74# >0	leshort		0x2e		v4.6
75# >0	leshort		0x32		v5.0
76# >0	leshort		0x33		v5.1
77# >0	leshort		0x34		v5.2
78# >0	leshort		0x3d		v6.1
79# >0	leshort		0x3e		v6.2
80# >0	leshort		0x3f		v6.3
81# >0	default		x
82# >>0	leshort		x		v?[%#x]
83
84#	display compatible host system name of ZIP archive
850	name		ziphost
86# The upper byte indicates the compatibility of the file attribute information.
87# If the file is compatible with MS-DOS (v 2.04g) then this value will be zero.
88#>1	ubyte		0		DOS
89>1	ubyte		1 		Amiga
90>1	ubyte		2		OpenVMS
91>1	ubyte		3		UNIX
92>1	ubyte		4		VM/CMS
93>1	ubyte		6		OS/2
94>1	ubyte		7		Macintosh
95>1	ubyte		11		MVS
96>1	ubyte		13		Acorn Risc
97>1	ubyte		16		BeOS
98>1	ubyte		17		Tandem
99# 9 untested
100>1	ubyte		5		Atari ST
101>1	ubyte		8		Z-System
102>1	ubyte		9		CP/M
103>1	ubyte		10		Windows NTFS
104>1	ubyte		12		VSE
105>1	ubyte		14		VFAT
106>1	ubyte		15		alternate MVS
107>1	ubyte		18		OS/400
108>1	ubyte		19		OS X
109# unused
110#>1	ubyte		>19		unused %#x
111
112# Zip End Of Central Directory record
113# GRR: wrong for ZIP with comment archive
114-22	string		PK\005\006
115#>4	uleshort	!0xFFff		\b, %u disks
116#>6	uleshort	!0xFFff		\b, central directory disk %u
117#>8	uleshort	!0xFFff		\b, %u central directories on this disk
118#>10	uleshort	!0xFFff		\b, %u central directories
119#>12	ulelong		!0xFFffFFff	\b, %u central directory bytes
120# offset of central directory
121#>16	ulelong		x		\b, central directory offset %#x
122>(16.l)	use		zipcd
123# archive comment length n
124#>>20	uleshort	>0		\b, comment length %u
125# archive comment
126>>20	pstring/l	>0		\b, %s
127