From e64127448754d8ed39e0108bac61e02297dcba7b Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Thu, 26 May 2022 12:39:14 +0200 Subject: [PATCH] zip: Add zip64 support and uncompress option {uncompress:boolean} uncompress and probe, default true --- README.md | 2 +- doc/formats.md | 22 +- format/all/help.fqtest | 6 + format/format.go | 4 + format/zip/testdata/test-macos.fqtest | 4 +- format/zip/testdata/test0.fqtest | 4 +- format/zip/testdata/test64.fqtest | 681 ++++++++++++++++++++++++++ format/zip/testdata/test64.zip | Bin 0 -> 1204 bytes format/zip/testdata/test9.fqtest | 4 +- format/zip/zip.go | 163 ++++-- 10 files changed, 843 insertions(+), 47 deletions(-) create mode 100644 format/zip/testdata/test64.fqtest create mode 100644 format/zip/testdata/test64.zip diff --git a/README.md b/README.md index 951624a0..1eff3588 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ vpx_ccr, wav, webp, xing, -zip +[zip](doc/formats.md#zip) [#]: sh-end diff --git a/doc/formats.md b/doc/formats.md index de6e6b39..cbc7c07c 100644 --- a/doc/formats.md +++ b/doc/formats.md @@ -95,7 +95,7 @@ |`wav` |WAV file |`id3v2` `id3v1` `id3v11`| |`webp` |WebP image |`vp8_frame`| |`xing` |Xing header || -|`zip` |ZIP archive |`probe`| +|[`zip`](#zip) |ZIP archive |`probe`| |`image` |Group |`gif` `jpeg` `mp4` `png` `tiff` `webp`| |`inet_packet` |Group |`ipv4_packet` `ipv6_packet`| |`ip_packet` |Group |`icmp` `icmpv6` `tcp_segment` `udp_datagram`| @@ -451,6 +451,26 @@ Current only supports plain RTMP (not RTMPT or encrypted variants etc) with AMF0 - https://rtmp.veriskope.com/docs/spec/ - https://rtmp.veriskope.com/pdf/video_file_format_spec_v10.pdf +### zip + +#### Options + +|Name |Default|Description| +|- |- |-| +|`uncompress`|true |Decompress and probe files| + +#### Examples + +Decode file using options +``` +$ fq -d zip -o uncompress=true file +``` + +Decode value as zip +``` +... | zip({uncompress: true}) +``` + [#]: sh-end diff --git a/format/all/help.fqtest b/format/all/help.fqtest index bc4c4cdf..e3b71d02 100644 --- a/format/all/help.fqtest +++ b/format/all/help.fqtest @@ -763,8 +763,14 @@ out # Decode value as xing out ... | xing "help(zip)" out zip: ZIP archive decoder +out Options: +out uncompress=true Decompress and probe files out Examples: out # Decode file as zip out $ fq -d zip file out # Decode value as zip out ... | zip +out # Decode file using options +out $ fq -d zip -o uncompress=true file +out # Decode value as zip +out ... | zip({uncompress: true}) diff --git a/format/format.go b/format/format.go index aabb1592..85d23e9f 100644 --- a/format/format.go +++ b/format/format.go @@ -265,3 +265,7 @@ type Mp4In struct { DecodeSamples bool `doc:"Decode supported media samples"` AllowTruncated bool `doc:"Allow box to be truncated"` } + +type ZipIn struct { + Uncompress bool `doc:"Decompress and probe files"` +} diff --git a/format/zip/testdata/test-macos.fqtest b/format/zip/testdata/test-macos.fqtest index 25c2847f..d297d876 100644 --- a/format/zip/testdata/test-macos.fqtest +++ b/format/zip/testdata/test-macos.fqtest @@ -622,13 +622,13 @@ $ fq -d zip dv test-macos.zip 0x0410| 0b 00 | .. | data_size: 11 0x413-0x414.7 (2) 0x0410| 01 04 f5 01 00 00 04 14 00 00 00| ...........| data: raw bits 0x415-0x41f.7 (11) | | | file_comment: "" 0x420-NA (0) - | | | end_of_central_directory{}: 0x420-0x435.7 (22) + | | | end_of_central_directory_record{}: 0x420-0x435.7 (22) 0x0420|50 4b 05 06 |PK.. | signature: raw bits (valid) 0x420-0x423.7 (4) 0x0420| 00 00 | .. | disk_nr: 0 0x424-0x425.7 (2) 0x0420| 00 00 | .. | central_directory_start_disk_nr: 0 0x426-0x427.7 (2) 0x0420| 05 00 | .. | nr_of_central_directory_records_on_disk: 5 0x428-0x429.7 (2) 0x0420| 05 00 | .. | nr_of_central_directory_records: 5 0x42a-0x42b.7 (2) -0x0420| b2 01 00 00| ....| size_of_central directory: 434 0x42c-0x42f.7 (4) +0x0420| b2 01 00 00| ....| size_of_central_directory: 434 0x42c-0x42f.7 (4) 0x0430|6e 02 00 00 |n... | offset_of_start_of_central_directory: 622 0x430-0x433.7 (4) 0x0430| 00 00| | ..| | comment_length: 0 0x434-0x435.7 (2) | | | comment: "" 0x436-NA (0) diff --git a/format/zip/testdata/test0.fqtest b/format/zip/testdata/test0.fqtest index 6341f7a2..5fe7bb83 100644 --- a/format/zip/testdata/test0.fqtest +++ b/format/zip/testdata/test0.fqtest @@ -597,13 +597,13 @@ $ fq -d zip dv test0.zip 0x03a0| 01 04 f5 01 00 00 04 14 00| .........| data: raw bits 0x3a7-0x3b1.7 (11) 0x03b0|00 00 |.. | | | | file_comment: "" 0x3b2-NA (0) - | | | end_of_central_directory{}: 0x3b2-0x3c7.7 (22) + | | | end_of_central_directory_record{}: 0x3b2-0x3c7.7 (22) 0x03b0| 50 4b 05 06 | PK.. | signature: raw bits (valid) 0x3b2-0x3b5.7 (4) 0x03b0| 00 00 | .. | disk_nr: 0 0x3b6-0x3b7.7 (2) 0x03b0| 00 00 | .. | central_directory_start_disk_nr: 0 0x3b8-0x3b9.7 (2) 0x03b0| 05 00 | .. | nr_of_central_directory_records_on_disk: 5 0x3ba-0x3bb.7 (2) 0x03b0| 05 00 | .. | nr_of_central_directory_records: 5 0x3bc-0x3bd.7 (2) -0x03b0| 8a 01| ..| size_of_central directory: 394 0x3be-0x3c1.7 (4) +0x03b0| 8a 01| ..| size_of_central_directory: 394 0x3be-0x3c1.7 (4) 0x03c0|00 00 |.. | 0x03c0| 28 02 00 00 | (... | offset_of_start_of_central_directory: 552 0x3c2-0x3c5.7 (4) 0x03c0| 00 00| | ..| | comment_length: 0 0x3c6-0x3c7.7 (2) diff --git a/format/zip/testdata/test64.fqtest b/format/zip/testdata/test64.fqtest new file mode 100644 index 00000000..0fe60e87 --- /dev/null +++ b/format/zip/testdata/test64.fqtest @@ -0,0 +1,681 @@ +# zip -fz -r test64.zip test +$ fq -d zip dv test64.zip + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: test64.zip (zip) 0x0-0x4b3.7 (1204) + | | | local_files[0:5]: 0x0-0x28b.7 (652) + | | | [0]{}: local_file 0x0-0x52.7 (83) +0x0000|50 4b 03 04 |PK.. | signature: raw bits (valid) 0x0-0x3.7 (4) +0x0000| 2d 00 | -. | version_needed: 45 0x4-0x5.7 (2) + | | | flags{}: 0x6-0x7.7 (2) +0x0000| 00 | . | unused0: 0 0x6-0x6 (0.1) +0x0000| 00 | . | strong_encryption: false 0x6.1-0x6.1 (0.1) +0x0000| 00 | . | compressed_patched_data: false 0x6.2-0x6.2 (0.1) +0x0000| 00 | . | enhanced_deflation: false 0x6.3-0x6.3 (0.1) +0x0000| 00 | . | data_descriptor: false 0x6.4-0x6.4 (0.1) +0x0000| 00 | . | compression0: false 0x6.5-0x6.5 (0.1) +0x0000| 00 | . | compression1: false 0x6.6-0x6.6 (0.1) +0x0000| 00 | . | encrypted: false 0x6.7-0x6.7 (0.1) +0x0000| 00 | . | reserved0: 0 0x7-0x7.1 (0.2) +0x0000| 00 | . | mask_header_values: false 0x7.2-0x7.2 (0.1) +0x0000| 00 | . | reserved1: false 0x7.3-0x7.3 (0.1) +0x0000| 00 | . | language_encoding: false 0x7.4-0x7.4 (0.1) +0x0000| 00 | . | unused1: 0 0x7.5-0x7.7 (0.3) +0x0000| 00 00 | .. | compression_method: "none" (0) 0x8-0x9.7 (2) + | | | last_modification_date{}: 0xa-0xb.7 (2) +0x0000| 6a | j | hours: 13 0xa-0xa.4 (0.5) +0x0000| 6a 96 | j. | minutes: 20 0xa.5-0xb.2 (0.6) +0x0000| 96 | . | seconds: 22 0xb.3-0xb.7 (0.5) + | | | last_modification_time{}: 0xc-0xd.7 (2) +0x0000| 2c | , | year: 22 0xc-0xc.6 (0.7) +0x0000| 2c 54 | ,T | month: 2 0xc.7-0xd.2 (0.4) +0x0000| 54 | T | day: 20 0xd.3-0xd.7 (0.5) +0x0000| 00 00| ..| crc32_uncompressed: 0x0 0xe-0x11.7 (4) +0x0010|00 00 |.. | +0x0010| ff ff ff ff | .... | compressed_size: 4294967295 0x12-0x15.7 (4) +0x0010| ff ff ff ff | .... | uncompressed_size: 4294967295 0x16-0x19.7 (4) +0x0010| 05 00 | .. | file_name_length: 5 0x1a-0x1b.7 (2) +0x0010| 30 00 | 0. | extra_field_length: 48 0x1c-0x1d.7 (2) +0x0010| 74 65| te| file_name: "test/" 0x1e-0x22.7 (5) +0x0020|73 74 2f |st/ | + | | | extra_fields[0:3]: 0x23-0x52.7 (48) + | | | [0]{}: extra_field 0x23-0x2f.7 (13) +0x0020| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x23-0x24.7 (2) +0x0020| 09 00 | .. | data_size: 9 0x25-0x26.7 (2) +0x0020| 03 17 15 df 61 5d 57 05 62| ....a]W.b| data: raw bits 0x27-0x2f.7 (9) + | | | [1]{}: extra_field 0x30-0x3e.7 (15) +0x0030|75 78 |ux | header_id: 0x7875 (UNIX UID/GID) 0x30-0x31.7 (2) +0x0030| 0b 00 | .. | data_size: 11 0x32-0x33.7 (2) +0x0030| 01 04 f5 01 00 00 04 14 00 00 00 | ........... | data: raw bits 0x34-0x3e.7 (11) + | | | [2]{}: extra_field 0x3f-0x52.7 (20) +0x0030| 01| .| header_id: 0x1 (ZIP64 extended information extra field) 0x3f-0x40.7 (2) +0x0040|00 |. | +0x0040| 10 00 | .. | data_size: 16 0x41-0x42.7 (2) +0x0040| 00 00 00 00 00 00 00 00 | ........ | uncompressed_size: 0 0x43-0x4a.7 (8) +0x0040| 00 00 00 00 00| .....| compressed_size: 0 0x4b-0x52.7 (8) +0x0050|00 00 00 |... | + | | | uncompressed: raw bits 0x53-NA (0) + | | | [1]{}: local_file 0x53-0xa7.7 (85) +0x0050| 50 4b 03 04 | PK.. | signature: raw bits (valid) 0x53-0x56.7 (4) +0x0050| 2d 00 | -. | version_needed: 45 0x57-0x58.7 (2) + | | | flags{}: 0x59-0x5a.7 (2) +0x0050| 00 | . | unused0: 0 0x59-0x59 (0.1) +0x0050| 00 | . | strong_encryption: false 0x59.1-0x59.1 (0.1) +0x0050| 00 | . | compressed_patched_data: false 0x59.2-0x59.2 (0.1) +0x0050| 00 | . | enhanced_deflation: false 0x59.3-0x59.3 (0.1) +0x0050| 00 | . | data_descriptor: false 0x59.4-0x59.4 (0.1) +0x0050| 00 | . | compression0: false 0x59.5-0x59.5 (0.1) +0x0050| 00 | . | compression1: false 0x59.6-0x59.6 (0.1) +0x0050| 00 | . | encrypted: false 0x59.7-0x59.7 (0.1) +0x0050| 00 | . | reserved0: 0 0x5a-0x5a.1 (0.2) +0x0050| 00 | . | mask_header_values: false 0x5a.2-0x5a.2 (0.1) +0x0050| 00 | . | reserved1: false 0x5a.3-0x5a.3 (0.1) +0x0050| 00 | . | language_encoding: false 0x5a.4-0x5a.4 (0.1) +0x0050| 00 | . | unused1: 0 0x5a.5-0x5a.7 (0.3) +0x0050| 00 00 | .. | compression_method: "none" (0) 0x5b-0x5c.7 (2) + | | | last_modification_date{}: 0x5d-0x5e.7 (2) +0x0050| 6a | j | hours: 13 0x5d-0x5d.4 (0.5) +0x0050| 6a 96 | j. | minutes: 20 0x5d.5-0x5e.2 (0.6) +0x0050| 96 | . | seconds: 22 0x5e.3-0x5e.7 (0.5) + | | | last_modification_time{}: 0x5f-0x60.7 (2) +0x0050| 2c| ,| year: 22 0x5f-0x5f.6 (0.7) +0x0050| 2c| ,| month: 2 0x5f.7-0x60.2 (0.4) +0x0060|54 |T | +0x0060|54 |T | day: 20 0x60.3-0x60.7 (0.5) +0x0060| 00 00 00 00 | .... | crc32_uncompressed: 0x0 0x61-0x64.7 (4) +0x0060| ff ff ff ff | .... | compressed_size: 4294967295 0x65-0x68.7 (4) +0x0060| ff ff ff ff | .... | uncompressed_size: 4294967295 0x69-0x6c.7 (4) +0x0060| 07 00 | .. | file_name_length: 7 0x6d-0x6e.7 (2) +0x0060| 30| 0| extra_field_length: 48 0x6f-0x70.7 (2) +0x0070|00 |. | +0x0070| 74 65 73 74 2f 61 2f | test/a/ | file_name: "test/a/" 0x71-0x77.7 (7) + | | | extra_fields[0:3]: 0x78-0xa7.7 (48) + | | | [0]{}: extra_field 0x78-0x84.7 (13) +0x0070| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x78-0x79.7 (2) +0x0070| 09 00 | .. | data_size: 9 0x7a-0x7b.7 (2) +0x0070| 03 17 15 df| ....| data: raw bits 0x7c-0x84.7 (9) +0x0080|61 19 15 df 61 |a...a | + | | | [1]{}: extra_field 0x85-0x93.7 (15) +0x0080| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x85-0x86.7 (2) +0x0080| 0b 00 | .. | data_size: 11 0x87-0x88.7 (2) +0x0080| 01 04 f5 01 00 00 04| .......| data: raw bits 0x89-0x93.7 (11) +0x0090|14 00 00 00 |.... | + | | | [2]{}: extra_field 0x94-0xa7.7 (20) +0x0090| 01 00 | .. | header_id: 0x1 (ZIP64 extended information extra field) 0x94-0x95.7 (2) +0x0090| 10 00 | .. | data_size: 16 0x96-0x97.7 (2) +0x0090| 00 00 00 00 00 00 00 00| ........| uncompressed_size: 0 0x98-0x9f.7 (8) +0x00a0|00 00 00 00 00 00 00 00 |........ | compressed_size: 0 0xa0-0xa7.7 (8) + | | | uncompressed: raw bits 0xa8-NA (0) + | | | [2]{}: local_file 0xa8-0x105.7 (94) +0x00a0| 50 4b 03 04 | PK.. | signature: raw bits (valid) 0xa8-0xab.7 (4) +0x00a0| 2d 00 | -. | version_needed: 45 0xac-0xad.7 (2) + | | | flags{}: 0xae-0xaf.7 (2) +0x00a0| 00 | . | unused0: 0 0xae-0xae (0.1) +0x00a0| 00 | . | strong_encryption: false 0xae.1-0xae.1 (0.1) +0x00a0| 00 | . | compressed_patched_data: false 0xae.2-0xae.2 (0.1) +0x00a0| 00 | . | enhanced_deflation: false 0xae.3-0xae.3 (0.1) +0x00a0| 00 | . | data_descriptor: false 0xae.4-0xae.4 (0.1) +0x00a0| 00 | . | compression0: false 0xae.5-0xae.5 (0.1) +0x00a0| 00 | . | compression1: false 0xae.6-0xae.6 (0.1) +0x00a0| 00 | . | encrypted: false 0xae.7-0xae.7 (0.1) +0x00a0| 00| .| reserved0: 0 0xaf-0xaf.1 (0.2) +0x00a0| 00| .| mask_header_values: false 0xaf.2-0xaf.2 (0.1) +0x00a0| 00| .| reserved1: false 0xaf.3-0xaf.3 (0.1) +0x00a0| 00| .| language_encoding: false 0xaf.4-0xaf.4 (0.1) +0x00a0| 00| .| unused1: 0 0xaf.5-0xaf.7 (0.3) +0x00b0|00 00 |.. | compression_method: "none" (0) 0xb0-0xb1.7 (2) + | | | last_modification_date{}: 0xb2-0xb3.7 (2) +0x00b0| 6a | j | hours: 13 0xb2-0xb2.4 (0.5) +0x00b0| 6a 96 | j. | minutes: 20 0xb2.5-0xb3.2 (0.6) +0x00b0| 96 | . | seconds: 22 0xb3.3-0xb3.7 (0.5) + | | | last_modification_time{}: 0xb4-0xb5.7 (2) +0x00b0| 2c | , | year: 22 0xb4-0xb4.6 (0.7) +0x00b0| 2c 54 | ,T | month: 2 0xb4.7-0xb5.2 (0.4) +0x00b0| 54 | T | day: 20 0xb5.3-0xb5.7 (0.5) +0x00b0| 45 e5 98 ad | E... | crc32_uncompressed: 0xad98e545 0xb6-0xb9.7 (4) +0x00b0| ff ff ff ff | .... | compressed_size: 4294967295 0xba-0xbd.7 (4) +0x00b0| ff ff| ..| uncompressed_size: 4294967295 0xbe-0xc1.7 (4) +0x00c0|ff ff |.. | +0x00c0| 0c 00 | .. | file_name_length: 12 0xc2-0xc3.7 (2) +0x00c0| 30 00 | 0. | extra_field_length: 48 0xc4-0xc5.7 (2) +0x00c0| 74 65 73 74 2f 61 2f 61 2e 74| test/a/a.t| file_name: "test/a/a.txt" 0xc6-0xd1.7 (12) +0x00d0|78 74 |xt | + | | | extra_fields[0:3]: 0xd2-0x101.7 (48) + | | | [0]{}: extra_field 0xd2-0xde.7 (13) +0x00d0| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0xd2-0xd3.7 (2) +0x00d0| 09 00 | .. | data_size: 9 0xd4-0xd5.7 (2) +0x00d0| 03 17 15 df 61 30 15 df 61 | ....a0..a | data: raw bits 0xd6-0xde.7 (9) + | | | [1]{}: extra_field 0xdf-0xed.7 (15) +0x00d0| 75| u| header_id: 0x7875 (UNIX UID/GID) 0xdf-0xe0.7 (2) +0x00e0|78 |x | +0x00e0| 0b 00 | .. | data_size: 11 0xe1-0xe2.7 (2) +0x00e0| 01 04 f5 01 00 00 04 14 00 00 00 | ........... | data: raw bits 0xe3-0xed.7 (11) + | | | [2]{}: extra_field 0xee-0x101.7 (20) +0x00e0| 01 00| ..| header_id: 0x1 (ZIP64 extended information extra field) 0xee-0xef.7 (2) +0x00f0|10 00 |.. | data_size: 16 0xf0-0xf1.7 (2) +0x00f0| 04 00 00 00 00 00 00 00 | ........ | uncompressed_size: 4 0xf2-0xf9.7 (8) +0x00f0| 04 00 00 00 00 00| ......| compressed_size: 4 0xfa-0x101.7 (8) +0x0100|00 00 |.. | +0x0100| 61 61 61 61 | aaaa | uncompressed: raw bits 0x102-0x105.7 (4) + | | | [3]{}: local_file 0x106-0x163.7 (94) +0x0100| 50 4b 03 04 | PK.. | signature: raw bits (valid) 0x106-0x109.7 (4) +0x0100| 2d 00 | -. | version_needed: 45 0x10a-0x10b.7 (2) + | | | flags{}: 0x10c-0x10d.7 (2) +0x0100| 00 | . | unused0: 0 0x10c-0x10c (0.1) +0x0100| 00 | . | strong_encryption: false 0x10c.1-0x10c.1 (0.1) +0x0100| 00 | . | compressed_patched_data: false 0x10c.2-0x10c.2 (0.1) +0x0100| 00 | . | enhanced_deflation: false 0x10c.3-0x10c.3 (0.1) +0x0100| 00 | . | data_descriptor: false 0x10c.4-0x10c.4 (0.1) +0x0100| 00 | . | compression0: false 0x10c.5-0x10c.5 (0.1) +0x0100| 00 | . | compression1: false 0x10c.6-0x10c.6 (0.1) +0x0100| 00 | . | encrypted: false 0x10c.7-0x10c.7 (0.1) +0x0100| 00 | . | reserved0: 0 0x10d-0x10d.1 (0.2) +0x0100| 00 | . | mask_header_values: false 0x10d.2-0x10d.2 (0.1) +0x0100| 00 | . | reserved1: false 0x10d.3-0x10d.3 (0.1) +0x0100| 00 | . | language_encoding: false 0x10d.4-0x10d.4 (0.1) +0x0100| 00 | . | unused1: 0 0x10d.5-0x10d.7 (0.3) +0x0100| 08 00| ..| compression_method: "deflated" (8) 0x10e-0x10f.7 (2) + | | | last_modification_date{}: 0x110-0x111.7 (2) +0x0110|6a |j | hours: 13 0x110-0x110.4 (0.5) +0x0110|6a 96 |j. | minutes: 20 0x110.5-0x111.2 (0.6) +0x0110| 96 | . | seconds: 22 0x111.3-0x111.7 (0.5) + | | | last_modification_time{}: 0x112-0x113.7 (2) +0x0110| 2c | , | year: 22 0x112-0x112.6 (0.7) +0x0110| 2c 54 | ,T | month: 2 0x112.7-0x113.2 (0.4) +0x0110| 54 | T | day: 20 0x113.3-0x113.7 (0.5) +0x0110| 2c 89 b3 aa | ,... | crc32_uncompressed: 0xaab3892c 0x114-0x117.7 (4) +0x0110| ff ff ff ff | .... | compressed_size: 4294967295 0x118-0x11b.7 (4) +0x0110| ff ff ff ff| ....| uncompressed_size: 4294967295 0x11c-0x11f.7 (4) +0x0120|0a 00 |.. | file_name_length: 10 0x120-0x121.7 (2) +0x0120| 30 00 | 0. | extra_field_length: 48 0x122-0x123.7 (2) +0x0120| 74 65 73 74 2f 61 2e 74 78 74 | test/a.txt | file_name: "test/a.txt" 0x124-0x12d.7 (10) + | | | extra_fields[0:3]: 0x12e-0x15d.7 (48) + | | | [0]{}: extra_field 0x12e-0x13a.7 (13) +0x0120| 55 54| UT| header_id: 0x5455 (extended timestamp) 0x12e-0x12f.7 (2) +0x0130|09 00 |.. | data_size: 9 0x130-0x131.7 (2) +0x0130| 03 17 15 df 61 2f 15 df 61 | ....a/..a | data: raw bits 0x132-0x13a.7 (9) + | | | [1]{}: extra_field 0x13b-0x149.7 (15) +0x0130| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x13b-0x13c.7 (2) +0x0130| 0b 00 | .. | data_size: 11 0x13d-0x13e.7 (2) +0x0130| 01| .| data: raw bits 0x13f-0x149.7 (11) +0x0140|04 f5 01 00 00 04 14 00 00 00 |.......... | + | | | [2]{}: extra_field 0x14a-0x15d.7 (20) +0x0140| 01 00 | .. | header_id: 0x1 (ZIP64 extended information extra field) 0x14a-0x14b.7 (2) +0x0140| 10 00 | .. | data_size: 16 0x14c-0x14d.7 (2) +0x0140| 35 00| 5.| uncompressed_size: 53 0x14e-0x155.7 (8) +0x0150|00 00 00 00 00 00 |...... | +0x0150| 06 00 00 00 00 00 00 00 | ........ | compressed_size: 6 0x156-0x15d.7 (8) + 0x000|61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|aaaaaaaaaaaaaaaa| uncompressed: raw bits 0x0-0x34.7 (53) + * |until 0x34.7 (end) (53) | | +0x0150| 4b 4c| KL| compressed: raw bits 0x15e-0x163.7 (6) +0x0160|24 03 00 00 |$... | + | | | [4]{}: local_file 0x164-0x28b.7 (296) +0x0160| 50 4b 03 04 | PK.. | signature: raw bits (valid) 0x164-0x167.7 (4) +0x0160| 2d 00 | -. | version_needed: 45 0x168-0x169.7 (2) + | | | flags{}: 0x16a-0x16b.7 (2) +0x0160| 00 | . | unused0: 0 0x16a-0x16a (0.1) +0x0160| 00 | . | strong_encryption: false 0x16a.1-0x16a.1 (0.1) +0x0160| 00 | . | compressed_patched_data: false 0x16a.2-0x16a.2 (0.1) +0x0160| 00 | . | enhanced_deflation: false 0x16a.3-0x16a.3 (0.1) +0x0160| 00 | . | data_descriptor: false 0x16a.4-0x16a.4 (0.1) +0x0160| 00 | . | compression0: false 0x16a.5-0x16a.5 (0.1) +0x0160| 00 | . | compression1: false 0x16a.6-0x16a.6 (0.1) +0x0160| 00 | . | encrypted: false 0x16a.7-0x16a.7 (0.1) +0x0160| 00 | . | reserved0: 0 0x16b-0x16b.1 (0.2) +0x0160| 00 | . | mask_header_values: false 0x16b.2-0x16b.2 (0.1) +0x0160| 00 | . | reserved1: false 0x16b.3-0x16b.3 (0.1) +0x0160| 00 | . | language_encoding: false 0x16b.4-0x16b.4 (0.1) +0x0160| 00 | . | unused1: 0 0x16b.5-0x16b.7 (0.3) +0x0160| 08 00 | .. | compression_method: "deflated" (8) 0x16c-0x16d.7 (2) + | | | last_modification_date{}: 0x16e-0x16f.7 (2) +0x0160| 6a | j | hours: 13 0x16e-0x16e.4 (0.5) +0x0160| 6a 96| j.| minutes: 20 0x16e.5-0x16f.2 (0.6) +0x0160| 96| .| seconds: 22 0x16f.3-0x16f.7 (0.5) + | | | last_modification_time{}: 0x170-0x171.7 (2) +0x0170|2c |, | year: 22 0x170-0x170.6 (0.7) +0x0170|2c 54 |,T | month: 2 0x170.7-0x171.2 (0.4) +0x0170| 54 | T | day: 20 0x171.3-0x171.7 (0.5) +0x0170| cd 66 90 fb | .f.. | crc32_uncompressed: 0xfb9066cd 0x172-0x175.7 (4) +0x0170| ff ff ff ff | .... | compressed_size: 4294967295 0x176-0x179.7 (4) +0x0170| ff ff ff ff | .... | uncompressed_size: 4294967295 0x17a-0x17d.7 (4) +0x0170| 0a 00| ..| file_name_length: 10 0x17e-0x17f.7 (2) +0x0180|30 00 |0. | extra_field_length: 48 0x180-0x181.7 (2) +0x0180| 74 65 73 74 2f 62 2e 70 6e 67 | test/b.png | file_name: "test/b.png" 0x182-0x18b.7 (10) + | | | extra_fields[0:3]: 0x18c-0x1bb.7 (48) + | | | [0]{}: extra_field 0x18c-0x198.7 (13) +0x0180| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x18c-0x18d.7 (2) +0x0180| 09 00| ..| data_size: 9 0x18e-0x18f.7 (2) +0x0190|03 17 15 df 61 30 15 df 61 |....a0..a | data: raw bits 0x190-0x198.7 (9) + | | | [1]{}: extra_field 0x199-0x1a7.7 (15) +0x0190| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x199-0x19a.7 (2) +0x0190| 0b 00 | .. | data_size: 11 0x19b-0x19c.7 (2) +0x0190| 01 04 f5| ...| data: raw bits 0x19d-0x1a7.7 (11) +0x01a0|01 00 00 04 14 00 00 00 |........ | + | | | [2]{}: extra_field 0x1a8-0x1bb.7 (20) +0x01a0| 01 00 | .. | header_id: 0x1 (ZIP64 extended information extra field) 0x1a8-0x1a9.7 (2) +0x01a0| 10 00 | .. | data_size: 16 0x1aa-0x1ab.7 (2) +0x01a0| 03 01 00 00| ....| uncompressed_size: 259 0x1ac-0x1b3.7 (8) +0x01b0|00 00 00 00 |.... | +0x01b0| d0 00 00 00 00 00 00 00 | ........ | compressed_size: 208 0x1b4-0x1bb.7 (8) + | | | uncompressed{}: (png) 0x0-0x102.7 (259) + 0x000|89 50 4e 47 0d 0a 1a 0a |.PNG.... | signature: raw bits (valid) 0x0-0x7.7 (8) + | | | chunks[0:9]: 0x8-0x102.7 (251) + | | | [0]{}: chunk 0x8-0x20.7 (25) + 0x000| 00 00 00 0d | .... | length: 13 0x8-0xb.7 (4) + 0x000| 49 48 44 52| IHDR| type: "IHDR" 0xc-0xf.7 (4) + 0x000| 49 | I | ancillary: false 0xc.3-0xc.3 (0.1) + 0x000| 48 | H | private: false 0xd.3-0xd.3 (0.1) + 0x000| 44 | D | reserved: false 0xe.3-0xe.3 (0.1) + 0x000| 52| R| safe_to_copy: true 0xf.3-0xf.3 (0.1) + 0x010|00 00 00 04 |.... | width: 4 0x10-0x13.7 (4) + 0x010| 00 00 00 04 | .... | height: 4 0x14-0x17.7 (4) + 0x010| 01 | . | bit_depth: 1 0x18-0x18.7 (1) + 0x010| 00 | . | color_type: "grayscale" (0) 0x19-0x19.7 (1) + 0x010| 00 | . | compression_method: "deflate" (0) 0x1a-0x1a.7 (1) + 0x010| 00 | . | filter_method: "adaptive_filtering" (0) 0x1b-0x1b.7 (1) + 0x010| 00 | . | interlace_method: "none" (0) 0x1c-0x1c.7 (1) + 0x010| 81 8a a3| ...| crc: 0x818aa3d3 (valid) 0x1d-0x20.7 (4) + 0x020|d3 |. | + | | | [1]{}: chunk 0x21-0x30.7 (16) + 0x020| 00 00 00 04 | .... | length: 4 0x21-0x24.7 (4) + 0x020| 67 41 4d 41 | gAMA | type: "gAMA" 0x25-0x28.7 (4) + 0x020| 67 | g | ancillary: false 0x25.3-0x25.3 (0.1) + 0x020| 41 | A | private: false 0x26.3-0x26.3 (0.1) + 0x020| 4d | M | reserved: false 0x27.3-0x27.3 (0.1) + 0x020| 41 | A | safe_to_copy: false 0x28.3-0x28.3 (0.1) + 0x020| 00 00 b1 8f | .... | value: 45455 0x29-0x2c.7 (4) + 0x020| 0b fc 61| ..a| crc: 0xbfc6105 (valid) 0x2d-0x30.7 (4) + 0x030|05 |. | + | | | [2]{}: chunk 0x31-0x5c.7 (44) + 0x030| 00 00 00 20 | ... | length: 32 0x31-0x34.7 (4) + 0x030| 63 48 52 4d | cHRM | type: "cHRM" 0x35-0x38.7 (4) + 0x030| 63 | c | ancillary: false 0x35.3-0x35.3 (0.1) + 0x030| 48 | H | private: false 0x36.3-0x36.3 (0.1) + 0x030| 52 | R | reserved: true 0x37.3-0x37.3 (0.1) + 0x030| 4d | M | safe_to_copy: false 0x38.3-0x38.3 (0.1) + 0x030| 00 00 7a 26 | ..z& | white_point_x: 31.27 0x39-0x3c.7 (4) + 0x030| 00 00 80| ...| white_point_y: 32.9 0x3d-0x40.7 (4) + 0x040|84 |. | + 0x040| 00 00 fa 00 | .... | red_x: 64 0x41-0x44.7 (4) + 0x040| 00 00 80 e8 | .... | red_y: 33 0x45-0x48.7 (4) + 0x040| 00 00 75 30 | ..u0 | green_x: 30 0x49-0x4c.7 (4) + 0x040| 00 00 ea| ...| green_y: 60 0x4d-0x50.7 (4) + 0x050|60 |` | + 0x050| 00 00 3a 98 | ..:. | blue_x: 15 0x51-0x54.7 (4) + 0x050| 00 00 17 70 | ...p | blue_y: 6 0x55-0x58.7 (4) + 0x050| 9c ba 51 3c | ..Q< | crc: 0x9cba513c (valid) 0x59-0x5c.7 (4) + | | | [3]{}: chunk 0x5d-0x6a.7 (14) + 0x050| 00 00 00| ...| length: 2 0x5d-0x60.7 (4) + 0x060|02 |. | + 0x060| 62 4b 47 44 | bKGD | type: "bKGD" 0x61-0x64.7 (4) + 0x060| 62 | b | ancillary: false 0x61.3-0x61.3 (0.1) + 0x060| 4b | K | private: false 0x62.3-0x62.3 (0.1) + 0x060| 47 | G | reserved: false 0x63.3-0x63.3 (0.1) + 0x060| 44 | D | safe_to_copy: false 0x64.3-0x64.3 (0.1) + 0x060| 00 01 | .. | gray: 1 0x65-0x66.7 (2) + 0x060| dd 8a 13 a4 | .... | crc: 0xdd8a13a4 (valid) 0x67-0x6a.7 (4) + | | | [4]{}: chunk 0x6b-0x7d.7 (19) + 0x060| 00 00 00 07 | .... | length: 7 0x6b-0x6e.7 (4) + 0x060| 74| t| type: "tIME" 0x6f-0x72.7 (4) + 0x070|49 4d 45 |IME | + 0x060| 74| t| ancillary: true 0x6f.3-0x6f.3 (0.1) + 0x070|49 |I | private: false 0x70.3-0x70.3 (0.1) + 0x070| 4d | M | reserved: false 0x71.3-0x71.3 (0.1) + 0x070| 45 | E | safe_to_copy: false 0x72.3-0x72.3 (0.1) + 0x070| 07 e5 0b 15 00 13 26 | ......& | data: raw bits 0x73-0x79.7 (7) + 0x070| 29 a8 72 42 | ).rB | crc: 0x29a87242 (valid) 0x7a-0x7d.7 (4) + | | | [5]{}: chunk 0x7e-0x94.7 (23) + 0x070| 00 00| ..| length: 11 0x7e-0x81.7 (4) + 0x080|00 0b |.. | + 0x080| 49 44 41 54 | IDAT | type: "IDAT" 0x82-0x85.7 (4) + 0x080| 49 | I | ancillary: false 0x82.3-0x82.3 (0.1) + 0x080| 44 | D | private: false 0x83.3-0x83.3 (0.1) + 0x080| 41 | A | reserved: false 0x84.3-0x84.3 (0.1) + 0x080| 54 | T | safe_to_copy: true 0x85.3-0x85.3 (0.1) + 0x080| 08 d7 63 60 80 00 00 00 08 00| ..c`......| data: raw bits 0x86-0x90.7 (11) + 0x090|01 |. | + 0x090| 2f 20 dd 31 | / .1 | crc: 0x2f20dd31 (valid) 0x91-0x94.7 (4) + | | | [6]{}: chunk 0x95-0xc5.7 (49) + 0x090| 00 00 00 25 | ...% | length: 37 0x95-0x98.7 (4) + 0x090| 74 45 58 74 | tEXt | type: "tEXt" 0x99-0x9c.7 (4) + 0x090| 74 | t | ancillary: true 0x99.3-0x99.3 (0.1) + 0x090| 45 | E | private: false 0x9a.3-0x9a.3 (0.1) + 0x090| 58 | X | reserved: true 0x9b.3-0x9b.3 (0.1) + 0x090| 74 | t | safe_to_copy: true 0x9c.3-0x9c.3 (0.1) + 0x090| 64 61 74| dat| keyword: "date:create" 0x9d-0xa8.7 (12) + 0x0a0|65 3a 63 72 65 61 74 65 00 |e:create. | + 0x0a0| 32 30 32 31 2d 31 31| 2021-11| text: "2021-11-21T00:19:38+00:00" 0xa9-0xc1.7 (25) + 0x0b0|2d 32 31 54 30 30 3a 31 39 3a 33 38 2b 30 30 3a|-21T00:19:38+00:| + 0x0c0|30 30 |00 | + 0x0c0| 53 9e 05 f4 | S... | crc: 0x539e05f4 (valid) 0xc2-0xc5.7 (4) + | | | [7]{}: chunk 0xc6-0xf6.7 (49) + 0x0c0| 00 00 00 25 | ...% | length: 37 0xc6-0xc9.7 (4) + 0x0c0| 74 45 58 74 | tEXt | type: "tEXt" 0xca-0xcd.7 (4) + 0x0c0| 74 | t | ancillary: true 0xca.3-0xca.3 (0.1) + 0x0c0| 45 | E | private: false 0xcb.3-0xcb.3 (0.1) + 0x0c0| 58 | X | reserved: true 0xcc.3-0xcc.3 (0.1) + 0x0c0| 74 | t | safe_to_copy: true 0xcd.3-0xcd.3 (0.1) + 0x0c0| 64 61| da| keyword: "date:modify" 0xce-0xd9.7 (12) + 0x0d0|74 65 3a 6d 6f 64 69 66 79 00 |te:modify. | + 0x0d0| 32 30 32 31 2d 31| 2021-1| text: "2021-11-21T00:19:38+00:00" 0xda-0xf2.7 (25) + 0x0e0|31 2d 32 31 54 30 30 3a 31 39 3a 33 38 2b 30 30|1-21T00:19:38+00| + 0x0f0|3a 30 30 |:00 | + 0x0f0| 22 c3 bd 48 | "..H | crc: 0x22c3bd48 (valid) 0xf3-0xf6.7 (4) + | | | [8]{}: chunk 0xf7-0x102.7 (12) + 0x0f0| 00 00 00 00 | .... | length: 0 0xf7-0xfa.7 (4) + 0x0f0| 49 45 4e 44 | IEND | type: "IEND" 0xfb-0xfe.7 (4) + 0x0f0| 49 | I | ancillary: false 0xfb.3-0xfb.3 (0.1) + 0x0f0| 45 | E | private: false 0xfc.3-0xfc.3 (0.1) + 0x0f0| 4e | N | reserved: false 0xfd.3-0xfd.3 (0.1) + 0x0f0| 44 | D | safe_to_copy: false 0xfe.3-0xfe.3 (0.1) + 0x0f0| ae| .| crc: 0xae426082 (valid) 0xff-0x102.7 (4) + 0x100|42 60 82| |B`.| | +0x01b0| eb 0c f0 73| ...s| compressed: raw bits 0x1bc-0x28b.7 (208) +0x01c0|e7 e5 92 e2 62 60 60 e0 f5 f4 70 09 02 d2 2c 20|....b``...p..., | +* |until 0x28b.7 (208) | | + | | | central_directories[0:5]: 0x28c-0x451.7 (454) + | | | [0]{}: central_directory 0x28c-0x2e2.7 (87) +0x0280| 50 4b 01 02| PK..| signature: raw bits (valid) 0x28c-0x28f.7 (4) +0x0290|1e 03 |.. | version_made_by: 798 0x290-0x291.7 (2) +0x0290| 0a 00 | .. | version_needed: 10 0x292-0x293.7 (2) + | | | flags{}: 0x294-0x295.7 (2) +0x0290| 00 | . | unused0: 0 0x294-0x294 (0.1) +0x0290| 00 | . | strong_encryption: false 0x294.1-0x294.1 (0.1) +0x0290| 00 | . | compressed_patched_data: false 0x294.2-0x294.2 (0.1) +0x0290| 00 | . | enhanced_deflation: false 0x294.3-0x294.3 (0.1) +0x0290| 00 | . | data_descriptor: false 0x294.4-0x294.4 (0.1) +0x0290| 00 | . | compression0: false 0x294.5-0x294.5 (0.1) +0x0290| 00 | . | compression1: false 0x294.6-0x294.6 (0.1) +0x0290| 00 | . | encrypted: false 0x294.7-0x294.7 (0.1) +0x0290| 00 | . | reserved0: 0 0x295-0x295.1 (0.2) +0x0290| 00 | . | mask_header_values: false 0x295.2-0x295.2 (0.1) +0x0290| 00 | . | reserved1: false 0x295.3-0x295.3 (0.1) +0x0290| 00 | . | language_encoding: false 0x295.4-0x295.4 (0.1) +0x0290| 00 | . | unused1: 0 0x295.5-0x295.7 (0.3) +0x0290| 00 00 | .. | compression_method: "none" (0) 0x296-0x297.7 (2) + | | | last_modification_date{}: 0x298-0x299.7 (2) +0x0290| 6a | j | hours: 13 0x298-0x298.4 (0.5) +0x0290| 6a 96 | j. | minutes: 20 0x298.5-0x299.2 (0.6) +0x0290| 96 | . | seconds: 22 0x299.3-0x299.7 (0.5) + | | | last_modification_time{}: 0x29a-0x29b.7 (2) +0x0290| 2c | , | year: 22 0x29a-0x29a.6 (0.7) +0x0290| 2c 54 | ,T | month: 2 0x29a.7-0x29b.2 (0.4) +0x0290| 54 | T | day: 20 0x29b.3-0x29b.7 (0.5) +0x0290| 00 00 00 00| ....| crc32_uncompressed: 0x0 0x29c-0x29f.7 (4) +0x02a0|00 00 00 00 |.... | compressed_size: 0 0x2a0-0x2a3.7 (4) +0x02a0| ff ff ff ff | .... | uncompressed_size: 4294967295 0x2a4-0x2a7.7 (4) +0x02a0| 05 00 | .. | file_name_length: 5 0x2a8-0x2a9.7 (2) +0x02a0| 24 00 | $. | extra_field_length: 36 0x2aa-0x2ab.7 (2) +0x02a0| 00 00 | .. | file_comment_length: 0 0x2ac-0x2ad.7 (2) +0x02a0| 00 00| ..| disk_number_where_file_starts: 0 0x2ae-0x2af.7 (2) +0x02b0|00 00 |.. | internal_file_attributes: 0 0x2b0-0x2b1.7 (2) +0x02b0| 10 00 ed 41 | ...A | external_file_attributes: 1106051088 0x2b2-0x2b5.7 (4) +0x02b0| 00 00 00 00 | .... | relative_offset_of_local_file_header: 0 0x2b6-0x2b9.7 (4) +0x02b0| 74 65 73 74 2f | test/ | file_name: "test/" 0x2ba-0x2be.7 (5) + | | | extra_fields[0:3]: 0x2bf-0x2e2.7 (36) + | | | [0]{}: extra_field 0x2bf-0x2c7.7 (9) +0x02b0| 55| U| header_id: 0x5455 (extended timestamp) 0x2bf-0x2c0.7 (2) +0x02c0|54 |T | +0x02c0| 05 00 | .. | data_size: 5 0x2c1-0x2c2.7 (2) +0x02c0| 03 17 15 df 61 | ....a | data: raw bits 0x2c3-0x2c7.7 (5) + | | | [1]{}: extra_field 0x2c8-0x2d6.7 (15) +0x02c0| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x2c8-0x2c9.7 (2) +0x02c0| 0b 00 | .. | data_size: 11 0x2ca-0x2cb.7 (2) +0x02c0| 01 04 f5 01| ....| data: raw bits 0x2cc-0x2d6.7 (11) +0x02d0|00 00 04 14 00 00 00 |....... | + | | | [2]{}: extra_field 0x2d7-0x2e2.7 (12) +0x02d0| 01 00 | .. | header_id: 0x1 (ZIP64 extended information extra field) 0x2d7-0x2d8.7 (2) +0x02d0| 08 00 | .. | data_size: 8 0x2d9-0x2da.7 (2) +0x02d0| 00 00 00 00 00| .....| uncompressed_size: 0 0x2db-0x2e2.7 (8) +0x02e0|00 00 00 |... | + | | | file_comment: "" 0x2e3-NA (0) + | | | [1]{}: central_directory 0x2e3-0x33b.7 (89) +0x02e0| 50 4b 01 02 | PK.. | signature: raw bits (valid) 0x2e3-0x2e6.7 (4) +0x02e0| 1e 03 | .. | version_made_by: 798 0x2e7-0x2e8.7 (2) +0x02e0| 0a 00 | .. | version_needed: 10 0x2e9-0x2ea.7 (2) + | | | flags{}: 0x2eb-0x2ec.7 (2) +0x02e0| 00 | . | unused0: 0 0x2eb-0x2eb (0.1) +0x02e0| 00 | . | strong_encryption: false 0x2eb.1-0x2eb.1 (0.1) +0x02e0| 00 | . | compressed_patched_data: false 0x2eb.2-0x2eb.2 (0.1) +0x02e0| 00 | . | enhanced_deflation: false 0x2eb.3-0x2eb.3 (0.1) +0x02e0| 00 | . | data_descriptor: false 0x2eb.4-0x2eb.4 (0.1) +0x02e0| 00 | . | compression0: false 0x2eb.5-0x2eb.5 (0.1) +0x02e0| 00 | . | compression1: false 0x2eb.6-0x2eb.6 (0.1) +0x02e0| 00 | . | encrypted: false 0x2eb.7-0x2eb.7 (0.1) +0x02e0| 00 | . | reserved0: 0 0x2ec-0x2ec.1 (0.2) +0x02e0| 00 | . | mask_header_values: false 0x2ec.2-0x2ec.2 (0.1) +0x02e0| 00 | . | reserved1: false 0x2ec.3-0x2ec.3 (0.1) +0x02e0| 00 | . | language_encoding: false 0x2ec.4-0x2ec.4 (0.1) +0x02e0| 00 | . | unused1: 0 0x2ec.5-0x2ec.7 (0.3) +0x02e0| 00 00 | .. | compression_method: "none" (0) 0x2ed-0x2ee.7 (2) + | | | last_modification_date{}: 0x2ef-0x2f0.7 (2) +0x02e0| 6a| j| hours: 13 0x2ef-0x2ef.4 (0.5) +0x02e0| 6a| j| minutes: 20 0x2ef.5-0x2f0.2 (0.6) +0x02f0|96 |. | +0x02f0|96 |. | seconds: 22 0x2f0.3-0x2f0.7 (0.5) + | | | last_modification_time{}: 0x2f1-0x2f2.7 (2) +0x02f0| 2c | , | year: 22 0x2f1-0x2f1.6 (0.7) +0x02f0| 2c 54 | ,T | month: 2 0x2f1.7-0x2f2.2 (0.4) +0x02f0| 54 | T | day: 20 0x2f2.3-0x2f2.7 (0.5) +0x02f0| 00 00 00 00 | .... | crc32_uncompressed: 0x0 0x2f3-0x2f6.7 (4) +0x02f0| 00 00 00 00 | .... | compressed_size: 0 0x2f7-0x2fa.7 (4) +0x02f0| ff ff ff ff | .... | uncompressed_size: 4294967295 0x2fb-0x2fe.7 (4) +0x02f0| 07| .| file_name_length: 7 0x2ff-0x300.7 (2) +0x0300|00 |. | +0x0300| 24 00 | $. | extra_field_length: 36 0x301-0x302.7 (2) +0x0300| 00 00 | .. | file_comment_length: 0 0x303-0x304.7 (2) +0x0300| 00 00 | .. | disk_number_where_file_starts: 0 0x305-0x306.7 (2) +0x0300| 00 00 | .. | internal_file_attributes: 0 0x307-0x308.7 (2) +0x0300| 10 00 ed 41 | ...A | external_file_attributes: 1106051088 0x309-0x30c.7 (4) +0x0300| 53 00 00| S..| relative_offset_of_local_file_header: 83 0x30d-0x310.7 (4) +0x0310|00 |. | +0x0310| 74 65 73 74 2f 61 2f | test/a/ | file_name: "test/a/" 0x311-0x317.7 (7) + | | | extra_fields[0:3]: 0x318-0x33b.7 (36) + | | | [0]{}: extra_field 0x318-0x320.7 (9) +0x0310| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x318-0x319.7 (2) +0x0310| 05 00 | .. | data_size: 5 0x31a-0x31b.7 (2) +0x0310| 03 17 15 df| ....| data: raw bits 0x31c-0x320.7 (5) +0x0320|61 |a | + | | | [1]{}: extra_field 0x321-0x32f.7 (15) +0x0320| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x321-0x322.7 (2) +0x0320| 0b 00 | .. | data_size: 11 0x323-0x324.7 (2) +0x0320| 01 04 f5 01 00 00 04 14 00 00 00| ...........| data: raw bits 0x325-0x32f.7 (11) + | | | [2]{}: extra_field 0x330-0x33b.7 (12) +0x0330|01 00 |.. | header_id: 0x1 (ZIP64 extended information extra field) 0x330-0x331.7 (2) +0x0330| 08 00 | .. | data_size: 8 0x332-0x333.7 (2) +0x0330| 00 00 00 00 00 00 00 00 | ........ | uncompressed_size: 0 0x334-0x33b.7 (8) + | | | file_comment: "" 0x33c-NA (0) + | | | [2]{}: central_directory 0x33c-0x399.7 (94) +0x0330| 50 4b 01 02| PK..| signature: raw bits (valid) 0x33c-0x33f.7 (4) +0x0340|1e 03 |.. | version_made_by: 798 0x340-0x341.7 (2) +0x0340| 2d 00 | -. | version_needed: 45 0x342-0x343.7 (2) + | | | flags{}: 0x344-0x345.7 (2) +0x0340| 00 | . | unused0: 0 0x344-0x344 (0.1) +0x0340| 00 | . | strong_encryption: false 0x344.1-0x344.1 (0.1) +0x0340| 00 | . | compressed_patched_data: false 0x344.2-0x344.2 (0.1) +0x0340| 00 | . | enhanced_deflation: false 0x344.3-0x344.3 (0.1) +0x0340| 00 | . | data_descriptor: false 0x344.4-0x344.4 (0.1) +0x0340| 00 | . | compression0: false 0x344.5-0x344.5 (0.1) +0x0340| 00 | . | compression1: false 0x344.6-0x344.6 (0.1) +0x0340| 00 | . | encrypted: false 0x344.7-0x344.7 (0.1) +0x0340| 00 | . | reserved0: 0 0x345-0x345.1 (0.2) +0x0340| 00 | . | mask_header_values: false 0x345.2-0x345.2 (0.1) +0x0340| 00 | . | reserved1: false 0x345.3-0x345.3 (0.1) +0x0340| 00 | . | language_encoding: false 0x345.4-0x345.4 (0.1) +0x0340| 00 | . | unused1: 0 0x345.5-0x345.7 (0.3) +0x0340| 00 00 | .. | compression_method: "none" (0) 0x346-0x347.7 (2) + | | | last_modification_date{}: 0x348-0x349.7 (2) +0x0340| 6a | j | hours: 13 0x348-0x348.4 (0.5) +0x0340| 6a 96 | j. | minutes: 20 0x348.5-0x349.2 (0.6) +0x0340| 96 | . | seconds: 22 0x349.3-0x349.7 (0.5) + | | | last_modification_time{}: 0x34a-0x34b.7 (2) +0x0340| 2c | , | year: 22 0x34a-0x34a.6 (0.7) +0x0340| 2c 54 | ,T | month: 2 0x34a.7-0x34b.2 (0.4) +0x0340| 54 | T | day: 20 0x34b.3-0x34b.7 (0.5) +0x0340| 45 e5 98 ad| E...| crc32_uncompressed: 0xad98e545 0x34c-0x34f.7 (4) +0x0350|04 00 00 00 |.... | compressed_size: 4 0x350-0x353.7 (4) +0x0350| ff ff ff ff | .... | uncompressed_size: 4294967295 0x354-0x357.7 (4) +0x0350| 0c 00 | .. | file_name_length: 12 0x358-0x359.7 (2) +0x0350| 24 00 | $. | extra_field_length: 36 0x35a-0x35b.7 (2) +0x0350| 00 00 | .. | file_comment_length: 0 0x35c-0x35d.7 (2) +0x0350| 00 00| ..| disk_number_where_file_starts: 0 0x35e-0x35f.7 (2) +0x0360|01 00 |.. | internal_file_attributes: 1 0x360-0x361.7 (2) +0x0360| 00 00 a4 81 | .... | external_file_attributes: 2175008768 0x362-0x365.7 (4) +0x0360| a8 00 00 00 | .... | relative_offset_of_local_file_header: 168 0x366-0x369.7 (4) +0x0360| 74 65 73 74 2f 61| test/a| file_name: "test/a/a.txt" 0x36a-0x375.7 (12) +0x0370|2f 61 2e 74 78 74 |/a.txt | + | | | extra_fields[0:3]: 0x376-0x399.7 (36) + | | | [0]{}: extra_field 0x376-0x37e.7 (9) +0x0370| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x376-0x377.7 (2) +0x0370| 05 00 | .. | data_size: 5 0x378-0x379.7 (2) +0x0370| 03 17 15 df 61 | ....a | data: raw bits 0x37a-0x37e.7 (5) + | | | [1]{}: extra_field 0x37f-0x38d.7 (15) +0x0370| 75| u| header_id: 0x7875 (UNIX UID/GID) 0x37f-0x380.7 (2) +0x0380|78 |x | +0x0380| 0b 00 | .. | data_size: 11 0x381-0x382.7 (2) +0x0380| 01 04 f5 01 00 00 04 14 00 00 00 | ........... | data: raw bits 0x383-0x38d.7 (11) + | | | [2]{}: extra_field 0x38e-0x399.7 (12) +0x0380| 01 00| ..| header_id: 0x1 (ZIP64 extended information extra field) 0x38e-0x38f.7 (2) +0x0390|08 00 |.. | data_size: 8 0x390-0x391.7 (2) +0x0390| 04 00 00 00 00 00 00 00 | ........ | uncompressed_size: 4 0x392-0x399.7 (8) + | | | file_comment: "" 0x39a-NA (0) + | | | [3]{}: central_directory 0x39a-0x3f5.7 (92) +0x0390| 50 4b 01 02 | PK.. | signature: raw bits (valid) 0x39a-0x39d.7 (4) +0x0390| 1e 03| ..| version_made_by: 798 0x39e-0x39f.7 (2) +0x03a0|2d 00 |-. | version_needed: 45 0x3a0-0x3a1.7 (2) + | | | flags{}: 0x3a2-0x3a3.7 (2) +0x03a0| 00 | . | unused0: 0 0x3a2-0x3a2 (0.1) +0x03a0| 00 | . | strong_encryption: false 0x3a2.1-0x3a2.1 (0.1) +0x03a0| 00 | . | compressed_patched_data: false 0x3a2.2-0x3a2.2 (0.1) +0x03a0| 00 | . | enhanced_deflation: false 0x3a2.3-0x3a2.3 (0.1) +0x03a0| 00 | . | data_descriptor: false 0x3a2.4-0x3a2.4 (0.1) +0x03a0| 00 | . | compression0: false 0x3a2.5-0x3a2.5 (0.1) +0x03a0| 00 | . | compression1: false 0x3a2.6-0x3a2.6 (0.1) +0x03a0| 00 | . | encrypted: false 0x3a2.7-0x3a2.7 (0.1) +0x03a0| 00 | . | reserved0: 0 0x3a3-0x3a3.1 (0.2) +0x03a0| 00 | . | mask_header_values: false 0x3a3.2-0x3a3.2 (0.1) +0x03a0| 00 | . | reserved1: false 0x3a3.3-0x3a3.3 (0.1) +0x03a0| 00 | . | language_encoding: false 0x3a3.4-0x3a3.4 (0.1) +0x03a0| 00 | . | unused1: 0 0x3a3.5-0x3a3.7 (0.3) +0x03a0| 08 00 | .. | compression_method: "deflated" (8) 0x3a4-0x3a5.7 (2) + | | | last_modification_date{}: 0x3a6-0x3a7.7 (2) +0x03a0| 6a | j | hours: 13 0x3a6-0x3a6.4 (0.5) +0x03a0| 6a 96 | j. | minutes: 20 0x3a6.5-0x3a7.2 (0.6) +0x03a0| 96 | . | seconds: 22 0x3a7.3-0x3a7.7 (0.5) + | | | last_modification_time{}: 0x3a8-0x3a9.7 (2) +0x03a0| 2c | , | year: 22 0x3a8-0x3a8.6 (0.7) +0x03a0| 2c 54 | ,T | month: 2 0x3a8.7-0x3a9.2 (0.4) +0x03a0| 54 | T | day: 20 0x3a9.3-0x3a9.7 (0.5) +0x03a0| 2c 89 b3 aa | ,... | crc32_uncompressed: 0xaab3892c 0x3aa-0x3ad.7 (4) +0x03a0| 06 00| ..| compressed_size: 6 0x3ae-0x3b1.7 (4) +0x03b0|00 00 |.. | +0x03b0| ff ff ff ff | .... | uncompressed_size: 4294967295 0x3b2-0x3b5.7 (4) +0x03b0| 0a 00 | .. | file_name_length: 10 0x3b6-0x3b7.7 (2) +0x03b0| 24 00 | $. | extra_field_length: 36 0x3b8-0x3b9.7 (2) +0x03b0| 00 00 | .. | file_comment_length: 0 0x3ba-0x3bb.7 (2) +0x03b0| 00 00 | .. | disk_number_where_file_starts: 0 0x3bc-0x3bd.7 (2) +0x03b0| 01 00| ..| internal_file_attributes: 1 0x3be-0x3bf.7 (2) +0x03c0|00 00 a4 81 |.... | external_file_attributes: 2175008768 0x3c0-0x3c3.7 (4) +0x03c0| 06 01 00 00 | .... | relative_offset_of_local_file_header: 262 0x3c4-0x3c7.7 (4) +0x03c0| 74 65 73 74 2f 61 2e 74| test/a.t| file_name: "test/a.txt" 0x3c8-0x3d1.7 (10) +0x03d0|78 74 |xt | + | | | extra_fields[0:3]: 0x3d2-0x3f5.7 (36) + | | | [0]{}: extra_field 0x3d2-0x3da.7 (9) +0x03d0| 55 54 | UT | header_id: 0x5455 (extended timestamp) 0x3d2-0x3d3.7 (2) +0x03d0| 05 00 | .. | data_size: 5 0x3d4-0x3d5.7 (2) +0x03d0| 03 17 15 df 61 | ....a | data: raw bits 0x3d6-0x3da.7 (5) + | | | [1]{}: extra_field 0x3db-0x3e9.7 (15) +0x03d0| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x3db-0x3dc.7 (2) +0x03d0| 0b 00 | .. | data_size: 11 0x3dd-0x3de.7 (2) +0x03d0| 01| .| data: raw bits 0x3df-0x3e9.7 (11) +0x03e0|04 f5 01 00 00 04 14 00 00 00 |.......... | + | | | [2]{}: extra_field 0x3ea-0x3f5.7 (12) +0x03e0| 01 00 | .. | header_id: 0x1 (ZIP64 extended information extra field) 0x3ea-0x3eb.7 (2) +0x03e0| 08 00 | .. | data_size: 8 0x3ec-0x3ed.7 (2) +0x03e0| 35 00| 5.| uncompressed_size: 53 0x3ee-0x3f5.7 (8) +0x03f0|00 00 00 00 00 00 |...... | + | | | file_comment: "" 0x3f6-NA (0) + | | | [4]{}: central_directory 0x3f6-0x451.7 (92) +0x03f0| 50 4b 01 02 | PK.. | signature: raw bits (valid) 0x3f6-0x3f9.7 (4) +0x03f0| 1e 03 | .. | version_made_by: 798 0x3fa-0x3fb.7 (2) +0x03f0| 2d 00 | -. | version_needed: 45 0x3fc-0x3fd.7 (2) + | | | flags{}: 0x3fe-0x3ff.7 (2) +0x03f0| 00 | . | unused0: 0 0x3fe-0x3fe (0.1) +0x03f0| 00 | . | strong_encryption: false 0x3fe.1-0x3fe.1 (0.1) +0x03f0| 00 | . | compressed_patched_data: false 0x3fe.2-0x3fe.2 (0.1) +0x03f0| 00 | . | enhanced_deflation: false 0x3fe.3-0x3fe.3 (0.1) +0x03f0| 00 | . | data_descriptor: false 0x3fe.4-0x3fe.4 (0.1) +0x03f0| 00 | . | compression0: false 0x3fe.5-0x3fe.5 (0.1) +0x03f0| 00 | . | compression1: false 0x3fe.6-0x3fe.6 (0.1) +0x03f0| 00 | . | encrypted: false 0x3fe.7-0x3fe.7 (0.1) +0x03f0| 00| .| reserved0: 0 0x3ff-0x3ff.1 (0.2) +0x03f0| 00| .| mask_header_values: false 0x3ff.2-0x3ff.2 (0.1) +0x03f0| 00| .| reserved1: false 0x3ff.3-0x3ff.3 (0.1) +0x03f0| 00| .| language_encoding: false 0x3ff.4-0x3ff.4 (0.1) +0x03f0| 00| .| unused1: 0 0x3ff.5-0x3ff.7 (0.3) +0x0400|08 00 |.. | compression_method: "deflated" (8) 0x400-0x401.7 (2) + | | | last_modification_date{}: 0x402-0x403.7 (2) +0x0400| 6a | j | hours: 13 0x402-0x402.4 (0.5) +0x0400| 6a 96 | j. | minutes: 20 0x402.5-0x403.2 (0.6) +0x0400| 96 | . | seconds: 22 0x403.3-0x403.7 (0.5) + | | | last_modification_time{}: 0x404-0x405.7 (2) +0x0400| 2c | , | year: 22 0x404-0x404.6 (0.7) +0x0400| 2c 54 | ,T | month: 2 0x404.7-0x405.2 (0.4) +0x0400| 54 | T | day: 20 0x405.3-0x405.7 (0.5) +0x0400| cd 66 90 fb | .f.. | crc32_uncompressed: 0xfb9066cd 0x406-0x409.7 (4) +0x0400| d0 00 00 00 | .... | compressed_size: 208 0x40a-0x40d.7 (4) +0x0400| ff ff| ..| uncompressed_size: 4294967295 0x40e-0x411.7 (4) +0x0410|ff ff |.. | +0x0410| 0a 00 | .. | file_name_length: 10 0x412-0x413.7 (2) +0x0410| 24 00 | $. | extra_field_length: 36 0x414-0x415.7 (2) +0x0410| 00 00 | .. | file_comment_length: 0 0x416-0x417.7 (2) +0x0410| 00 00 | .. | disk_number_where_file_starts: 0 0x418-0x419.7 (2) +0x0410| 00 00 | .. | internal_file_attributes: 0 0x41a-0x41b.7 (2) +0x0410| 00 00 a4 81| ....| external_file_attributes: 2175008768 0x41c-0x41f.7 (4) +0x0420|64 01 00 00 |d... | relative_offset_of_local_file_header: 356 0x420-0x423.7 (4) +0x0420| 74 65 73 74 2f 62 2e 70 6e 67 | test/b.png | file_name: "test/b.png" 0x424-0x42d.7 (10) + | | | extra_fields[0:3]: 0x42e-0x451.7 (36) + | | | [0]{}: extra_field 0x42e-0x436.7 (9) +0x0420| 55 54| UT| header_id: 0x5455 (extended timestamp) 0x42e-0x42f.7 (2) +0x0430|05 00 |.. | data_size: 5 0x430-0x431.7 (2) +0x0430| 03 17 15 df 61 | ....a | data: raw bits 0x432-0x436.7 (5) + | | | [1]{}: extra_field 0x437-0x445.7 (15) +0x0430| 75 78 | ux | header_id: 0x7875 (UNIX UID/GID) 0x437-0x438.7 (2) +0x0430| 0b 00 | .. | data_size: 11 0x439-0x43a.7 (2) +0x0430| 01 04 f5 01 00| .....| data: raw bits 0x43b-0x445.7 (11) +0x0440|00 04 14 00 00 00 |...... | + | | | [2]{}: extra_field 0x446-0x451.7 (12) +0x0440| 01 00 | .. | header_id: 0x1 (ZIP64 extended information extra field) 0x446-0x447.7 (2) +0x0440| 08 00 | .. | data_size: 8 0x448-0x449.7 (2) +0x0440| 03 01 00 00 00 00| ......| uncompressed_size: 259 0x44a-0x451.7 (8) +0x0450|00 00 |.. | + | | | file_comment: "" 0x452-NA (0) + | | | end_of_central_directory_record_zip64{}: 0x452-0x489.7 (56) +0x0450| 50 4b 06 06 | PK.. | signature: raw bits (valid) 0x452-0x455.7 (4) +0x0450| 2c 00 00 00 00 00 00 00 | ,....... | size_of_end_of_central_directory: 44 0x456-0x45d.7 (8) +0x0450| 1e 03| ..| version_made_by: 798 0x45e-0x45f.7 (2) +0x0460|2d 00 |-. | version_needed_to_extract: 45 0x460-0x461.7 (2) +0x0460| 00 00 00 00 | .... | disk_nr: 0 0x462-0x465.7 (4) +0x0460| 00 00 00 00 | .... | central_directory_start_disk_nr: 0 0x466-0x469.7 (4) +0x0460| 05 00 00 00 00 00| ......| nr_of_central_directory_records_on_disk: 5 0x46a-0x471.7 (8) +0x0470|00 00 |.. | +0x0470| 05 00 00 00 00 00 00 00 | ........ | nr_of_central_directory_records: 5 0x472-0x479.7 (8) +0x0470| c6 01 00 00 00 00| ......| size_of_central_directory: 454 0x47a-0x481.7 (8) +0x0480|00 00 |.. | +0x0480| 8c 02 00 00 00 00 00 00 | ........ | offset_of_start_of_central_directory: 652 0x482-0x489.7 (8) + | | | end_of_central_directory_locator{}: 0x48a-0x49d.7 (20) +0x0480| 50 4b 06 07 | PK.. | signature: raw bits (valid) 0x48a-0x48d.7 (4) +0x0480| 00 00| ..| disk_nr: 0 0x48e-0x491.7 (4) +0x0490|00 00 |.. | +0x0490| 52 04 00 00 00 00 00 00 | R....... | offset_of_end_of_central_directory_record: 1106 0x492-0x499.7 (8) +0x0490| 01 00 00 00 | .... | total_disk_nr: 1 0x49a-0x49d.7 (4) + | | | end_of_central_directory_record{}: 0x49e-0x4b3.7 (22) +0x0490| 50 4b| PK| signature: raw bits (valid) 0x49e-0x4a1.7 (4) +0x04a0|05 06 |.. | +0x04a0| 00 00 | .. | disk_nr: 0 0x4a2-0x4a3.7 (2) +0x04a0| 00 00 | .. | central_directory_start_disk_nr: 0 0x4a4-0x4a5.7 (2) +0x04a0| 05 00 | .. | nr_of_central_directory_records_on_disk: 5 0x4a6-0x4a7.7 (2) +0x04a0| 05 00 | .. | nr_of_central_directory_records: 5 0x4a8-0x4a9.7 (2) +0x04a0| c6 01 00 00 | .... | size_of_central_directory: 454 0x4aa-0x4ad.7 (4) +0x04a0| ff ff| ..| offset_of_start_of_central_directory: 4294967295 0x4ae-0x4b1.7 (4) +0x04b0|ff ff |.. | +0x04b0| 00 00| | ..| | comment_length: 0 0x4b2-0x4b3.7 (2) + | | | comment: "" 0x4b4-NA (0) diff --git a/format/zip/testdata/test64.zip b/format/zip/testdata/test64.zip new file mode 100644 index 0000000000000000000000000000000000000000..35f062a1006fa1e420871c1132d22329ffb9778b GIT binary patch literal 1204 zcmWIWW@gc40D-J&Iw2tXKNPSs7%-Hi7MJLUhHx@4i;Lb*j16Z^Dy`sVU}X8q$iToN z0#wY%AOO;X0s?Rv$qq9z5n-q#&|s1cb$vQxEzF%f2tyO~N-9d=&NaYpG7HqPFgg(k zU{2-$hk{P$=2bA$x!|Uwn5~c9Y*VP&Y*5 zbdqgTjikh?D-se?Q4$h$jIB~}1_o243=H;oB_wQ^b?|^foI!f{0^Wco&6Bt9wl;pu zoBlyap?~j@%h#v=)!eSpykXX}E+zE^0^65&CvzPC`lN+Tp}n~=F#h2>#R*HJ9!UjG zniMf9Yii6Ct|byZJUu+6yu78oJkC5kYj||m_ULYDMESgRb$YMo2+ab96C;xxGZ)x*u+#|RfI^FvK?Uk-0fx7ZASN_zvO>}(MiSzH zDhCBWZe!U|j17hv3re5F8jQ$2pi~J;RUr5BKn(^(*^0BtLvjHsuhXz5jVd)dyY*3m6r7C2zfn1==Q($I8Qz&kC!%}B}HyfJ{NHY+~ xF+)NJ#AXE%KmenUfr17IdYB+IP#-&p6$A|ckaU1ID>y5$0(F7ZgWSi!004*PCqw`M literal 0 HcmV?d00001 diff --git a/format/zip/testdata/test9.fqtest b/format/zip/testdata/test9.fqtest index a7673006..19007d8f 100644 --- a/format/zip/testdata/test9.fqtest +++ b/format/zip/testdata/test9.fqtest @@ -597,13 +597,13 @@ $ fq -d zip dv test9.zip 0x03a0| 01 04 f5 01 00 00 04 14 00| .........| data: raw bits 0x3a7-0x3b1.7 (11) 0x03b0|00 00 |.. | | | | file_comment: "" 0x3b2-NA (0) - | | | end_of_central_directory{}: 0x3b2-0x3c7.7 (22) + | | | end_of_central_directory_record{}: 0x3b2-0x3c7.7 (22) 0x03b0| 50 4b 05 06 | PK.. | signature: raw bits (valid) 0x3b2-0x3b5.7 (4) 0x03b0| 00 00 | .. | disk_nr: 0 0x3b6-0x3b7.7 (2) 0x03b0| 00 00 | .. | central_directory_start_disk_nr: 0 0x3b8-0x3b9.7 (2) 0x03b0| 05 00 | .. | nr_of_central_directory_records_on_disk: 5 0x3ba-0x3bb.7 (2) 0x03b0| 05 00 | .. | nr_of_central_directory_records: 5 0x3bc-0x3bd.7 (2) -0x03b0| 8a 01| ..| size_of_central directory: 394 0x3be-0x3c1.7 (4) +0x03b0| 8a 01| ..| size_of_central_directory: 394 0x3be-0x3c1.7 (4) 0x03c0|00 00 |.. | 0x03c0| 28 02 00 00 | (... | offset_of_start_of_central_directory: 552 0x3c2-0x3c5.7 (4) 0x03c0| 00 00| | ..| | comment_length: 0 0x3c6-0x3c7.7 (2) diff --git a/format/zip/zip.go b/format/zip/zip.go index 0896b3bd..e26ab866 100644 --- a/format/zip/zip.go +++ b/format/zip/zip.go @@ -23,6 +23,9 @@ func init() { Description: "ZIP archive", Groups: []string{format.PROBE}, DecodeFn: zipDecode, + DecodeInArg: format.ZipIn{ + Uncompress: true, + }, Dependencies: []decode.Dependency{ {Names: []string{format.PROBE}, Group: &probeFormat}, }, @@ -66,35 +69,42 @@ var compressionMethodMap = scalar.UToSymStr{ } var ( - centralDirectorySignature = []byte("PK\x01\x02") - endOfCentralDirectorySignature = []byte("PK\x05\x06") - endOfCentralDirectorySignatureN = 0x06054b50 - localFileSignature = []byte("PK\x03\x04") - dataIndicatorSignature = []byte("PK\x07\x08") + centralDirectorySignature = []byte("PK\x01\x02") + endOfCentralDirectoryRecordSignature = []byte("PK\x05\x06") + endOfCentralDirectoryRecordSignatureN = 0x06054b50 + endOfCentralDirectoryRecord64Signature = []byte("PK\x06\x06") + endOfCentralDirectoryLocatorSignature = []byte("PK\x06\x07") + endOfCentralDirectoryLocatorSignatureN = 0x07064b50 + localFileSignature = []byte("PK\x03\x04") + dataIndicatorSignature = []byte("PK\x07\x08") +) + +const ( + headerIDZip64ExtendedInformation = 0x001 ) var headerIDMap = scalar.UToDescription{ - 0x0001: "ZIP64 extended information extra field", - 0x0007: "AV Info", - 0x0009: "OS/2 extended attributes", - 0x000a: "NTFS (Win9x/WinNT FileTimes)", - 0x000c: "OpenVMS", - 0x000d: "Unix", - 0x000f: "Patch Descriptor", - 0x0014: "PKCS#7 Store for X.509 Certificates", - 0x0015: "X.509 Certificate ID and Signature for individual file", - 0x0016: "X.509 Certificate ID for Central Directory", - 0x0065: "IBM S/390 attributes - uncompressed", - 0x0066: "IBM S/390 attributes - compressed", - 0x07c8: "Info-ZIP Macintosh (old, J. Lee)", - 0x2605: "ZipIt Macintosh (first version)", - 0x2705: "ZipIt Macintosh v 1.3.5 and newer (w/o full filename)", - 0x334d: "Info-ZIP Macintosh (new, D. Haase's 'Mac3' field )", - 0x4154: "Tandem NSK", - 0x4341: "Acorn/SparkFS (David Pilling)", - 0x4453: "Windows NT security descriptor (binary ACL)", - 0x4704: "VM/CMS", - 0x470f: "MVS", + headerIDZip64ExtendedInformation: "ZIP64 extended information extra field", + 0x0007: "AV Info", + 0x0009: "OS/2 extended attributes", + 0x000a: "NTFS (Win9x/WinNT FileTimes)", + 0x000c: "OpenVMS", + 0x000d: "Unix", + 0x000f: "Patch Descriptor", + 0x0014: "PKCS#7 Store for X.509 Certificates", + 0x0015: "X.509 Certificate ID and Signature for individual file", + 0x0016: "X.509 Certificate ID for Central Directory", + 0x0065: "IBM S/390 attributes - uncompressed", + 0x0066: "IBM S/390 attributes - compressed", + 0x07c8: "Info-ZIP Macintosh (old, J. Lee)", + 0x2605: "ZipIt Macintosh (first version)", + 0x2705: "ZipIt Macintosh v 1.3.5 and newer (w/o full filename)", + 0x334d: "Info-ZIP Macintosh (new, D. Haase's 'Mac3' field )", + 0x4154: "Tandem NSK", + 0x4341: "Acorn/SparkFS (David Pilling)", + 0x4453: "Windows NT security descriptor (binary ACL)", + 0x4704: "VM/CMS", + 0x470f: "MVS", // "inofficial" in original table //nolint:misspell 0x4854: "Theos, old inofficial port", @@ -129,6 +139,8 @@ func fieldMSDOSDate(d *decode.D) { } func zipDecode(d *decode.D, in any) any { + zi, _ := in.(format.ZipIn) + // TODO: just decode instead? if !bytes.Equal(d.PeekBytes(4), []byte("PK\x03\x04")) { d.Errorf("expected PK header") @@ -140,7 +152,7 @@ func zipDecode(d *decode.D, in any) any { // TODO: better EOCD probe p, _, err := d.TryPeekFind(32, -8, -10000, func(v uint64) bool { - return v == uint64(endOfCentralDirectorySignatureN) + return v == uint64(endOfCentralDirectoryRecordSignatureN) }) if err != nil { d.Fatalf("can't find end of central directory") @@ -151,18 +163,61 @@ func zipDecode(d *decode.D, in any) any { var sizeCD uint64 var diskNr uint64 - d.FieldStruct("end_of_central_directory", func(d *decode.D) { - d.FieldRawLen("signature", 4*8, d.AssertBitBuf(endOfCentralDirectorySignature)) + d.FieldStruct("end_of_central_directory_record", func(d *decode.D) { + d.FieldRawLen("signature", 4*8, d.AssertBitBuf(endOfCentralDirectoryRecordSignature)) diskNr = d.FieldU16("disk_nr") d.FieldU16("central_directory_start_disk_nr") d.FieldU16("nr_of_central_directory_records_on_disk") d.FieldU16("nr_of_central_directory_records") - sizeCD = d.FieldU32("size_of_central directory") + sizeCD = d.FieldU32("size_of_central_directory") offsetCD = d.FieldU32("offset_of_start_of_central_directory") commentLength := d.FieldU16("comment_length") d.FieldUTF8("comment", int(commentLength)) }) + // there is a end of central directory locator, is zip64 + if offsetCD == 0xff_ff_ff_ff { + p, _, err := d.TryPeekFind(32, -8, -10000, func(v uint64) bool { + return v == uint64(endOfCentralDirectoryLocatorSignatureN) + }) + if err != nil { + d.Fatalf("can't find zip64 end of central directory") + } + d.SeekAbs(d.Len() + p) + + var offsetEOCD uint64 + d.FieldStruct("end_of_central_directory_locator", func(d *decode.D) { + d.FieldRawLen("signature", 4*8, d.AssertBitBuf(endOfCentralDirectoryLocatorSignature)) + diskNr = d.FieldU32("disk_nr") + offsetEOCD = d.FieldU64("offset_of_end_of_central_directory_record") + diskNr = d.FieldU32("total_disk_nr") + }) + + d.SeekAbs(int64(offsetEOCD) * 8) + d.FieldStruct("end_of_central_directory_record_zip64", func(d *decode.D) { + d.FieldRawLen("signature", 4*8, d.AssertBitBuf(endOfCentralDirectoryRecord64Signature)) + sizeEOCD := d.FieldU64("size_of_end_of_central_directory") + d.FieldU16("version_made_by") + d.FieldU16("version_needed_to_extract") + diskNr = d.FieldU32("disk_nr") + d.FieldU32("central_directory_start_disk_nr") + d.FieldU64("nr_of_central_directory_records_on_disk") + d.FieldU64("nr_of_central_directory_records") + sizeCD = d.FieldU64("size_of_central_directory") + offsetCD = d.FieldU64("offset_of_start_of_central_directory") + const sizeOfFixedFields = 44 + d.FramedFn(int64(sizeEOCD-sizeOfFixedFields)*8, func(d *decode.D) { + for !d.End() { + d.FieldStruct("extra_field", func(d *decode.D) { + d.FieldU16("header_id", headerIDMap, scalar.ActualHex) + dataSize := d.FieldU32("data_size") + d.FieldRawLen("data", int64(dataSize)*8) + }) + } + }) + }) + } + var localFileOffsets []uint64 d.SeekAbs(int64(offsetCD) * 8) @@ -208,9 +263,26 @@ func zipDecode(d *decode.D, in any) any { d.FramedFn(int64(extraFieldLength)*8, func(d *decode.D) { for !d.End() { d.FieldStruct("extra_field", func(d *decode.D) { - d.FieldU16("header_id", headerIDMap, scalar.ActualHex) + headerID := d.FieldU16("header_id", headerIDMap, scalar.ActualHex) dataSize := d.FieldU16("data_size") - d.FieldRawLen("data", int64(dataSize)*8) + d.FramedFn(int64(dataSize)*8, func(d *decode.D) { + switch headerID { + case headerIDZip64ExtendedInformation: + d.FieldU64("uncompressed_size") + // TODO: spec says these should be here but real zip64 seems to not have them? optional? + if !d.End() { + d.FieldU64("compressed_size") + } + if !d.End() { + localFileOffset = d.FieldU64("relative_offset_of_local_file_header") + } + if !d.End() { + d.FieldU32("disk_number_where_file_starts") + } + default: + d.FieldRawLen("data", int64(dataSize)*8) + } + }) }) } }) @@ -262,9 +334,20 @@ func zipDecode(d *decode.D, in any) any { d.FramedFn(int64(extraFieldLength)*8, func(d *decode.D) { for !d.End() { d.FieldStruct("extra_field", func(d *decode.D) { - d.FieldU16("header_id", headerIDMap, scalar.ActualHex) + headerID := d.FieldU16("header_id", headerIDMap, scalar.ActualHex) dataSize := d.FieldU16("data_size") - d.FieldRawLen("data", int64(dataSize)*8) + d.FramedFn(int64(dataSize)*8, func(d *decode.D) { + switch headerID { + case headerIDZip64ExtendedInformation: + d.FieldU64("uncompressed_size") + // TODO: spec says these should be here but real zip64 seems to not have them? optional? + if !d.End() { + compressedSizeBytes = d.FieldU64("compressed_size") + } + default: + d.FieldRawLen("data", int64(dataSize)*8) + } + }) }) } }) @@ -281,11 +364,13 @@ func zipDecode(d *decode.D, in any) any { d.FieldFormatOrRawLen("uncompressed", compressedSize, probeFormat, nil) } else { var rFn func(r io.Reader) io.Reader - switch compressionMethod { - case compressionMethodDeflated: - // bitio.NewIOReadSeeker implements io.ByteReader so that deflate don't do own - // buffering and might read more than needed messing up knowing compressed size - rFn = func(r io.Reader) io.Reader { return flate.NewReader(r) } + if zi.Uncompress { + switch compressionMethod { + case compressionMethodDeflated: + // bitio.NewIOReadSeeker implements io.ByteReader so that deflate don't do own + // buffering and might read more than needed messing up knowing compressed size + rFn = func(r io.Reader) io.Reader { return flate.NewReader(r) } + } } if rFn != nil {