Threat Hunting in Windows Files

 Threat Hunting in Windows Files


Windows 中啟動可執行檔或二進位檔都會驗證數位簽名以防止惡意軟體運行

兩個較常見且容易使用的工具

 - Powershell

 - Sigcheck : Sysinternals 的一部分


使用 Powershell 進行簽名驗證

開啟 Powershell 輸入 Get-AuthenticodeSignature C:\Windows\System32\calc.exe

查看小算盤的數位簽名,Status 的欄位結果顯示有效 (Valid)



檢查 pslist.exe 數位簽名最後五碼的值 --> 3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC



使用 Sigcheck 進行簽名驗證

直接執行工具 sigcheck.exe,一樣對小算盤做數位簽名驗證

指令 : .\sigcheck.exe c:\windows\system32\calc.exe



試試看 exiftool 跑出來的資訊有否包含,看來僅有部分而已,所以 metadata 不代表數位簽名



檢查另一個檔案 hello.world,可以看到未簽名也沒有發行者




Magic Numbers and Hex Editors

魔法密碼指的是檔案的前幾個位元組,宣告了這個檔的格式,用在網站檔案上傳欺騙是個很好用的方式,常見的魔法密碼如下



不法改變的是 16 進位的結果,所以檢查檔頭時使用 16 進位編輯器查看檔案是最佳的

使用 HxD 程式開啟 sigcheck.exe 然後搜尋 Go To 00098B00




下一步搜尋 destroy



可以依序再往下找或是一次整個列出該值 destroy



搜尋 HEX 的 String,值使用 50 45 00 00(PE executables) 或是 4D 5A(MZ executables)

PE 表示可執行檔



於圖片 picture2.jpg 中尋找 50 45 00 00 發現存在,看來於圖片中採用了隱寫術



HASH


使用工具 ssdeep.exe 計算檔案的 HASH

計算單一檔案 .\ssdeep.exe .\sigcheck.exe

或是該路徑下所有的 *.exe 檔,.\ssdeep.exe -r -l *.exe



使用 .\ssdeep.exe -d -r -l * 比較所有的 HASH 或是改用 -p -r -l * 較友善的輸出

即便檔案做了一點點小小的異動導致 HASH 不一樣,ssdeep 也可以比較是否有相似性

下圖可以看到多個 exe 檔案與 hellp.world 相似,且有某張圖片也相似高達 82%



Get-Item -path .\I_can_hide.txt -Stream *


裡面藏了兩個資訊 hidden_stream & secrets.txt


Remove Data Streams

  1. To enumerate all streams, enter the following in PowerShell:
    Get-ChildItem -Recurse | % {get-item $_.FullName -Stream *} | where stream -ne ':$Data'
  2. There are several Zone.Identifier streams. To remove them from the results, enter:
    Get-ChildItem -Recurse | % {get-item $_.FullName -Stream *} | where {($_.stream -ne ':$Data') -and ($_.stream -ne 'Zone.Identifier')}
  3. Examine the results:
    • There is a stream that is named removeMe in the sample.c file.
  4. To remove this stream enter:
    Remove-Item -path .\sample.c -Stream removeMe
  5. Confirm that the removeMe stream is no longer present by entering:
    Get-Item -path .\sample.c -Stream *



留言

這個網誌中的熱門文章

Challenge 0 - Secura(2)

Challenge 0 - Secura(1)

Challenge 8 - Poseidon(0)