158a0f0d0SEitan Adler#------------------------------------------------------------------------------ 2*a4d6d3b8SXin LI# $File: zip,v 1.8 2021/10/24 15:53:56 christos Exp $ 358a0f0d0SEitan Adler# zip: file(1) magic for zip files; this is not use 458a0f0d0SEitan Adler# Note the version of magic in archive is currently stronger, this is 558a0f0d0SEitan Adler# just an example until negative offsets are supported better 6*a4d6d3b8SXin LI# Note: All fields unless otherwise noted are unsigned! 758a0f0d0SEitan Adler 82726a701SXin LI# Zip Central Directory record 958a0f0d0SEitan Adler0 name zipcd 1048c779cdSXin LI>0 string PK\001\002 Zip archive data 1143a5ec4eSXin LI!:mime application/zip 12*a4d6d3b8SXin LI# no "made by" in local file header with PK\3\4 magic 1358a0f0d0SEitan Adler>>4 leshort x \b, made by 1458a0f0d0SEitan Adler>>4 use zipversion 152726a701SXin LI>>4 use ziphost 16*a4d6d3b8SXin LI# inside ./archive 1.151 called "at least" zipversion "to extract" 1758a0f0d0SEitan Adler>>6 leshort x \b, extract using at least 1858a0f0d0SEitan Adler>>6 use zipversion 19*a4d6d3b8SXin LI# This is DOS date like: ledate 21:00:48 19 Dec 2001 != DOS 00:00 1 Jan 2010 ~ 0000213C 20*a4d6d3b8SXin LI>>12 ulelong x \b, last modified 21*a4d6d3b8SXin LI>>14 lemsdosdate x \b, last modified %s 22*a4d6d3b8SXin LI>>12 lemsdostime x %s 23*a4d6d3b8SXin LI# uncompressed size of 1st entry; FFffFFff means real value stored in ZIP64 record 24*a4d6d3b8SXin LI>>24 ulelong !0xFFffFFff \b, uncompressed size %u 25*a4d6d3b8SXin LI# inside ./archive 1.151 called "compression method="zipcompression 2658a0f0d0SEitan Adler>>10 leshort x \b, method= 2758a0f0d0SEitan Adler>>10 use zipcompression 2858a0f0d0SEitan Adler 292726a701SXin LI# URL: https://en.wikipedia.org/wiki/Zip_(file_format) 3043a5ec4eSXin LI# reference: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT (Version: 6.3.9) 3158a0f0d0SEitan Adler# Zip known compressions 3258a0f0d0SEitan Adler0 name zipcompression 3358a0f0d0SEitan Adler>0 leshort 0 \bstore 342726a701SXin LI>0 leshort 1 \bShrinking 352726a701SXin LI>0 leshort 6 \bImploding 362726a701SXin LI>0 leshort 7 \bTokenizing 3758a0f0d0SEitan Adler>0 leshort 8 \bdeflate 3858a0f0d0SEitan Adler>0 leshort 9 \bdeflate64 392726a701SXin LI>0 leshort 10 \bLibrary imploding 402726a701SXin LI#>0 leshort 11 \bReserved by PKWARE 4158a0f0d0SEitan Adler>0 leshort 12 \bbzip2 422726a701SXin LI#>0 leshort 13 \bReserved by PKWARE 4358a0f0d0SEitan Adler>0 leshort 14 \blzma 442726a701SXin LI#>0 leshort 15 \bReserved by PKWARE 4543a5ec4eSXin LI>0 leshort 16 \bCMPSC (IBM z/OS) 462726a701SXin LI#>0 leshort 17 \bReserved by PKWARE 472726a701SXin LI>0 leshort 18 \bIBM TERSE 4843a5ec4eSXin LI>0 leshort 19 \bIBM LZ77 (z/Architecture) 4943a5ec4eSXin LI>0 leshort 20 \bZstd (deprecated) 5043a5ec4eSXin LI>0 leshort 93 \bZstd 5158a0f0d0SEitan Adler>0 leshort 94 \bMP3 5258a0f0d0SEitan Adler>0 leshort 95 \bxz 5358a0f0d0SEitan Adler>0 leshort 96 \bJpeg 5458a0f0d0SEitan Adler>0 leshort 97 \bWavPack 5558a0f0d0SEitan Adler>0 leshort 98 \bPPMd 5658a0f0d0SEitan Adler>0 leshort 99 \bAES Encrypted 5758a0f0d0SEitan Adler>0 default x 5858a0f0d0SEitan Adler>>0 leshort x \b[%#x] 5958a0f0d0SEitan Adler 6058a0f0d0SEitan Adler# Zip known versions 6158a0f0d0SEitan Adler0 name zipversion 622726a701SXin LI# The lower byte indicates the ZIP version of this file. The value/10 indicates 632726a701SXin LI# the major version number, and the value mod 10 is the minor version number. 642726a701SXin LI>0 ubyte/10 x v%u 652726a701SXin LI>0 ubyte%10 x \b.%u 662726a701SXin LI# >0 leshort 0x09 v0.9 672726a701SXin LI# >0 leshort 0x0a v1.0 682726a701SXin LI# >0 leshort 0x0b v1.1 692726a701SXin LI# >0 leshort 0x14 v2.0 702726a701SXin LI# >0 leshort 0x15 v2.1 712726a701SXin LI# >0 leshort 0x19 v2.5 722726a701SXin LI# >0 leshort 0x1b v2.7 732726a701SXin LI# >0 leshort 0x2d v4.5 742726a701SXin LI# >0 leshort 0x2e v4.6 752726a701SXin LI# >0 leshort 0x32 v5.0 762726a701SXin LI# >0 leshort 0x33 v5.1 772726a701SXin LI# >0 leshort 0x34 v5.2 782726a701SXin LI# >0 leshort 0x3d v6.1 792726a701SXin LI# >0 leshort 0x3e v6.2 802726a701SXin LI# >0 leshort 0x3f v6.3 812726a701SXin LI# >0 default x 822726a701SXin LI# >>0 leshort x v?[%#x] 832726a701SXin LI 842726a701SXin LI# display compatible host system name of ZIP archive 852726a701SXin LI0 name ziphost 862726a701SXin LI# The upper byte indicates the compatibility of the file attribute information. 872726a701SXin LI# If the file is compatible with MS-DOS (v 2.04g) then this value will be zero. 882726a701SXin LI#>1 ubyte 0 DOS 892726a701SXin LI>1 ubyte 1 Amiga 902726a701SXin LI>1 ubyte 2 OpenVMS 912726a701SXin LI>1 ubyte 3 UNIX 922726a701SXin LI>1 ubyte 4 VM/CMS 932726a701SXin LI>1 ubyte 6 OS/2 942726a701SXin LI>1 ubyte 7 Macintosh 952726a701SXin LI>1 ubyte 11 MVS 962726a701SXin LI>1 ubyte 13 Acorn Risc 972726a701SXin LI>1 ubyte 16 BeOS 982726a701SXin LI>1 ubyte 17 Tandem 992726a701SXin LI# 9 untested 1002726a701SXin LI>1 ubyte 5 Atari ST 1012726a701SXin LI>1 ubyte 8 Z-System 1022726a701SXin LI>1 ubyte 9 CP/M 1032726a701SXin LI>1 ubyte 10 Windows NTFS 1042726a701SXin LI>1 ubyte 12 VSE 1052726a701SXin LI>1 ubyte 14 VFAT 1062726a701SXin LI>1 ubyte 15 alternate MVS 1072726a701SXin LI>1 ubyte 18 OS/400 1082726a701SXin LI>1 ubyte 19 OS X 1092726a701SXin LI# unused 11043a5ec4eSXin LI#>1 ubyte >19 unused %#x 11158a0f0d0SEitan Adler 11258a0f0d0SEitan Adler# Zip End Of Central Directory record 113*a4d6d3b8SXin LI# GRR: wrong for ZIP with comment archive 11448c779cdSXin LI-22 string PK\005\006 115*a4d6d3b8SXin LI#>4 uleshort !0xFFff \b, %u disks 116*a4d6d3b8SXin LI#>6 uleshort !0xFFff \b, central directory disk %u 117*a4d6d3b8SXin LI#>8 uleshort !0xFFff \b, %u central directories on this disk 118*a4d6d3b8SXin LI#>10 uleshort !0xFFff \b, %u central directories 119*a4d6d3b8SXin LI#>12 ulelong !0xFFffFFff \b, %u central directory bytes 120*a4d6d3b8SXin LI# offset of central directory 121*a4d6d3b8SXin LI#>16 ulelong x \b, central directory offset %#x 12258a0f0d0SEitan Adler>(16.l) use zipcd 123*a4d6d3b8SXin LI# archive comment length n 124*a4d6d3b8SXin LI#>>20 uleshort >0 \b, comment length %u 125*a4d6d3b8SXin LI# archive comment 126d38c30c0SXin LI>>20 pstring/l >0 \b, %s 127