Capture The Frog

かえるぴょこぴょこw

MENU

GhidraでMalware TechのCTF(Hade and Seek)

f:id:QWERTYtan:20211220212227p:plain

一通りアセンブラがそれぞれ何をしているか分かってきたので、練習がてらCTFを解いてみた。

Ghidraは、リバースエンジニアリングツールで.exe等の実行ファイルを逆アセンブル・逆コンパイルツールである。

まだ、インストールしていない人は↓から

ghidra-sre.org

 

今回は、このGhidraでMalware Techが公開しているCTFを解いていく。

www.malwaretech.com

まずは、[Hide and Seek]の

を解いていく。

 

下準備

まず、ghidraを立ち上げる。↓このような画面が出てくる。Tipsはcloseで消して、

Projectをstrings1という名前で作る。

f:id:QWERTYtan:20211202120937p:plain

すると、code browserが開く。

ghidraではここを使ってリバースエンジニアリングをしたものを見ていく。

f:id:QWERTYtan:20211202121500p:plain

この状態では、なんのプログラムを読み込んでいないため

左上の[File]→Import file→上でダウンロードしたstrings1.exe_を選択→AnalyseOK→Analyse→OK

で読み込む。

f:id:QWERTYtan:20211202121631p:plain

 

 

strings1.exe_

strings1.exe contains an un-encrypted flag stored within the executable. When run, the program will output an MD5 hash of the flag but not the original. Can you extract the flag?<https://www.malwaretech.com/challenges/windows-reversing/strings1抜粋>

 

ここから、MD5 hashでflagが書かれていることがわかる。

そのため、左のsymbol treeに関数がツリー状に書かれているのだが、ここの検索欄に

"hash"と入力する。(↓の黄色になっている部分)

すると、hashに関連する関数のみsymbol treeに表示される。

そこの md5_hashをクリックする。すると、真ん中のコード表示部分に青色でカバーがかかる。

ちなみに右には関数がある場合はその逆コンパイルしたものが書かれている。

そこから、下にしばらくスクロールしていくとflagが書かれている。

f:id:QWERTYtan:20211202120605p:plain

そのflagをさっきのサイトのflag提出欄にコピペして提出したら、success!と表示される。

f:id:QWERTYtan:20211202123039p:plain

 

 

string2.exe_

strings2.exe contains an un-encrypted flag stored within the executable. When run, the program will output an MD5 hash of the flag but not the original. Can you extract the flag?<https://www.malwaretech.com/challenges/windows-reversing/strings2抜粋>

 

string1.exe_と解き方は同じで、しかし今回はflagが16進数で書かれているので

それを16進数から文字にエンコードし直す必要がある。

f:id:QWERTYtan:20211202120702p:plain

f:id:QWERTYtan:20211202120738p:plain

flagのエンコードには、ここのサイトが役に立つ。

www.rapidtables.org

 

string3.exe_

strings3.exe contains an un-encrypted flag stored within the executable. When run, the program will output an MD5 hash of the flag but not the original. Can you extract the flag?<https://www.malwaretech.com/challenges/windows-reversing/strings3から抜粋>

 

ここまで、string1.exe_・string2.exe_と解いてて気づきましたか?

hash関数でflagが見つかりましたよね。

そこで、今回もhash*関数があるかなと思い検索してみると、ありません。

f:id:QWERTYtan:20211202142408p:plain

ここで、もう一つ気づきませんでしたか?

上まではhash*で検索していましたが、そのhash関数はentry関数の中で動いていますよね。

そこで、entry関数はないかなと思い検索しました。↓

f:id:QWERTYtan:20211202141428p:plain

すると、flagが見つかります。

f:id:QWERTYtan:20211202141514p:plain

 

次は、[Shellcode]分野のCTF

qwertytan.hatenablog.jp