TryHackMe 歴1ヵ月半が参加する Advent of Cyber 2022 [Day 20]

20 日目。

[Day 20] Binwalkin’ around the Christmas tree

はじめに bin ディレクトリに移動して gpg コマンドで firmwarev2.2-encrypted.gpg を復号しようとすると secret key がないといわれるので、まずはその secret key を探すところから始まる。

ここからの流れは以下のようになる。

  • 暗号化されていない firmwarev1.0-unsigned を調べる
    • FMK(Firmware ModKit、今回は extract-firmware.sh として登場)を用いてイメージを抽出する
    • 鍵とそのパラフレーズがないか調べる(両方ある)
  • パラフレーズを用いて鍵を import する
  • firmwarev2.2-encrypted.gpg を復号する
  • 復号された firmwarev2.2-encrypted を調べる
    • FMK を用いてイメージを抽出する
    • rootfs ディレクトリを調べる

What is the flag value after reversing the file firmwarev2.2-encrypted.gpg?

まずは ~/bin-unsigned/ ディレクトリに移動し、FMK を実行する(extract-firmware.sh firmwarev1.0-unsigned、sudo パスは解説の通り Santa1010)。実行すると新たに fmk ディレクトリが生成され、その中に抽出されたファイル(?)が格納される。

解説の通り grep コマンドで調べるとどうやら ~/bin-unsigned/fmk/rootfs/gpg ディレクトリが怪しいので移動する。中身を見ると鍵とテキストファイルがあるので gpg --import private.key コマンドで鍵を import する(パスフレーズはテキスト内に記載されているものを使う。)

秘密鍵が import できたので ~/bin/ ディレクトリに移動し、gpg firmwarev2.2-encrypted.gpg コマンドで復号する(このとき再びパスフレーズを入力)。復号が終わると firmwarev2.2-encrypted が作成されるので今度はこれに含まれるイメージの抽出を FMK を用いて行う(extract-firmware.sh firmwarev2.2-encrypted)。抽出が終わると fmk ディレクトリができるので、あとは適当に flag を探す。

What is the Paraphrase value for the binary firmwarev1.0_unsigned?

先述の通り。テキストに書いてあったパラフレーズパスフレーズ)を答える。

After reversing the encrypted firmware, can you find the build number for rootfs?

rootfs ディレクトリ上で Hint の通り ls -lah * コマンドを使う。適当に grep コマンドを組み合わせても解答が見つかる。

Did you know we have a wonderful community on Discord? If you join us there, you can count on nice conversation, cyber security tips & tricks, and room help from our mods and mentors. Our Discord admin has some rooms out, too - you can try an easy one or a hard one!

No answer needed

感想

firmwarev1.0_unsignedfirmwarev2.2-encryptedファームウェア本体を指すと思ったのだがどうなのだろう。それらのファームウェアから〇〇を抽出する、みたいなイメージだったので所々にあった extract the firmware みたいな表現が気になった。それとなんで firmwarev1.0_unsigned に鍵やそのパスフレーズが書かれたテキストファイルがあったのかが謎。ご都合主義みたいな?