ファイルが与えられた。
このファイルをdump.zip が得られた。
dump.zip をバイナリエディタで開くと、PKというデータが大量に入っているようだった。
そこで、PK\x03\x04 で始まるヘッダを抽出し、さらにファイルサイズを表す部分を抜き出した。
A file was given.
Opening this file with dump.zip.
Opening dump.zip with a binary editor, I found that there are a lot of strings PK.
Seeing this, I extracted headers beginning with PK\x03\x04 using
すると、最初の2ファイル (hello.txt および hi.txt) 以外は全て1バイトであることがわかった。
さらに、ファイル名の長さを抽出した。
As a result, I found that all of the files except for the first 2 files (hello.txt and hi.txt) are 1-byte long.
After that, I extracted the lengths of the names of the files.
その結果、hello.txt 以外は全て6バイトであることがわかった。
ファイルのデータを抽出すると、abcdefghijklmnopqrstuvwxyz{CTF0137}_ が繰り返されていた。
As a result, I found that all names except for hello.txt are 6-byte long.
Extracting the data of the files resulted in repeated abcdefghijklmnopqrstuvwxyz{CTF0137}_.
「PK\x03\x04から始まるヘッダとファイルのデータ」および「PK\x01\x02から始まるヘッダ」以外のデータが無いかをチェックしたところ、
ファイルの最後に PK\x05\x06 から始まるデータが繰り返されていることがわかった。
I also checked if there is any other data than "headers beginning with PK\x03\x04 and data of files" and "headers beginning with PK\x01\x02".
As a result, I found there is data beginning with PK\x05\x06 repeated at the end of the file.
To Hex, Regular expression - CyberChef
このデータを調査したところ、PK\x05\x06の16バイト先が、flagの文字のファイル中の位置に1を足した値になっているようであることがわかった。
そこで、この仮定に基づいてflagを抽出する以下のプログラムを作成した。
Investigating the data, I found that the values 16 bytes after PK\x05\x06 look like the offsets of the characters of the flag in the file plus one.
I created this program to extract the flag based on this finding.
このプログラムにより、flagが得られた。
I obtained the flag using this program.