ZIP central directory file header
Offset | Bytes | Description |
0 | 4 | Central directory file header signature = 0x02014b50 |
4 | 2 | Version made by |
6 | 2 | Version needed to extract (minimum) |
8 | 2 | General purpose bit flag |
10 | 2 | Compression method |
12 | 2 | File last modification time |
14 | 2 | File last modification date |
16 | 4 | CRC-32 |
20 | 4 | Compressed size |
24 | 4 | Uncompressed size |
28 | 2 | File name length (n) |
30 | 2 | Extra field length (m) |
32 | 2 | File comment length (k) |
34 | 2 | Disk number where file starts |
36 | 2 | Internal file attributes |
38 | 4 | External file attributes |
42 | 4 | Relative offset of local file header. This is the number of bytes between |
the start of the first disk on which the file occurs, and the start of | ||
the local file header. This allows software reading the central directory | ||
to locate the position of the file inside the ZIP file. | ||
46 | n | File name |
46+n | m | Extra field |
46+n+m | k | File comment |
첫번째 ZIP central directory file header 분석
$ xxd test.zip | grep -A 4 00000a0: 00000a0: 504b 0102 1e03 0a00 0000 0000 5189 093f PK..........Q..? 00000b0: b537 3c98 1000 0000 1000 0000 0600 1800 .7<............. 00000c0: 0000 0000 0000 0000 a481 0000 0000 6161 ..............aa 00000d0: 2e74 7874 5554 0500 0379 eb40 4e75 780b .txtUT...y.@Nux. 00000e0: 0001 04e8 0300 0004 6400 0000 504b 0102 ........d...PK..
Offset | Bytes | Description | |
0 | 4 | signature = 0x02014b50 | 504b 0102 |
4 | 2 | Version made by | 1e03 |
6 | 2 | Version needed to extract (minimum) | 0a00 |
8 | 2 | General purpose bit flag | 0000 |
10 | 2 | Compression method | 0000 |
12 | 2 | last modification time | 5189 |
14 | 2 | last modification date | 093f |
16 | 4 | CRC-32 | b537 3c98 |
20 | 4 | Compressed size | 1000 0000 |
24 | 4 | Uncompressed size | 1000 0000 |
28 | 2 | File name length (n) | 0600 |
30 | 2 | Extra field length (m) | 1800 |
32 | 2 | File comment length (k) | 0000 |
34 | 2 | Disk number where file starts | 0000 |
36 | 2 | Internal file attributes | 0000 |
38 | 4 | External file attributes | 0000 a481 |
42 | 4 | Relative offset of local file header | 0000 0000 |
46 | n | File name | 6161 2e74 7874 "aa.txt" |
46+n | m(0x18) | Extra field | |
5554 0500 0379 eb40 4e75 780b 0001 04e8 | |||
0300 0004 6400 0000 | |||
46+n+m | k(0x0) | File comment |
- 두번째 ZIP central directory file header 분석
$ xxd -s 0xec test.zip 00000ec: 504b 0102 1e03 0a00 0000 0000 6089 093f PK..........`..? 00000fc: b537 3c98 1000 0000 1000 0000 0600 1800 .7<............. 000010c: 0000 0000 0000 0000 a481 5000 0000 6262 ..........P...bb 000011c: 2e74 7874 5554 0500 0394 eb40 4e75 780b .txtUT.....@Nux. 000012c: 0001 04e8 0300 0004 6400 0000 504b 0506 ........d...PK.. ....
은 알아서들 해보시고^^
ZIP end of central directory record
Offset | Bytes | Description |
0 | 4 | End of central directory signature = 0x06054b50 |
4 | 2 | Number of this disk |
6 | 2 | Disk where central directory starts |
8 | 2 | Number of central directory records on this disk |
10 | 2 | Total number of central directory records |
12 | 4 | Size of central directory (bytes) |
16 | 4 | |
20 | 2 | ZIP file comment length (n) |
22 | n | ZIP file comment |
- ZIP end of central directory record 분석
$ xxd -s 0x138 test.zip 0000138: 504b 0506 0000 0000 0200 0200 9800 0000 PK.............. 0000148: a000 0000 0000 ......
Offset | Bytes | Description | |
0 | 4 | Signature = 0x06054b50 | 504b 0506 |
4 | 2 | Number of this disk | 0000 |
6 | 2 | Disk where central directory starts | 0000 |
8 | 2 | Number of central directory records on this disk | 0200 |
10 | 2 | Total number of central directory records | 0200 |
12 | 4 | Size of central directory (bytes) | 9800 0000 |
16 | 4 | Offset of start of central directory | a000 0000 |
20 | 2 | ZIP file comment length (n) | 0000 |
22 | n | ZIP file comment |
이제 대략적인 분석은 끝났으므로 다음에는 zip파일을 가지고 프로그래밍 해보시죠.