LoginSignup
0
0

More than 3 years have passed since last update.

[TryHackMe] Advent of Cyber 2, Day 21 - Walkthrough -

Last updated at Posted at 2020-12-22

本稿では、TryHackMeにて提供されている「Advent of Cyber 2」ルームに関する攻略方法(Walkthrough)について検証します。
「Advent of Cyber 2」は「free room」(無料)で提供されています。購読を必要とせずに仮想マシンを「展開(Deploy)」することができます。

『Advent of Cyber 2』のWalkthroughインデックスを「[TryHackMe] Advent of Cyber 2に参加してみた」にて公開しました。

[Day 21] Blue Teaming: Time for some ELForensics

ストーリー

little helpers」の一人がワークステーションにログインしたところ、データベースのコネクタファイルが差し替えられていることに気付き、いたずらリストを見つけることができなくなってしまいました。さらに、データベース・コネクタファイルを実行すると、そのファイルが別の場所に移動されたことを示すメッセージが表示されました。

エルフ・McEagerは通知を受け、データベース・コネクタファイルを探すためにピースをまとめます。

タスク

フォレンジックのような調査技術を使って、データベースのコネクタファイルが隠されている場所を探します。

Day 21 - #1.

Read the contents of the text file within the Documents folder. What is the file hash for db.exe?

CMDPowerShellのそれぞれにて調査してみます。

コマンドプロンプトにて、テキストファイルなどの内容を画面表示するにはTYPEコマンドが使用できます。

C:\Users\littlehelper\Documents>type "db file hash.txt"
Filename:       db.exe
MD5 Hash:       5966{BLOCKED}E3A1

PowerShellでは、Get-Contentコマンドレットが使用できます。

PS C:\Users\littlehelper\Documents> Get-Content -Path '.\db file hash.txt'
Filename:       db.exe
MD5 Hash:       5966{BLOCKED}E3A1

Day 21 - #2.

What is the file hash of the mysterious executable within the Documents folder?

コマンドプロンプトにて、ファイルのハッシュ値を計算するにはCertUtilコマンドが使用できます。

C:\Users\littlehelper\Documents>CertUtil -hashfile deebee.exe md5
MD5 hash of deebee.exe:
5f03{BLOCKED}09f0
CertUtil: -hashfile command completed successfully.

PowerShellでは、Get-FileHashコマンドレットが使用できます。

PS C:\Users\littlehelper\Documents> Get-FileHash -Algorithm MD5 .\deebee.exe

Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
MD5             5F03{BLOCKED}09F0                                       C:\Users\littlehelper\Documen...

Day 21 - #3.

Using Strings find the hidden flag within the executable?

Windows Sysinternalsの「Strings.exe」ユーティリティーを使用することで、バイナリに含まれる文字列を調べることが可能です。
また、findstrコマンドと組み合わせると、正規表現を使った柔軟な文字列検索を行うことができます。

c:\Tools>strings64.exe C:\Users\littlehelper\Documents\deebee.exe | findstr THM*
THM{f618{BLOCKED}b6f9}

PowerShellでは、Select-Stringコマンドレットと-Patternオプションが使用できます。

PS C:\Users\littlehelper\Documents> Select-String -Path .\deebee.exe -Pattern 'THM*'

意図した文字列のみ抽出するには、-Patternオプションの指定方法に工夫が必要です。
Select-String.png

Day 21 - #4.

What is the flag that is displayed when you run the database connector file?

NTFSファイルシステムには「代替データストリーム(ADS:Alternate Data Stream)」という機能があります。
コマンドプロンプトにて、代替データストリームの情報を表示するにはdirコマンドの/rオプションが使用できます。

Microsoft Windows [Version 10.0.17763.737]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\littlehelper\Documents>dir /r
 Volume in drive C has no label.
 Volume Serial Number is C2ED-B403

 Directory of C:\Users\littlehelper\Documents

11/23/2020  04:12 PM    <DIR>          .
11/23/2020  04:12 PM    <DIR>          ..
11/23/2020  11:21 AM                63 db file hash.txt
11/23/2020  11:22 AM             5,632 deebee.exe
                                 6,144 deebee.exe:hidedb:$DATA
               2 File(s)          5,695 bytes
               2 Dir(s)   4,928,839,680 bytes free

PowerShellでは、Get-Itemコマンドレットと-Streamオプションが使用できます。

PS C:\Users\littlehelper\Documents> Get-Item .\deebee.exe -Stream *


PSPath        : Microsoft.PowerShell.Core\FileSystem::C:\Users\littlehelper\Documents\deebee.exe::$DATA
PSParentPath  : Microsoft.PowerShell.Core\FileSystem::C:\Users\littlehelper\Documents
PSChildName   : deebee.exe::$DATA
PSDrive       : C
PSProvider    : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : False
FileName      : C:\Users\littlehelper\Documents\deebee.exe
Stream        : :$DATA
Length        : 5632

PSPath        : Microsoft.PowerShell.Core\FileSystem::C:\Users\littlehelper\Documents\deebee.exe:hidedb
PSParentPath  : Microsoft.PowerShell.Core\FileSystem::C:\Users\littlehelper\Documents
PSChildName   : deebee.exe:hidedb
PSDrive       : C
PSProvider    : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : False
FileName      : C:\Users\littlehelper\Documents\deebee.exe
Stream        : hidedb
Length        : 6144

代替データストリームに追加されている実行ファイルを起動させるには、wmic.exe(Windows Management Instrumentation Command Line)コマンドライン・ツールが使用できます。
コマンド構文は次のとおりです。

PS C:\Users\littlehelper\Documents> wmic process call create $(Resolve-Path .\deebee.exe:hidedb)
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ProcessId = 4804;
        ReturnValue = 0;
};

wmic.png

これにて、21日目のミッションが終了です。

参考情報

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