partition02

partition01 で与えられたファイルについて、 flag画像がFLAG01とFLAG02に分割して入っているという情報が与えられた。

partition.img に strings コマンドをかけた結果から FLAG01 を検索すると、 見つかった場所の近くに flag01.png という文字列があり、さらにその近くに IHDR という文字列があった。
バイナリエディタで partition.img から文字列 IHDR を検索すると、0x4912400c に見つかり、0x49124000 からデータが始まっているようだった。
そこで、以下のように dd コマンドを用い、この場所から適当なサイズのデータを取り出した。

Regarding of the file given in partition01, information that a flag image is divided and put into FLAG01 and FLAG02 was given.

I searched for FLAG01 from the output of the strings command applied to partition.img, I found that there is a string flag01.png near the occurance of FLAG01, and that there is a string IHDR around there.
I seached for a string IHDR from partition.img using a binary editor. As a result, I found that at 0x4912400c and it looked like data is beginning from 0x49124000.
Seeing this, I extracted some data from there using the dd command in this way:

dd bs=512 skip=2394400 count=1024 if=..\partition01\partition.img of=first.bin

さらに、バイナリエディタで partition.img から文字列 IEND を検索すると、0x691279d2 に見つかった。
そこで、以下のように dd コマンドを用い、この場所を含む512バイトのブロックまでの適当なサイズのデータを取り出した。

After that, I searched for a string IEND from partition.img using a binary editor and found it at 0x691279d2.
Seeing this, I used the dd command to extract some data until the 512-byte block that contains the occurance in this way:

dd bs=512 skip=3441981 count=1024 if=..\partition01\partition.img of=second.bin

取り出した first.bin からバイナリエディタで 00 00 00 00 00 を検索すると、0x3c00 から大量のゼロが並んでいた。
取り出した second.bin の最後からバイナリエディタで 00 00 00 00 00 を検索すると、0x7c600 からゼロでないデータが始まっていることがわかった。
そこで、以下のように、これらのゼロでないデータを取り出して結合した。

I searched for 00 00 00 00 00 from the extracted file first.bin using a binary editor, finding that there are a lot of zeros from 0x3c00.
I searched for 00 00 00 00 00 from the extracted file second.bin using a binary editor, finding that non-zero data begins from 0x7c600.
Seeing these, I extracted these non-zero data and concatenated them using these commands:

dd if=first.bin count=30 bs=512 of=first-data.bin dd if=second.bin skip=995 bs=512 of=second-data.bin cat first-data.bin second-data.bin > recover.png

結合した結果は画像として閲覧することができ、flagが書かれていた。

The result of concatenation was enable to be opened as an image, and the flag was written there.

FLAG{you_found_flag_in_FLAGs}

WaniCTF 2021