그 중에서 firmware에 손상이 있어 zip file구조에 대해서 공부를 하게 되었는데, 그때 정리 했던 내용을 다시 한번 정리 해보려고 한다.
본 그림은 zip파일에 파일 내부 구조 이며, local header1 : 50 4b 03 04 , Central header : 50 4b 01 02 , Central header Offset : 50 4b 05 06 을 갖는 것을 확인 할 수 있다.
위와 같이 50 4b는 PK
위와 같이 ASCII코드로 0x50 , 0x4b를 의미 한다.
그럼 이다음부턴 'PK' 하면 zip파일이라고 생각하자!
좀 더 자세히 구조를 글로 본다면 아래와 같이 정리 할 수 있다.
1. Local File Header(30byte: 가변값 제외)
local file header signature - 4 bytes - (0x04034b50) : 고유 값
version needed to extract - 2 bytes
general purpose bit flag - 2 bytes
compression method - 2 bytes
last mod file time - 2 bytes
last mod file date - 2 bytes
crc-32 - 4 bytes
compressed size - 4 bytes
uncompressed size - 4 bytes
file name length - 2 bytes
extra field length - 2 bytes
file name (variable size)
extra field (variable size)
2. Central File Header(46byte: 가변값 제외)
central file header signature - 4 bytes - (0x02014b50) : 고유 값
version made by - 2 bytes
version needed to extract - 2 bytes
general purpose bit flag - 2 bytes
compression method - 2 bytes
last mod file time - 2 bytes
last mod file date - 2 bytes
crc-32 - 4 bytes
compressed size - 4 bytes
uncompressed size - 4 bytes
file name length - 2 bytes
extra field length - 2 bytes
file comment length - 2 bytes
disk number start - 2 bytes
internal file attributes - 2 bytes
external file attributes - 4 bytes
relative offset of local header 4 bytes
file name (variable size)
extra field (variable size)
file comment (variable size)
local file header signature - 4 bytes - (0x04034b50) : 고유 값
version needed to extract - 2 bytes
general purpose bit flag - 2 bytes
compression method - 2 bytes
last mod file time - 2 bytes
last mod file date - 2 bytes
crc-32 - 4 bytes
compressed size - 4 bytes
uncompressed size - 4 bytes
file name length - 2 bytes
extra field length - 2 bytes
file name (variable size)
extra field (variable size)
2. Central File Header(46byte: 가변값 제외)
central file header signature - 4 bytes - (0x02014b50) : 고유 값
version made by - 2 bytes
version needed to extract - 2 bytes
general purpose bit flag - 2 bytes
compression method - 2 bytes
last mod file time - 2 bytes
last mod file date - 2 bytes
crc-32 - 4 bytes
compressed size - 4 bytes
uncompressed size - 4 bytes
file name length - 2 bytes
extra field length - 2 bytes
file comment length - 2 bytes
disk number start - 2 bytes
internal file attributes - 2 bytes
external file attributes - 4 bytes
relative offset of local header 4 bytes
file name (variable size)
extra field (variable size)
file comment (variable size)
3. End Header(22byte: comment 제외)
end of central dir signature - 4 bytes - (0x06054b50) : 고유값
number of this disk - 2 bytes
number of the disk with the start of the central directory - 2 bytes
total number of entries in the central directory on this disk - 2 bytes
total number of entries in the central directory - 2 bytes
size of the central directory - 4 bytes
offset of start of central directory with respect to the starting disk number - 4 bytes
.ZIP file comment length - 2 bytes
.ZIP file comment (variable size)
end of central dir signature - 4 bytes - (0x06054b50) : 고유값
number of this disk - 2 bytes
number of the disk with the start of the central directory - 2 bytes
total number of entries in the central directory on this disk - 2 bytes
total number of entries in the central directory - 2 bytes
size of the central directory - 4 bytes
offset of start of central directory with respect to the starting disk number - 4 bytes
.ZIP file comment length - 2 bytes
.ZIP file comment (variable size)
안드로이드 앱설치파일 확장자인 APK(Android PaKage)도 구조가 zip과 똑같다.(Android쪽 프로젝트 여서 확인 해본 결과 같은 구조를 가졌다.)
댓글 없음:
댓글 쓰기