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