onekey-sec / unblob

Extract files from any kind of container formats
https://unblob.org
Other
2.14k stars 81 forks source link

zip file being missidentified as zip64 #900

Closed nyuware closed 1 month ago

nyuware commented 1 month ago

We have identified a possibility for the zip handler to miss label a zip file (zip, zip64).

Its possible for a zip file to contain FFFF values (indicating it's a zip64) but it does not hold a zip64 End of Central Directory.

If that happens, the zip handler will just raise an InvalidInputFormat and skip the valid zip file

kissgyorgy commented 1 month ago

Here is how to make such a file:

$ cat somefile.txt | zip > zip64.zip
$ zip -F zip64.zip --out zip64-without-cd.zip
$ zipdetails zip64-without-cd.zip 

0000 LOCAL HEADER #1       04034B50
0004 Extract Zip Spec      2D '4.5'
0005 Extract OS            00 'MS-DOS'
0006 General Purpose Flag  0000
     [Bits 1-2]            0 'Normal Compression'
0008 Compression Method    0008 'Deflated'
000A Last Mod Time         58F75520 'Tue Jul 23 10:41:00 2024'
000E CRC                   79AADA01
0012 Compressed Length     FFFFFFFF
0016 Uncompressed Length   FFFFFFFF
001A Filename Length       0001
001C Extra Length          0014
001E Filename              '-'
001F Extra ID #0001        0001 'ZIP64'
0021   Length              0010
0023   Uncompressed Size   000000000000005E
002B   Compressed Size     000000000000004D
0033 PAYLOAD               -
                           .1..0...........R.....7&.|.9b...db....'.
                           ..`.JzQ.i......4..j..M..1..4...].S,/

0080 CENTRAL HEADER #1     02014B50
0084 Created Zip Spec      1E '3.0'
0085 Created OS            03 'Unix'
0086 Extract Zip Spec      2D '4.5'
0087 Extract OS            00 'MS-DOS'
0088 General Purpose Flag  0000
     [Bits 1-2]            0 'Normal Compression'
008A Compression Method    0008 'Deflated'
008C Last Mod Time         58F75520 'Tue Jul 23 10:41:00 2024'
0090 CRC                   79AADA01
0094 Compressed Length     0000004D
0098 Uncompressed Length   0000005E
009C Filename Length       0001
009E Extra Length          0000
00A0 Comment Length        0000
00A2 Disk Start            0000
00A4 Int File Attributes   0001
     [Bit 0]               1 Text Data
00A6 Ext File Attributes   11800000
00AA Local Header Offset   00000000
00AE Filename              '-'
ADD 0 77 CENTRAL HEADER ref Local #1: -

00AF END CENTRAL HEADER    06054B50
00B3 Number of this disk   0000
00B5 Central Dir Disk no   0000
00B7 Entries in this disk  0001
00B9 Total Entries         0001
00BB Size of Central Dir   0000002F
00BF Offset to Central Dir 00000080
00C3 Comment Length        0000
Done