Prob35 | xcz
(~정공법)
그래서 7-zip을 통해서 압축을 해제해보니
format_it을 hxd에 넣어보니 시그니쳐부터 png이라고 쓰여있는데 IEND가 없길래 49 45 4E 44를 추가하였다. 확장자 .png 를 추가하고 열어주니 flag.rar의 암호 도출
얻은 암호로 flag.rar을 풀어주니
(정공법)
zip파일 구조
local file header sig : 50 4B 03 04
central directory sig : 50 4B 01 02
end of central directory sig : 50 4B 05 06
end of central directory부터 읽어보자
디스크 파일 개수(E0 5~06 부분)을 보면 2개임을 확인할 수 있다. 또한, Central directory의 시작 오프셋(E0 0D~E부분)은 리틀-엔디안 방식으로 읽어주면 0D C7 임을 알 수 있다.
그러나, central directory의 file signature(50 4B 01 02)를 검색해보면 하나만 나온다. 이름모를 파일 하나가 누락되었음을 알 수 있다.
그럼 누락된 파일의 central directory를 작성해주기 위해
local과 central directory 구조에 대해서 알아보자
복구대상 파일의 local directory header
flag.rar보다 앞의 오프셋에 위치 => central directory도 flag.rar의 것보다 앞에 위치
- version 14 00
- flags 00 00
- compression method 08 00
- file modification time D2 BE
- file modification date 50 43
- crc-32 checksum EC BD 08 97
- compressed size 71 05 00 00
- uncompressed size 76 05 00 00
- file name length(2) 09 00
- extra field length(2) 08 00
- file name(9바이트) 00 00 00 00 00 00 00 00 00
- extra field(8바이트) 7A E5 04 00 B5 03 00 00 7D 94
flag.rar의 local directory header
- version 14 00
- flags 00 00
- compression method 08 00
- file modification time 00 BF
- file modification date 50 43
- crc-32 checksum BD A8 85 A1
- compressed size 01 08 00 00
- uncompressed size FC 07 00 00
- file name length 08 00
- extra field length 00 00
- file name(8바이트) 66 6C 61 67 2E 72 61 72
- extra field
flag.rar의 central directory header
- version 14 00
- vers. needed
- flags 00 00
- compression method 08 00
- file modification time 00 BF
- file modification date 50 43
- crc-32 checksum BD A8 85 A1
- compressed size 01 08 00 00
- uncompressed size FC 07 00 00
- file name length(2) 08 00
- extra field length(2) 00 00
- file comment length(2) 00 00
- disk # start (2) 00 00
- internal attr (2) 01 00
- external attr (4) 20 00 00 00
- offset of local header (4) A0 05 00 00
- file name (가변) 66 6C 61 67 2E 72 61 72
=> flag.rar파일의 local, central dir의 정보를 참고해보면 local과 central 의 정보가 겹치는 게 많다는 사실을 알 수 있다. 즉, 이름모를 파일의 local dir의 정보로 복구해주면 될 것 같다.
이제 복구해보자...
- signature 50 4B 01 02
- version 14 00
- vers. needed 14 00
- flags : 00 00
- compression method 08 00
- file modification time D2 BE
- file modification date 50 43
- crc-32 checksum EC BD 08 97
- compressed size 71 05 00 00
- uncompressed size 76 05 00 00
- file name length(2) 09 00
- extra field length(2) 08 00
- file comment length(2) 00 00
- disk # start (2) 00 00
- internal attr (2) 01 00
- external attr (4) 20 00 00 00
- offset of local header (4) 00 00 00 00
- file name (9바이트) 00 00 00 00 00 00 00 00 00
- extra field (8바이트) 7A E5 04 00 B5 03 00 00
- file comment (0바이트)
이렇게 하니 zip파일이 열리긴하는데 보여할 것이 보이지 아니한다.
extra field를 아예 지우면 다시 파일은 열리지 않는다. 이 상태로 ftk imager에서 파일을 열어보니
안의 pw가 도출된다. 이 pw를 가지고 flag.rar를 풀면 flag가 적힌 png파일이 나온다.