今天會分享 Boss Of The SOC v1 Q1 ~ Q10 的解題過程,解題平台會使用 CyberDefender,因為 Splunk 環境已經幫我們架設好了,也可以在平台上驗證答案的正確性。
本次實作實驗聚焦在 APT(高階持續性威脅)情境與勒索軟體情境。你將扮演 Alice Bluebird 的角色——剛被聘為 Wayne Enterprises 的 SOC 分析師,負責偵測與防禦各類網路攻擊。
今天是 Alice 在 Wayne Enterprises 安全部門(Security Operations Center,SOC)的第一天。Lucius 叫 Alice 坐下並給她第一個任務:一份來自高譚市警察局(Gotham City Police Department, GCPD)的備忘錄。GCPD 發現線上有證據(http://pastebin.com/Gw6dWjS9)顯示網站 www.imreallynotbatman.com 在 Wayne Enterprises 的 IP 位址空間內被入侵。該駭客組織有多重目標……但他們的作案手法之一是篡改網站以羞辱被害者。Lucius 要求 Alice 判定 www.imreallynotbatman.com(Wayne 企業執行長的個人部落格)是否確實遭到入侵。
在此情境中,使用者社群在瀏覽 Wayne Enterprises 網站時回報看到下列被篡改的圖片,且部分回報提到「P01s0n1vy」。若你不熟悉,P01s0n1vy 是一個曾針對 Wayne Enterprises 的 APT 組織。你作為 Alice 的目標是調查該網站篡改事件,並嘗試依照 Lockheed Martin Kill Chain 重建攻擊流程。
在第二個情境中,你的一位使用者在 Windows 桌面上看到一張圖片,表示系統上的檔案已被加密,必須付款才能取回檔案。看起來 Wayne Enterprises 有一台主機感染了 Cerber 勒索軟體,你的目標是調查這起勒索事件。
Q1 : This is a simple question to get you familiar with submitting answers. What is the name of the company that makes the software that you are using for this competition? Just a six-letter word with no punctuation.
因為題目給的環境是 Splunk,這邊回答 splunk 即可。
Ans : splunk
Q2 : Web Defacement: What content management system is imreallynotbatman.com likely using? (Please do not include punctuation such as . , ! ? in your answer. We are looking for alpha characters only.)
題目想要找出 imreallynotbatman.com
網站使用了什麼 CMS 系統。
因此我們會用到 Search 功能。
來到 Search & Report 頁面在 Search 欄位搜尋:
index="botsv1" imreallynotbatman.com
在 Splunk 收到日誌或事件後,會根據設定儲存在不同的 index
這段搜尋語法的意思是在資料索引為botsv1中,找出字串中包含 imreallynotbatman.com
。
data indexes 可以在 Setting-> DATA -> Index 中得知
看第一個 Log 就可以發現使用的是 joomla
。
ans :
joomla
Q3 : Web Defacement: What is the likely IP address of someone from the Po1s0n1vy group scanning imreallynotbatman.com for web application vulnerabilities?
接下來他想要找的是 Po1s0n1vy 用來掃描 imreallynotbatman.com 的 IP 是什麼?
有一個線索是知道這個 IP 有進行網頁漏洞掃描,有一個方向是我們可以使用在 Day17 提到的 Suricata,它會產生網路連接的 Log,因此我們搜尋的範圍可以限制在 Suricata 的 log 下,搜尋指令如下:
index=botsv1 sourcetype=suricata http.hostname=imreallynotbatman.com
然後我們想要專注的是來源 IP,因此我們會需要用到 table 語法,它可以將我們想要的欄位單獨拉出來做一張表格,讓我們可以專注在分析這個欄位上。
index=botsv1 sourcetype=suricata http.hostname=imreallynotbatman.com
| table src_ip
這邊我們獲得了每個 Suricata log 的來源 IP,接下來進行統計,因為我想要得到的是這個 IP 出現幾次,數量很多會有很高的機率是進行掃描,所以接下來會使用到 stats 語法,它提供了一些基本的統計功能。
index=botsv1 sourcetype=suricata http.hostname=imreallynotbatman.com
| table src_ip
| stats count by src_ip
這樣就看得出來答案就是 40.80.148.42
,另外如果想要數量由大排到小,可以使用 sort 語法,預設是由小排到大,加上 -
可以讓它變成由大排到小。
index=botsv1 sourcetype=suricata http.hostname=imreallynotbatman.com
| table src_ip
| stats count by src_ip
| sort -count reverse
ans :
40.80.148.42
Q4 : Web Defacement: What company created the web vulnerability scanner used by Po1s0n1vy? Type the company name. (For example, "Microsoft" or "Oracle")
這題想要搜尋到他們使用的 scanner 工具是什麼。
一樣我們可以使用 Suricata 工具,它除了可以產生網路連接 log 之外,還可以根據自訂規則產生警報,如抓到某個掃描工具的 Signature。
所以我們可以針對 Suricata 產生的 alert 去分析:
index=botsv1 sourcetype=suricata http.hostname=imreallynotbatman.com src_ip=40.80.148.42 alert
signature 欄位顯示偵測到的是什麼相關操作,因此我們用 table 專注去看 alert.signature 有沒有相關的線索:
index=botsv1 sourcetype=suricata http.hostname=imreallynotbatman.com src_ip=40.80.148.42 alert
| table alert.signature
接下來就可以找到這個 value:
ET SCAN Acunetix Accept HTTP Header detected scan in progress
可以看出 Acunetix 就是我們需要的答案。
ans : Acunetix
Q5 : Web Defacement: What IP address is likely attempting a brute force password attack against imreallynotbatman.com?
要找到哪個 IP 在對 imreallynotbatman.com 進行暴力破解。
需要對網站進行帳號密碼的暴力破解,會需要用到 POST 的 method,我們可以針對 POST 操作做查看,並且也會需要知道 POST 帶的資料,確認是不是在做暴力破解,查詢可以用以下指令:
index=botsv1 http_method=POST dest_ip=192.168.250.70 sourcetype=stream:http
| table src_ip, form_data, uri
sourcetype=stream:http
代表是拿 Splunk Stream app 所收集到並且屬於 HTTP 流量資料,而 dest_ip=192.168.250.70
是 imreallynotbatman.com 的 IP,在前幾題的操作可以得知。
這邊可以看出來是 23.22.63.114 在進行暴力破解。
ans : 23.22.63.114
Q6 : Web Defacement: What was the first brute force password used
這題要獲得第一個暴力破解嘗試的密碼。
這題可以使用 sort 將時間排序:
index=botsv1 http_method=POST dest_ip=192.168.250.70 sourcetype=stream:http src_ip=23.22.63.114
| table src_ip, form_data, uri _time
| sort _time
看到第一列的 password 參數是 12345678。
ans : 12345678
Q7 : Web Defacement: What is the name of the executable uploaded by Po1s0n1vy? Please include the file extension. (For example, "notepad.exe" or "favicon.ico")
這題要找的是 Po1s0n1vy 上傳的執行檔的檔名是什麼。
在 HTTP 中,如果上傳一個檔案會使用 multipart/form-data
,代表會將不同 type 的資料透過一次請求傳送出去,因此我們可以用 multipart/form-data
縮小我們的搜尋範圍,另外語法也支援 regex,在搜尋執行檔上比較方便:
index=botsv1 http_method=POST dest_ip=192.168.250.70 sourcetype=stream:http multipart/form-data *.exe
可以發現到上傳的執行檔檔名為 3791.exe。
ans : 3791.exe
Q8 : Web Defacement: What is the MD5 hash of the executable uploaded?
這題問 3791.exe 的 MD5 值是多少。
要取得 MD5 的值,會需要看關於 winlog 的紀錄,這邊會提到一個工具 - Sysmon,它會記錄系統內發生的重要事件,包含 Process Create、Network Connect、檔案建立與變更、Registry Modification。
以下是 Sysmon 的 Event ID:
Event ID | 說明 |
---|---|
1 | Process Create(程式啟動) |
2 | File creation time changed(時間戳被修改) |
3 | Network connection(TCP 連線) |
5 | Process Terminate(程式終止) |
6 | Driver Loaded(驅動載入) |
7 | Image Loaded(DLL載入) |
8 | CreateRemoteThread(遠端執行緒注入) |
9 | RawAccessRead(磁碟原始存取) |
10 | ProcessAccess(程式存取他人記憶體) |
11 | File Create(檔案建立) |
12 | Registry Key Create(註冊表鍵建立) |
13 | Registry Value Set(註冊表值修改) |
14 | Registry Key Delete(註冊表鍵刪除) |
15 | FileCreateStreamHash(建立 ADS) |
22 | DNS Query(DNS 查詢事件) |
23 | File Delete(檔案刪除) |
25 | Process Tampering(程式記憶體被修改) |
26 | File Deleted and Overwritten(防止取證) |
255 | Sysmon 設定被修改(Config change) |
其中 Event ID = 1 有 MD5 可以查看,那這樣我們就搜尋 3791.exe 的執行紀錄,獲得它的 MD5 值:
index=botsv1 source = WinEventLog:Microsoft-Windows-Sysmon/Operational 3791.exe EventCode=1
而我們專心看這個紀錄:
它的 ParentCommandLine 是 cmd.exe/c "3791.exe2>&1
,以及這邊顯示的 <DataName='Image'>C:\inetpub\wwwroot\joomla\3791.exe</Data><DataName='CommandLine'>3791.exe
,代表這個紀錄是關於 3791.exe 的資訊,所以往後面看它的 MD5 值是 AAE3F5A29935E6ABCC2C2754D12A9AF0。
ans : AAE3F5A29935E6ABCC2C2754D12A9AF0
Q9 : Web Defacement: What was the correct password for admin access to the content management system running "imreallynotbatman.com"?
這題想要問是哪個密碼成功進入了 imreallynotbatman.com。
我們可以在解 Q5 的時候知道登入的頁面是在 /joomla/administrator/index.php
,並且它是用暴力破解的方式嘗試登入系統,所以如果有一個密碼與其他登入次數比其他的還多就有可能會是正確的密碼,但是它的密碼是放在 form_data 欄位,這個欄位會包含其他的文字資訊,因此我們會需要用到 rex 語法:
index=botsv1 dest_ip=192.168.250.70 sourcetype=stream:http http_method=POST uri=/joomla/administrator/index.php
| rex field=form_data "passwd=(?<pass>\w+)"
| stats count by pass
rex 的欄位說明如下:
原本的 form_data 長這樣:
username=admin&task=login&return=aW5kZXgucGhw&option=com_login&passwd=topgun&49e63c55a9730eee52c7ea0448de3a01=1
因此它會提取 passwd=
後面的字串,直到碰到不是字母、數字或底線為止,然後它會變成單獨的 pass 欄位。
index=botsv1 dest_ip=192.168.250.70 sourcetype=stream:http http_method=POST uri=/joomla/administrator/index.php
| rex field=form_data "passwd=(?<pass>\w+)"
| stats count by pass
| sort -count
ans : batman
Q10 Web Defacement: What is the name of the file that defaced the imreallynotbatman.com website? Please submit only the name of the file with the extension (For example, "notepad.exe" or "favicon.ico").
題目想問是哪個檔案名稱污染了 imreallynotbatman.com 網頁。
這邊應該是想要問情境 1 當中進入網站出現一張圖片。
代表它之前可能會去下載過,因此可以用以下指令查詢它之前請求的頁面:
index=botsv1 sourcetype=stream:http src_ip=192.168.250.70
| table site src_headers
這邊可以看到它去一個網頁請求 poisonivy-is-coming-for-you-batman.jpeg
圖片,這個就是答案。
ans : poisonivy-is-coming-for-you-batman.jpeg
今天分享了 Boss Of The SOC v1 的 Q1 ~ Q10 的解題過程,當中分享了一些 Splunk 的用法以及 Threat Hunting 的過程,明天會繼續分享 Boss Of The SOC v1 剩餘題目。