alexrepsec/Windows-Forensics-write-up

GitHub: alexrepsec/Windows-Forensics-write-up

一份完整的 Windows 数字取证与事件响应(DFIR)实战报告,通过分析取证镜像还原攻击链并提取 MITRE ATT&CK 映射与 IOC。

Stars: 0 | Forks: 0

# 🪟 Windows 取证 — LetsDefend 挑战 [![Platform](https://img.shields.io/badge/-LetsDefend-0078D4?style=for-the-badge&logoColor=white)](https://app.letsdefend.io/challenge/windows-forensics) [![Difficulty](https://img.shields.io/badge/-Hard-FF0000?style=for-the-badge&logoColor=white)]() [![Category](https://img.shields.io/badge/-DFIR-6A0DAD?style=for-the-badge&logoColor=white)]() [![MITRE](https://img.shields.io/badge/-MITRE%20ATT%26CK-FF6600?style=for-the-badge&logoColor=white)](https://attack.mitre.org/) ## 📋 场景 **Artifact:** `Relevent Artifacts.ad1` — FTK Imager 取证镜像 **Password:** `infected` **受损用户:** `CyberJunkie` ## 🛠️ 使用的工具 | 工具 | 用途 | |------|---------| | FTK Imager 4.7 | 挂载并浏览 AD1 取证镜像 | | ShellBags Explorer (EZ Tools) | 识别已删除/访问的文件夹路径 | | RBCmd (EZ Tools) | 解析 Recycle Bin artifacts 以恢复已删除的文件 | | AmcacheParser (EZ Tools) | 识别已执行的二进制文件及其完整路径 | | MFTECmd / MFTExplorer (EZ Tools) | 解析 `$MFT` 的 MACB 时间戳并检测 timestomping | | RegistryExplorer (EZ Tools) | 分析注册表配置单元以寻找持久化机制 | | bmc-tools | 解码 RDP bitmap cache tiles | | RdpCacheStitcher | 从 bitmap cache 重建 RDP 会话截图 | | DeepBlueCLI | 通过 Windows Event Logs 进行威胁狩猎 | ## 🔍 调查 ### 第 1 步 — 挂载取证镜像 Artifact `Relevent Artifacts.ad1` 通过 `File → Add Evidence Item → Image File` 加载到 **FTK Imager** 中。 证据树显示了与调查相关的以下结构: ``` [root] ├── $MFT ├── $Recycle.Bin ├── Users/ │ └── CyberJunkie/ │ ├── AppData/ │ │ └── Local/Microsoft/ │ │ ├── Terminal Server Client/Cache/ ← RDP bitmap cache │ │ └── Windows/UsrClass.dat ← ShellBags │ ├── Documents/ │ └── Desktop/ └── Windows/ ├── appcompat/Programs/Amcache.hve ├── Prefetch/ └── System32/ ├── config/ (SAM, SECURITY, SOFTWARE, SYSTEM) └── winevt/Logs/ ``` ### Q1 — 钓鱼文档被下载到的完整路径 用户配置文件中**缺少** Downloads 文件夹,表明它在入侵后被删除了。为了恢复该路径,使用 **ShellBags Explorer** 分析了 **ShellBags** artifacts。 从以下位置加载了 `UsrClass.dat` 配置单元(加载期间按住 **SHIFT**): ``` [root]\Users\CyberJunkie\AppData\Local\Microsoft\Windows\UsrClass.dat ``` ShellBags 揭示了一个之前存在但已从磁盘中删除的文件夹,从而确认了邮件附件的保存位置。 ### Q2 — 钓鱼文档名称 由于该文档已被删除,因此使用 **RBCmd** 针对镜像中的 `$Recycle.Bin` artifacts 分析了 **Recycle Bin**: ``` RBCmd.exe -d "[root]\$Recycle.Bin" --csv C:\Output\ ``` 输出结果揭示了该已删除文档在被移动到 Recycle Bin 之前的原始文件名。 ### Q3 — 连接到攻击者 C2 服务器的 stager 针对 `Amcache.hve` 运行 **AmcacheParser** 以识别最近执行的二进制文件: ``` AmcacheParser.exe -f "[root]\Windows\appcompat\Programs\Amcache.hve" --csv C:\Output\ ``` 审查 `Amcache_UnassociatedFileEntries.csv` 时,发现了一个可疑条目: | 字段 | 值 | |-------|-------| | FileName | `SecurityPatch.exe` | | ParentPath | `\Users\CyberJunkie\Desktop` | 名称 `SecurityPatch.exe` 是一种**伪装技术** (T1036) —— 将恶意二进制文件命名为听起来像合法的 Windows 进程以避免被怀疑。 ### Q4 — Timestomping:原始时间戳与篡改时间戳对比 攻击者使用 **Timestomping** (T1070.006) 操纵了 `SecurityPatch.exe` 的 `$STANDARD_INFORMATION` (SI) 时间戳,使其看起来比实际创建时间早得多。 使用 **MFTExplorer** 分析了 **`$MFT`**,对比了两个时间戳属性: | 属性 | 描述 | 时间戳 | |-----------|-------------|-----------| | `$FILE_NAME` (FN) | 由操作系统控制 — **无法被用户模式工具修改** | `2022-08-21 13:02:23.66` | | `$STANDARD_INFORMATION` (SI) | 用户可写 — **被攻击者篡改** | `2021-12-25 15:34:32` | ### Q5 — 用作持久化触发器的进程名称 (GlobalFlags / IFEO) 攻击者使用了 **Image File Execution Options (IFEO) + SilentProcessExit** 技术 (T1546.012)。这允许 payload 在特定受监控进程**退出**时静默执行 —— 从而使其对标准的 autoruns 工具不可见。 使用 **RegistryExplorer** 加载 `SOFTWARE` 配置单元(加载时按住 **SHIFT**)并导航至: ``` HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\ ``` 在该路径下发现了一个恶意子项,用于标识被监控的进程。 ### Q6 — 持久化可执行文件的完整路径 在 `SilentProcessExit\explorer.exe` 项中,`MonitorProcess` 值包含了攻击者持久化 payload 的完整路径 —— 这是一个与初始 stager 不同的独立二进制文件,位于 Documents 文件夹中: ``` HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\explorer.exe MonitorProcess = c:\users\cyberjunkie\documents\getpatch.exe ``` ### Q7 — RDP 横向移动后运行的命令 从以下位置提取了 RDP **Bitmap Cache** 文件: ``` [root]\Users\CyberJunkie\AppData\Local\Microsoft\Terminal Server Client\Cache\ ├── Cache0000.bin └── bcache24.bmc ``` 使用 **bmc-tools** 提取了约 2,350 张 bitmap tile 图像: ``` python3 bmc-tools.py -s Cache0000.bin -d ./output/ ``` 然后,将这些 tiles 加载到 **RdpCacheStitcher** 中,以直观地重建 RDP 会话。重建的屏幕显示,远程机器上打开了一个 CMD 窗口,其中包含攻击者执行的第一个用于本地权限/组侦察的命令。 ### Q8 — 第二台机器上通过浏览器下载的工具 在 **RdpCacheStitcher** 中继续进行 RDP 缓存重建时,额外的 tiles 揭示了第二台机器上的一个浏览器下载对话框。攻击者下载了一个基于 PowerShell 的 Active Directory 侦察工具,该工具通常用于发现权限提升路径。 ### Q9 — 导致权限提升的命令 **方法 1 — 手动审查 Event Log** 在 Event Viewer 中分析 `System.evtx` 时,第一个被标记的可疑条目是一条 CMD 管道命令,这与 Metasploit 命名管道模拟攻击一致: ``` cmd.exe /c echo kyvckn > \\.\pipe\kyvckn ``` **方法 2 — DeepBlueCLI 自动化分析** 针对导出的 Event Logs 运行 PowerShell 威胁狩猎模块,确认了相同的条目并将其归因于 Metasploit。 ``` .\DeepBlue.ps1 .\System.evtx ``` ### Q10 — 攻击者使用的框架 **DeepBlueCLI** 根据 Windows Event Logs 中的命名管道约定 (`\\.\pipe\`) 和 shellcode 模式,明确识别出了攻击框架 —— 这是一个众所周知的 Metasploit 指标。 ## 🗺️ 攻击链总结 ``` [1] INITIAL ACCESS └── Phishing email → "security awareness.docx" downloaded to MailDownloads └── User opens document → execution triggered [2] EXECUTION & C2 └── SecurityPatch.exe (stager) executed from Desktop └── Timestomped to 2021-12-25 to evade timeline analysis └── Beacons to Metasploit C2 via named pipe [3] PERSISTENCE └── IFEO + SilentProcessExit configured in SOFTWARE hive └── explorer.exe exit → triggers getpatch.exe from Documents folder [4] LATERAL MOVEMENT └── RDP from CyberJunkie machine to internal second machine └── First command: "net localgroup" (local group reconnaissance) [5] POST-EXPLOITATION └── powerview.ps1 downloaded via browser on second machine └── AD enumeration for privilege escalation path discovery [6] PRIVILEGE ESCALATION └── cmd.exe /c echo kyvckn > \\.\pipe\kyvckn └── Metasploit named pipe impersonation → SYSTEM privileges ``` ## 📌 IOC | 类型 | 值 | |------|-------| | 钓鱼文档 | `security awareness.docx` | | 文档下载路径 | `c:\users\cyberjunkie\downloads\maildownloads` | | Stager | `SecurityPatch.exe` | | Stager 完整路径 | `c:\users\cyberjunkie\desktop\securitypatch.exe` | | 真实时间戳 (FN) | `2022-08-21 13:02:23.66` | | 篡改时间戳 (SI) | `2021-12-25 15:34:32` | | 持久化触发进程 | `explorer.exe` | | 持久化注册表项 | `HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\explorer.exe` | | 持久化 payload | `c:\users\cyberjunkie\documents\getpatch.exe` | | 横向移动协议 | RDP (`mstsc.exe`) | | 侦察工具 | `powerview.ps1` | | 权限提升命令 | `cmd.exe /c echo kyvckn > \\.\pipe\kyvckn` | | C2 框架 | `Metasploit` | ## 🧩 MITRE ATT&CK 映射 | 战术 | 技术 | ID | |--------|-----------|-----| | Initial Access | Spearphishing Attachment | T1566.001 | | Execution | User Execution: Malicious File | T1204.002 | | Defense Evasion | Masquerading | T1036 | | Defense Evasion | Timestomping | T1070.006 | | Persistence | IFEO Injection (SilentProcessExit) | T1546.012 | | Lateral Movement | Remote Desktop Protocol | T1021.001 | | Discovery | Local Groups Discovery | T1069.001 | | Discovery | Domain Trust Discovery (PowerView) | T1482 | | Privilege Escalation | Named Pipe Impersonation | T1134.001 | | Defense Evasion | Clear Windows Event Logs | T1070.001 | ## 📚 参考 - [IFEO + GlobalFlags 持久化 — Oddvar Moe](https://oddvar.moe/2018/04/10/persistence-using-globalflags-in-image-file-execution-options-hidden-from-autoruns-exe/) - [通过 IFEO 注入实现持久化 — PentestLab](https://pentestlab.blog/2020/01/13/persistence-image-file-execution-options-injection/) - [RDP Bitmap Cache 取证](https://medium.com/@ronald.craft/blind-forensics-with-the-rdp-bitmap-cache-16e0c202f91c) - [bmc-tools — ANSSI-FR](https://github.com/ANSSI-FR/bmc-tools/) - [RdpCacheStitcher — BSI](https://github.com/BSI-Bund/RdpCacheStitcher) - [DeepBlueCLI — SANS Blue Team](https://github.com/sans-blue-team/DeepBlueCLI) - [Eric Zimmerman 工具](https://ericzimmerman.github.io/) - [LetsDefend — Windows 取证挑战](https://app.letsdefend.io/challenge/windows-forensics) *报告由 [alexrepsec](https://github.com/alexrepsec) 编写 — LetsDefend DFIR 系列*
标签:AI合规