[THM][Note] Sysmon
https://tryhackme.com/room/sysmon
Task3
How many event ID 3 events are in C:\Users\THM-Analyst\Desktop\Scenarios\Practice\Filtering.evtx?
考え方)
Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Practice\Filtering.evtx -FilterXPath '*/System/EventID=3' | Measure-Object
これだとものすごく時間がかかるので、「Count」なんかをうまく使う方法を検討した方がいい。

以下の様にEvent Viewerからも確認できる。


Task6
Read the above and practice detecting Mimikatz with the provided evtx.
考え方)
- Get-WinEvent を使用する際に「Format-List」を覚えておくといい。以下のキャプチャーのようにEvent Viewerを開かなくても、プロパティの詳細が見れる。
PS> Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Practice\Hunting_Mimikatz.evtx -FilterXPath '*/System/EventID=10 and */EventData/Data[@Name="TargetImage"] and */EventData/Data="C:\Windows\system32\lsass.exe"' | Format-List -Property *

Task10
What is the full registry key of the USB device calling svchost.exe in Investigation 1?
考え方)
- 「レジストリ キーは何ですか? 」とあるので、Regstoryに関するイベントIDで絞る。
Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-1.evtx -FilterXPath '*/System/EventID=13' | Format-List -property *

What is the device name when being called by RawAccessRead in Investigation 1?
考え方)
- 指定されたevtxファイルには11行しかレコードがないので、とりあえず見てみる。
- Task Categoryの列に注目。
- 怪しいレコードの中身をチェック。

What is the first exe the process executes in Investigation 1?
考え方)
- 問題の意図が少し難しい。
- 要は、前の問題に引き続き、RawAccessReadがおこなわれた直後に実行されたexeはなんですか?と理解すればよい。
- プロセスが実行された時のTask Categoryに注目して時系列で対象のレコードを探す。

What is the full path of the payload in Investigation 2?
考え方)
- とりあえずログを一覧で見てみる。
PS> Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-2.evtx

- 3件しかないので、じっくりと見ていく。プロセス・クリエイトが2件、ネットワーク接続が1件。
- 一番古いイベントから確認。
PS C:\Windows\system32> (Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-2.evtx)[2] | Format-List -property *

- なにか色々書かれている。
- 次のイベントを確認する。
PS C:\Windows\system32> (Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-2.evtx)[1] | Format-List -property *

- この様に、2個めのイベントではどこかに通信(ポート: 4443)をしている。
- 最初のキャプチャーのログをよく見ると回答がわかる。TempやTmeporaryなどから実行されているプロセスは怪しい。
What is the full path of the file the payload masked itself as in Investigation 2?
考え方)
- 同じログ(一番古いイベント)から、IEから起動されている怪しくなさそうなファイルがあるのでそれを探す。
What is the IP of the adversary in Investigation 2?
What back connect port is used in Investigation 2?
考え方)
2つ目のネットワークのログをよく見る。「Destination」周りを確認する。
What is the IP of the suspected adversary in Investigation 3.1?
考え方)
- 一旦全部のログを見てみる。
PS> Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-3.1.evtx

- 全部で9件。
- 質問は「怪しいIP」なので3で絞る。
Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-3.1.evtx

- 一番古いログから見て、IPを探す。
(Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-3.1.evtx -FilterXpath '*/System/EventID=3')[0] | Format-List -property *
What is the hostname of the affected endpoint in Investigation 3.1?
考え方)
- 先程のログから端末名を探す。
What is the hostname of the C2 server connecting to the endpoint in Investigation 3.1?
考え方)
- 先程のログの「DestinationIp」に注目。
Where in the registry was the payload stored in Investigation 3.1?
考え方)
- 最初の9件のログを1つずつ見ていく。以下でヒット。
PS> (Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-3.1.evtx)[6] | Format-List -property *
What PowerShell launch code was used to launch the payload in Investigation 3.1?
考え方)
- 上記のログからいくつかログを遡って詳細を見ていくと、ペイロードを起動するためのPowerShellのコマンドがレジストリの中から見つかる。
What is the IP of the adversary in Investigation 3.2?
考え方)
- ログを一覧で見てみる。
PS> (Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-3.2.evtx)
- 結構ある

- カウントすると、24件。
PS> (Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-3.2.evtx).Count
- 一番古いログを見て、「DestinationIsIpv6」に注目。
PS> (Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-3.2.evtx)[23] | Format-List -property *
- 古いログから順に見ていくが、「Process Create」あたりで見つかる。
PS> (Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-3.2.evtx)[18] | Format-List -property *
What was the full command used to create the scheduled task in Investigation 3.2?
考え方)
- 同じく新しい方向に向かってログを見ていくと、更にProcessCreateが続く。
- その中で「schtask.exe」により、タスクにコマンドが登録されている。
What process was accessed by schtasks.exe that would be considered suspicious behavior in Investigation 3.2?
考え方)
- コマンドラインだと、「SourceImage」が、{b231f4ab-0305-5a78-0000-00101b276402}のような表記になっていて、ハマった。Event Viewerから探せばよかった。
- Event Viewerにて、schtask.exeでタスク登録されたあとのログを見ていく。
- ProcessCreateがいくつかあるので、詳細を確認する。
- schtasks.exeから実行されているプロセスが見つかる。

What is the IP of the adversary in Investigation 4?
考え方)
- ログを一覧で見てみると、13件ある。
PS> (Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-4.evtx)

- 一番古いログの「DestinationIsIpv6」を確認。
PS> (Get-WinEvent -Path C:\Users\THM-Analyst\Desktop\Scenarios\Investigations\Investigation-4.evtx)[12] | Format-List -property *
What port is the adversary operating on in Investigation 4?
考え方)
- 同じログの「DestinationHostname」を確認。
What C2 is the adversary utilizing in Investigation 4?
考え方)
- ログに出ているホスト名から探る。
- empirec2で検索。
