0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

pico2024 WinAntiDbg0x300 Writeup

Last updated at Posted at 2025-02-21

はじめに

初期にデバッカーを起動していてもしてなくても検知しているとしてループから抜け出せない仕様

Windbgは使わなくてもクリアできたらしいです。
https://youtu.be/AKYwzmRcLtw?si=lQ7gdsD5XCmG77Rt
をみて学びました

手順

picoCTFより実行ファイルをダウンロードする。
ファイルとして .exe, .pdb, .configがある。

  • pdbファイル : 実行ファイルの関数情報等が記載された解析補助ファイル?
  • config : これを使用して起動しているらしい。

upxのアンパック

ファイルがupxでパッキングされているため
https://github.com/upx/upx/releases/tag/v5.0.0
より
upx-5.0.0-win64.zip
をダウンロードする。解凍すると.exeがあるので、Windowsのcmdを起動して同じフォルダに移動して以下を実行。
私はパス指定があれだったので同階層にCTFのファイルをすべて移動してしまいました。

upx.exe -d WinAntiDbg0x300.exe

また、Linuxのupx -dで解凍してしまうとWindowsで実行できなくなる。

ghidraを用いた解析

https://github.com/NationalSecurityAgency/ghidra

To install an official pre-built multi-platform Ghidra release:
Install JDK 21 64-bit
Download a Ghidra release file
NOTE: The official multi-platform release file is named ghidra_<version>_<release>_<date>.zip which can be found under the "Assets" drop-down. Downloading either of the files named "Source Code" is not correct for this step.

を見て、
https://adoptium.net/temurin/releases/
のWindows用の.msi形式のファイルをダウンロードして実行する。
https://github.com/NationalSecurityAgency/ghidra/releases
より
ghidra_11.3.1_PUBLIC_20250219.zipのような最新のファイルをダウンロードする。
ファイル内の.BAT(バッチファイル)を実行する。

projectを新規作成し、import fileからWinAntiDbg0x300.exeを読み込むがこの時に、アナライズは実行しない。
スクリーンショット (35).png

次に、File > Load PDB file > ファイルを選択してロードする。
スクリーンショット (36).png

この時点でwinMain関数が見れる状態になる。
winMain関数の逆コンパイル結果に以下のようにあるので、

local_8 = CreateThread(0,0,ChallengeThreadFunction,0,0,0);

ChallengeThreadFunctionをクリックしてChallengeThreadFunctionに飛ぶ。
この関数は問答無用で5秒ごとにループしているので、これを無効化する。
スクリーンショット (38).png
NOPを入れる
JMP命令を右クリックし、Clear > Clear Code Bytesをクリック。
スクリーンショット (39).png

その後空白になったところ5か所に、Ctrl+Shift+Gまたは、右クリックしてPatchInstructionを選択して、NOP命令に書き換える。
スクリーンショット (40).png

次に、完成したファイルを書き出す
File > Export program > Formatはoriginalで任意の場所に出力する。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?