ファイル emoemotet.doc が与えられた。
テキストとしてファイルの中身を確認すると、Base64エンコードされているような文字列や、スクリプトのような文字列が見られた。
そこで、問題文にヒントとして示されていたページを参考に、Pythonのvirtualenvを用意して pip install oletools を実行した。
そして、olevba コマンドを用い、ファイルからスクリプトを抽出した。
抽出されたスクリプトを見ると、unxor 関数の呼び出しが並んでいた。
これは、Base64エンコードされた key の指定したオフセット以降のデータと指定した配列のデータをxorする関数であることが読み取れた。
そこで、
A file emoemotet.doc was given.
I tried to open the file with
Seeing the contents of the file as text, I found strings that looks like Base64-encoded and strings that looks like a part of a script.
Referring the page specified as a hint in the challenge descryption, I set up Python virtualenv and executed a command pip install oletools.
Then, I extracted a script from the file using olevba command.
Reading the extracted script, I found many calls of a function unxor.
This function performs exclusive-or of the input array and Base64-encoded key from the specified offset.
Seeing this, firstly I decoded the Base64 data used here using
From Base64, To Hex - CyberChef
次に、以下の手順により、unxor 関数の処理を再現した。
unxor 関数の呼び出しを2行目以降に入力する。
以下のRecipeは、CreateObject( と ).Run に挟まれている部分のデコードを行う。
Then, I simulated what the function unxor does in these steps:
unxor to simulate from the second line of the input.
This Recipe decodes the part between CreateObject( and ).Run.
結果は WScript.Shell となった。
行末のゴミを取り除く処理を追加した以下のRecipeは、Run の後の部分のデコードを行う。
The result was WScript.Shell.
This Recipe with a step to remove extra things in the end of lines added decoded the part after Run.
得られた結果にはBase64エンコードされているっぽい部分があったので、デコードを行った。
その結果は文字と . が交互になっていたので、UTF-16であると推測した。
The result had a part that looks like Base64-encoded, so I decoded that.
The result had . between each characters, so I guessed that the result is UTF-16.
From Base64, Decode text - CyberChef
結果はBase64エンコードされた文字列をデコードして解凍しているようだったので、同様の処理を行った。
The result looked like decoding a Base64-encoded string and expanding that, so I followed the process.
From Base64, Raw Inflate - CyberChef
この結果にflagが含まれていた。
The result contained the flag.