Skip to content

🛡️ BlueTeam CheatSheet

In this note, I organize the commons blue team skill

Event code

winlog

Event ID 說明
4104 Windows powershell 執行日記
4624 登入成功
4625 登入失敗
4648 明確帳號登入(如 RunAs)
4672 特權登入(如 admin 登入)
4634 使用者登出
4688 建立新程序(程式啟動)
4689 程式結束
4697 安裝新服務(常用於惡意持久化)
4720 建立新帳號
4722 啟用帳戶
4723 嘗試變更自己的密碼
4724 嘗試為他人變更密碼
4725 停用帳戶
4726 刪除帳戶
4732 使用者被加入群組
4768 Kerberos TGT 請求
4769 Kerberos 服務票證請求
4776 NTLM 驗證請求
5140 存取共用資料夾
5156 防火牆允許的網路連線(NetConn 事件)
7045 安裝服務(System log,也可監控持久化)

Sysmon

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)

IDS/IPS

  • OSSEC

    • HIDS
  • Suricata

    • NIDS/NIPS
    • ls -lah /etc/suricata/rules/ see all rulus
    • suricata -r test.pcap create various logs(etc eve.json,fast.log...)
    • suricata --pcap=ens160 -vv Suricata's (Live) LibPCAP mod
    • cat /var/log/suricata/old_eve.json | jq -c 'select(.event_type == "http")' | head -1 | jqquury example
  • RITA

  • Snort

    • example:
      sudo snort -c /root/snorty/etc/snort/snort.lua --daq-dir /usr/local/lib/daq -R /home/htb-student/local.rules -r /home/htb-student/pcaps/cerber.pcap -A cmg
      
    sudo snort -c /root/snorty/etc/snort/snort.lua --daq-dir /usr/local/lib/daq \
    -r XXX.pcap
    
    sudo snort -c /root/snorty/etc/snort/snort.lua --daq-dir /usr/local/lib/daq \
    -i ens160
    
  • Zeek

    • /usr/local/zeek/bin/zeek -C -r XXX.pcap
  • [Sysmon]

xml filter example

<QueryList>
  <Query Id="0" Path="Microsoft-Windows-Sysmon/Operational">
    <Select Path="Microsoft-Windows-Sysmon/Operational">
      *[
        System[
          (EventID=3)
          and TimeCreated[
            @SystemTime >= '2022-01-01T07:41:36.000Z'
            and @SystemTime <= '2022-10-02T07:41:36.999Z'
          ]
        ]
        and EventData[
          Data[@Name='ProcessGuid']='a79137ec-af0f-6338-b702-00000000e901'
        ]
      ]
    </Select>
  </Query>
</QueryList>

SIEM

Continuously, for ongoing detection and alerting

ELK Stack

Elastic Common Schema (ECS)

字段類型 描述 KQL 範例
event.category 將事件按大型邏輯類別分組,通常與"event.category"字段結合使用進行過濾搜索 • event.category: authentication
• event.category: process
• event.category: file
• event.category: malware
• event.category: network
event.type 作為子分類,通常與"event.category"字段結合使用過濾搜索 • event.type: creation
• event.type: deletion
• event.type: access
event.outcome 指示事件是否成功或失敗 • event.outcome: success
• event.outcome: failure

Common Search Fields

字段 KQL 範例 輸出
@timestamp @timestamp: 2023-01-25 事件發生時間的時間戳(事件來源於該時間而非更早或更晚)
agent.name agent.name: "DESKTOP*" 從代理名稱中搜索指定字符並顯示結果
message message: powershell 在任何含有"powershell"字符的消息中搜索
字段 KQL 範例 輸出
process.name event.category: process and process.name: svchost 尋找進程名為svchost的所有進程
process.command_line process.command_line: (cmd or "/c") 尋找使用cmd並且含有命令行參數為"/c"的進程
process.pid event.category: process and process.pid: 4360 尋找PID為4360的進程
process.parent.name event.category: process and process.parent.name: cmd.exe and process.name: powershell.exe 尋找父進程為cmd.exe且該進程名為powershell的進程;尋找由cmd.exe父進程啟動的PowerShell進程
process.parent.pid event.category: process and process.parent.pid: 1240 尋找父進程PID為1240的進程
字段 KQL 範例 輸出
source.ip source.ip: 127.0.0.1 尋找源IP地址中的任何出站流量
destination.ip destination.ip: 23.184.192.62 尋找目的IP地址中的任何入站流量
destination.port destination.port: 443 尋找目的端口中的任何入站流量,例如目的端口443
dns.question.name dns.question.name: "www.youtube.com" 尋找DNS查詢記錄查看DNS解析,包括網站youtube.com
dns.response_code dns.response_code: "NXDOMAIN" 尋找DNS響應代碼的返回碼,包含NXDOMAIN
destination.geo.country_name destination.geo.country_name: "Canada" 尋找目的地理國家欄位,例如Canada
字段 KQL 範例 輸出
user.name event.category: "authentication" and user.name: john 尋找用戶名john的登錄嘗試
winlog.logon.type event.category: "authentication" and winlog.logon.type: 3 尋找logon type為3(網路登錄)的驗證事件
winlog.event_data.AuthenticationPackageName event.category: "authentication" and winlog.event_data.AuthenticationPackageName: "NTLM" 尋找使用NTLM驗證包的驗證事件

常用查詢語法

event.provider: "Microsoft-Windows-Sysmon" and event.code: 11  and winlog.event_data.TargetFilename  : *.aspx

# DNS相關查詢
agent.type : "packetbeat" and type:"dns"  
dns.question.registered_domain : "XXX"

# 程序監控
event.category: process and process.name: powershell.exe
process.command_line: *encoded* and event.category: process

# 網路流量分析
source.ip: 192.168.1.0/24 and destination.port: (443 or 80)
event.category: network and destination.geo.country_name: "China"

# 驗證事件
event.category: authentication and event.outcome: failure
winlog.event_id: 4625 and user.name: administrator

# 檔案操作
event.category: file and event.type: creation
file.extension: (exe or dll) and file.path: *temp*

DFIR

after an incident has occurred

CTI

malware analysis

  • Noriben
    • Noriben is a Python-based script that works in conjunction with Sysinternals Procmon to automatically collect, analyze, and report on runtime indicators of malware.
    • python Noriben.py launch the script

Memory Forensics

Volatility Framework

記憶體取證分析工具,用於分析記憶體映像檔案

System Profiling

分析項目 插件 命令行
識別作業系統版本 imageinfo python vol.py -f memory.dump imageinfo
分析KDBG結構 kdbgscan python vol.py -f memory.dump --profile=Win7SP1x64 kdbgscan

Processes Analysis

分析項目 插件 命令行
程序列表 pslist python vol.py -f memory.dump --profile=Win7SP1x64 pslist
程序父子關係 pstree python vol.py -f memory.dump --profile=Win7SP1x64 pstree
掃描程序 (含隱藏/終止) psscan python vol.py -f memory.dump --profile=Win7SP1x64 psscan
隱藏程序檢查 psxview python vol.py -f memory.dump --profile=Win7SP1x64 psxview
程序詳細資訊 psinfo python vol.py -f memory.dump --profile=Win7SP1x64 psinfo -p 1640
程序權限 privs python vol.py -f memory.dump --profile=Win7SP1x64 privs -p 1640
程序執行緒 threads python vol.py -f memory.dump --profile=Win7SP1x64 threads -p 1640
程序SID getsids python vol.py -f memory.dump --profile=Win7SP1x64 getsids -p 1640
程序令牌 tokens python vol.py -f memory.dump --profile=Win7SP1x64 tokens -p 1640
轉儲程序執行檔 procdump python vol.py -f memory.dump --profile=Win7SP1x64 procdump -p 1640 --dump-dir=./
虛擬位址描述符 vadinfo python vol.py -f memory.dump --profile=Win7SP1x64 vadinfo -p 1640
VAD樹結構 vadtree python vol.py -f memory.dump --profile=Win7SP1x64 vadtree -p 1640
遍歷VAD vadwalk python vol.py -f memory.dump --profile=Win7SP1x64 vadwalk -p 1640

Network Connections

分析項目 插件 命令行
網路連線/網路活動 netscan python vol.py -f memory.dump --profile=Win7SP1x64 netscan

Persistence Techniques

分析項目 插件 命令行
註冊表鍵值 printkey python vol.py -f memory.dump --profile=Win7SP1x64 printkey -K "Software\Microsoft\Windows\CurrentVersion\Run"
查找所有持久化機制 autoruns python vol.py -f memory.dump --profile=Win7SP1x64 autoruns

Filesystem

分析項目 插件 命令行
解析MFT項目 mftparser python vol.py -f memory.dump --profile=Win7SP1x64 mftparser
掃描檔案物件 filescan python vol.py -f memory.dump --profile=Win7SP1x64 filescan
轉儲檔案 dumpfiles python vol.py -f memory.dump --profile=Win7SP1x64 dumpfiles -Q 0x000000007e410890 --dump-dir=./

Advanced Analysis

分析項目 插件 命令行
掃描DLL dlllist python vol.py -f memory.dump --profile=Win7SP1x64 dlllist -p 1640
檢查處理程序句柄 handles python vol.py -f memory.dump --profile=Win7SP1x64 handles -p 1640 -t Process,Thread
命令行歷史 cmdline python vol.py -f memory.dump --profile=Win7SP1x64 cmdline
環境變數 envars python vol.py -f memory.dump --profile=Win7SP1x64 envars
記憶體字串搜尋 strings strings memory.dump \| grep -i password
轉儲程序記憶體 memdump python vol.py -f memory.dump --profile=Win7SP1x64 memdump -p 1640 --dump-dir=./
拿evtx dumpfiles + Evtxcmd python vol.py –f Win7SP1x86.vmem --profile=Win7SP1x86 dumpfiles --regex .evtx$ --ignore-case --dump-dir output EvtxECmd.exe -f "C:\Temp\Application.evtx" --csv "c:\temp\out"

Malware Detection

分析項目 插件 命令行
檢查程序注入 malfind python vol.py -f memory.dump --profile=Win7SP1x64 malfind
Hook檢測 apihooks python vol.py -f memory.dump --profile=Win7SP1x64 apihooks
SSDT Hook檢測 ssdt python vol.py -f memory.dump --profile=Win7SP1x64 ssdt
驅動程式掃描 driverscan python vol.py -f memory.dump --profile=Win7SP1x64 driverscan

常用記憶體取證工具

  • Volatility
    • 最流行的記憶體取證框架
    • 支援多種作業系統記憶體分析
  • Rekall
    • Google開發的記憶體取證工具
  • MemProcFS
    • 將記憶體dump檔案掛載為虛擬檔案系統

記憶體取得方法

  • Windows
    • DumpIt.exe - 快速記憶體dump
    • WinPmem - Google開發的記憶體取得工具
    • hiberfil.sys - 休眠檔案(當系統關機時)
    • pagefile.sys - 虛擬記憶體檔案
  • Linux
    • LiME - Linux Memory Extractor
    • dd指令 - dd if=/dev/mem of=memory.dump
  • Virtual Machines
    • VMware: .vmem檔案
    • VirtualBox: 儲存狀態檔案

Network Forensics

  • wireshark
  • NetworkMiner
  • Zui
    • find who is attacker by alert 查看attacker掃描主機port指令
      _path=="conn" and id.resp_h = xxx.xxx.xxx.xxx | cut id.resp_p | sort | uniq
      

disk Forensics

  • AutoSpy

  • R-studio

    • $MFT viewer
  • MFTECmd

    • $MFT to csv file
    • can use timeline Explorer to see the csv
  • NTFS Log Tracker

  • SIDR

    • windows Search Index Database Reporter
    • detect the delete file
  • shellbagsexplorer

    • shellbags date changes into nice view
    • to trace the user active even the file had been delete
    • need %userprofile%\AppData\Local\Microsoft\Windows\USRCLASS.dat and %userprofile%\NTUSER.dat
  • [LECmd]

    • to see link file LECmd.exe -d "C:\Users\Administrator\Desktop\Start Here\Artifacts" --csvf lnk.csv --csv "C:\Users\Administrator\Desktop\lnk-files"
  • jumpLists Explorer

    • to
  • USB Forensics tracker

  • WxTCMD

    • analyze timeline data base to csv file
    • "C:\Users\ \AppData\Local\ConnectedDevicesPlatform\L.\ActivitiesCache.db"
  • Amcache parser

    • may catch the app install time
  • RegistryExplorer

  • WinPrefetchView

  • SrumECmd

項目 Shellbags $MFT (主檔案表) $LogFile $UsnJrnl:$J
📦 來源 註冊表 (NTUSER.DAT / USRCLASS.DAT) NTFS檔案系統中繼資料 NTFS交易日誌 (操作歷程記錄) NTFS更新序號日誌 (USN Journal)
📂 追蹤內容 透過檔案總管GUI存取的資料夾 (本機、USB、網路) 每個檔案/資料夾的中繼資料和時間戳記 低階檔案/資料夾變更 (建立、重新命名、刪除) 所有檔案/資料夾變更事件,包含USN ID和時間戳記
⏱️ 包含時間戳記 ✅ 是 – 資料夾存取/建立時間戳記 ✅ 是 – MACB時間戳記 (修改、存取、建立、項目修改時間) ✅ 是 – 變更時間戳記 (不記錄內容變更) ✅ 是 – 詳細的變更時間
👁️ 分析重點 使用者GUI行為:哪些資料夾被點擊/檢視? 檔案存在性和生命週期中繼資料 變更日誌,類似交易記錄 追蹤檔案/資料夾的完整變更歷史
🧠 保留目的 儲存資料夾檢視設定和歷程 (維持UI一致性) NTFS操作的核心結構 提供檔案系統一致性和當機復原 提供快速檔案變更查詢 (應用程式、索引、備份使用)
👣 常見鑑識用途 - 偵測使用者是否存取 \\10.10.5.86\shared
- 追蹤橫向移動或USB使用
- 檢查檔案是否存在、建立時間
- 識別惡意檔案活動
- 重建惡意活動序列 (例如:惡意程式建立過程) - 識別檔案使用和重新命名/刪除事件
🧪 可恢復刪除檔案? ❌ 否 – 基於資料夾,不保留刪除檔案資訊 ✅ 是 – 除非被覆寫,否則可能留有痕跡 ✅ 可能 – 如果日誌完整可恢復部分操作 ✅ 是 – 顯示檔案建立、重新命名、刪除歷史
🔍 資料保留期間 長期保存 (直到使用者清理註冊表) 永久保存 (直到檔案系統格式化或損毀) 循環覆寫 (取決於系統活動量) 循環覆寫 (預設約3天到數週)
💾 檔案位置 C:\Users\[用戶]\NTUSER.DAT
C:\Users\[用戶]\AppData\Local\Microsoft\Windows\UsrClass.dat
$MFT (NTFS根目錄) $LogFile (NTFS根目錄) $Extend\$UsnJrnl:$J (NTFS)
🛠️ 分析工具 - Registry Explorer
- ShellBags Explorer
- RegRipper
- MFTECmd
- FTK Imager
- Autopsy
- X-Ways Forensics
- LogFileParser
- NTFS Log Tracker
- UsnJrnl2Csv
- USN Analytics
- NTFS Log Tracker
⚠️ 限制 僅追蹤GUI操作,不包含命令列存取 不包含檔案內容,僅中繼資料 日誌大小有限,舊記錄會被覆寫 不追蹤檔案內容變更,僅追蹤檔案系統變更

Zone Identifier

當從瀏覽器(如 Edge、Chrome、IE)下載檔案時,Windows 會建立一個 NTFS 區段資料(ADS) 來記錄檔案來源,例如:

[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://example.com
HostUrl=https://example.com/download/file.exe
這通常儲存在 Zone.Identifier 流裡。

要查看可以從FTK imager 中點擊下載的檔案看有沒有附加的Zone.Identifier


Rapid Triage tool

  • Eric Zimmerman
    • MFTECmd
      • .\MFTECmd.exe -f 'C:\Users\johndoe\Desktop\forensic_data\kape_output\D\$Extend\$J' --csv C:\Users\johndoe\Desktop\forensic_data\mft_analysis\ --csvf MFT-J.csv
    • Timeline Explorer
      • View CSV and Excel files, filter, group, sort, etc. with ease
    • EvtxECmd
      • Event log (evtx) parser with standardized CSV, XML, and json output! Custom maps, locked file support, and more!
      • .\EvtxECmd.exe -f "C:\Users\johndoe\Desktop\forensic_data\kape_output\D\Windows\System32\winevt\logs\Microsoft-Windows-Sysmon%4Operational.evtx" --csv "C:\Users\johndoe\Desktop\forensic_data\event_logs\csv_timeline" --csvf kape_event_log.csv
    • Registry Explorer
      • Registry viewer with searching, multi-hive support, plugins, and more. Handles locked files
    • RegRipper
      • .\rip.exe -r "C:\Users\johndoe\Desktop\forensic_data\kape_output\D\Windows\System32\config\SYSTEM" -p compname
    • PECmd
      • Prefetch parser
      • .\PECmd.exe -d C:\Users\johndoe\Desktop\forensic_data\kape_output\D\Windows\prefetch --csv C:\Users\johndoe\Desktop\forensic_data\prefetch_analysis
    • API Monitor

Acquision

  • Dumpit.exe
    • windows memory image
  • LiME
    • Linux memory image
  • EDD
    • check disk wheather has been encrypted
  • KAPE
    • triage image
  • CyLR
    • inux triage image

if windwos memory dead Acquision

  • hiberfil.sys C:/

  • pagefile.sys C:/