ZIP File Structure

g0ni·2024년 10월 29일

ZIP File

목록 보기
1/2

ZIP 파일 구조


ZIP 파일의 경우 일반적인 구조로 크게 3개의 파일 구조를 가짐.
(Local File Header, Central Directory, End of Central Directory record)

  1. ZIP 파일을 최초 실행 시 먼저 End of Central Directory Record 로 이동.

  2. End of Central Directory Record 에 들어있는 값을 읽어 Central Directory file Header Offset 으로 이동.

  3. Central Directory Header 의 시작 위치부터 값을 따라 이동하며 내부에 존재하는 정보들을 통해서 Central Directory Header 의 개수 만큼 반복하여 Central 4. Directory 에 존재하는 Local Header Offset 에 들어있는 값을 확인하고, End of Central Directory 전 까지 정보를 읽음.

  4. 확인한 Local Header Offset 의 정보를 토대로 Local Header Offset 으로 이동.

  5. Local Header Offset 으로 이동한 뒤 정보를 읽어 해당되는 File Data 로 이동하고, zip 파일 사용자가 zip 파일 내부 압축 데이터를 확인할 수 있게 됨. (즉, 압축해제)

  6. Local Header의 개수만큼 N번 반복.


End of central directory record


offset 기준Bytedescription
0x00 ~ 0x034Signature 0x06054B50 (little endian) : 시그니쳐
0x04 ~ 0x052Disk Number : 파일이 존재하는 디스크 번호
0x06 ~ 0x072Disk # w/cd : central directory가 시작되는 disk의 개수
0x09 ~ 0x092Disk Entries : disk의 central directory의 개수
0xa ~ 0xb2Total Entries : central directory의 개수
0xc ~ 0xf4Central Directory Size : central directory의 크기
0x10 ~ 0x134Offset of cd wrt to starting disk : central directory 시작 offset
0x14 ~ 0x152Comment len : file comment 길이
0x16 ~ 0x16+nnZIP File Comment (Variable) : ZIP 파일 설명 (선택적)

Central Directory (Central Directory file header)


offset 기준Bytedescription
0x00 ~ 0x034Signature 0x02014B50 (little endian) : 시그니쳐
0x04 ~ 0x052Version : upper byte( ), lower byte(zip 사양 버전)
0x06 ~ 0x072Vers. needed : 압축 해제시 필요한 정보
0x08 ~ 0x092Flags : ZIP 파일에 대한 다양한 속성을 제어하는데 사용
0xa ~ 0xb2Compression method : ZIP 파일 내에서 사용된 압축 방식
0xc ~ 0xd2File modification time : 파일 수정 시간
0xe ~ 0xf2File modification date : 파일 수정 날짜
0x10 ~ 0x134Crc-32 checksum : crc-32 체크섬
0x14 ~ 0x174Compressed size : 압축 크기
0x18 ~ 0x1b4Uncompressed size : 원본 크기
0x1c ~ 0x1d2File name length : 파일 이름 길이
0x1e ~ 0x1f2Extra field length : 추가 필드 길이
0x20 ~ 0x212File comm. len : 파일 코맨트 길이
0x22 ~ 0x232Disk # start : 파일이 존재하는 디스크 번호
0x24 ~ 0x252Internal attr. : 내부 속성 값
0x26 ~ 0x294External attr. : 추가 파일 속성 값
0x2a ~ 0x2d4Offset of local header : local header 시작 offset
0x2e ~ 0x2e+nnFile name : 파일명
0x2e+n ~ 0x2e+mmExtra field : 추가 길이 필드 (선택적)
0x2e+m ~ 0x2e+m+kkFile comment : ZIP 파일 설명 (선택적)

Local File Header


offset 기준Bytedescription
0x00 ~ 0x034Signature 0x04034B50 (little endian) : 시그니쳐
0x04 ~ 0x052Version : unzip을 하기 위한 버전
0x06 ~ 0x072Flags : ZIP 파일에 대한 다양한 속성을 제어하는데 사용
0x08 ~ 0x092Compression method : ZIP 파일 내에서 사용된 압축 방식
0x0a ~ 0x0b2File modification time : 파일 수정 시간
0x0c ~ 0x0d2File modification date : 파일 수정 날짜
0x0e ~ 0x114Crc-32 checksum : crc-32 체크섬
0x12 ~ 0x154Compressed size : 압축 크기
0x16 ~ 0x194Uncompressed size : 원본 크기
0x1a ~ 0x1b2File name length : 파일 이름의 길이
0x1c ~ 0x1d2Extra field length : 추가 필드의 길이
0x1f ~ 0x2faFile name : 파일명 (선택적)
0x30 ~ 0x3fbExtra field : 추가 길이 필드 (선택적)

Flags


바이트 식별자
Bit 00암호화된 파일
Bit 01압축 옵션
Bit 02압축 옵션
Bit 03데이터 기술자
Bit 04강화된 디플레이션
Bit 05암축된 패치 데이터
Bit 06강력한 암호화
Bit 07-10-
Bit 11언어 인코딩
Bit 12예약
Bit 13헤더값을 마스크
Bit 14-15예약

Version


상위 바이트
00MS Dos and OS/2
01Amiga
02OpenVMS
03UNIX
04VM/CMS
05Atari ST
06OS/2 H.P.F.S.
07Macintosh
08Z-System
09CP/M
10Window NTFS
11MVS
12VSE
13Acorn Risc
14VFAT
15alternate MVS
16BeOS
17Tandem
18OS/400
19OS/X

Reference
https://lemonpoo22.tistory.com/13
https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html

profile
Let it rip!

0개의 댓글