IAmLegionVaal/Malicious-Word-Macro-Attack-Chain-Research

GitHub: IAmLegionVaal/Malicious-Word-Macro-Attack-Chain-Research

一项防御性安全研究项目,系统性剖析恶意 Word 宏攻击链并提供检测工程、加固和事件响应的完整防御材料。

Stars: 0 | Forks: 0

# 恶意 Word 宏攻击链研究 [![防御性研究](https://img.shields.io/badge/purpose-defensive%20research-0b7285)](#scope-and-safety) [![MITRE ATT&CK](https://img.shields.io/badge/MITRE-ATT%26CK-red)](docs/01-attack-chain.md#mitre-attck-mapping) [![平台](https://img.shields.io/badge/platform-Windows-blue)](#observed-attack-chain) [![Office](https://img.shields.io/badge/vector-Microsoft%20Word-2b579a)](#observed-attack-chain) 对经典恶意 Microsoft Word/VBA 投递链的防御性深度剖析: 该仓库记录了一段 17 帧演示中展示的技术,解释了攻击者使用的工具,将行为映射到 MITRE ATT&CK,并提供了检测、加固、事件响应和安全实验室材料。 ## 范围与安全性 该仓库有意设为**非武器化**: - 不包含可工作的 reverse-shell payload。 - 不包含可部署的恶意 `.docm` 文件。 - 不包含命令与控制 (C2) 配置。 - 源演示中展示的 VBA 未被转录为可运行的形式。 - 模拟遥测中的测试 IP 使用了 RFC 5737 文档地址范围。 - 包含的 VBA 示例仅写入一个本地的良性标记文件,不会生成进程或使用网络。 仅将此材料用于授权的安全研究、检测工程、事件响应和受控实验室训练。 ## 重要的现代背景说明 该演示代表了一种众所周知的宏攻击模式,但它简化了当前 Microsoft 365 Apps 的行为。在受支持的 Windows Office 版本中,带有 Mark of the Web (MotW) 的文件中的 VBA 宏默认会被阻止。因此,一次成功的现代攻击通常取决于绕过条件,例如不安全的策略配置、移除了 Mark of the Web、受信任的位置、受信任的发布者、旧版 Office 行为或其他投递方法。 这是简短的概念验证视频与真实的企业入侵之间最重要的区别之一。 ## 观察到的攻击链 ``` flowchart LR A[Invoice-themed Word document] --> B[User opens macro-enabled file] B --> C[VBA auto-open event] C --> D[Word creates hidden PowerShell child process] D --> E[PowerShell retrieves second-stage content over HTTP] E --> F[PowerShell opens outbound TCP channel] F --> G[Attacker-side listener receives Windows shell] G --> H[Discovery commands: user and directory context] ``` ### 可能的进程树 ``` explorer.exe / email client / browser └── WINWORD.EXE └── powershell.exe or pwsh.exe ├── outbound HTTP connection to staging service ├── outbound TCP connection to listener or C2 └── cmd.exe ├── whoami └── dir ``` ### 分阶段摘要 | 阶段 | 发生的行为 | 可观测证据 | |---|---|---| | 投递 | 向目标提供一份发票主题的启用宏的文档。 | 电子邮件附件、下载事件、`.docm`/`.dotm`、Mark of the Web | | 用户执行 | 用户在配置薄弱或旧版环境中打开文档并允许活动内容。 | `WINWORD.EXE`、Office 安全事件、受信任文档更改 | | VBA 执行 | `AutoOpen` 或 `Document_Open` 调用触发例程。 | VBA 流、自动运行关键字、AMSI 检查 | | PowerShell 分阶段 | Word 启动 PowerShell,通常带有隐藏窗口。 | Office → PowerShell 父子链、命令行、Event ID 4688/Sysmon 1 | | 工具传输 | PowerShell 从临时 Web 服务器获取第二阶段脚本。 | HTTP 请求、PowerShell 脚本块日志、Sysmon 3、代理日志 | | 命令通道 | 脚本向监听系统发起外部连接。 | 异常的远程 IP/端口、PowerShell 网络连接 | | Shell 访问 | 通过该通道返回一个 Windows 命令 shell。 | PowerShell 生成的 `cmd.exe`、交互式命令序列 | | 发现 | 操作者识别当前用户并枚举文件。 | `whoami`、`dir`、T1033、T1083 | ## 演示中展示的工具 | 工具或组件 | 角色 | |---|---| | Microsoft Word | 承载诱饵和 VBA 工程 | | Visual Basic for Applications | 自动执行和第一阶段编排 | | PowerShell | 原生 Windows 脚本解释器和第二阶段加载器 | | .NET 网络类 | 从分阶段服务器进行 HTTP 检索 | | Powercat 风格脚本 | TCP shell/通道的 PowerShell 实现 | | Python HTTP 服务器 | 临时 payload 分阶段 | | Netcat/Ncat | 攻击者端 TCP 监听器 | | Kali Linux | 攻击者/实验室工作站 | | 私有实验室子网 | 攻击者和受害者虚拟机之间的隔离连接 | 截图专门展示了 `powercat.ps1` 文件、基于 Python 的 HTTP 服务器和 Netcat 监听器。真实的入侵可能会替换为自定义加载器、商业或开源 C2 框架、云端托管的分阶段服务器、被入侵的网站或 living-off-the-land 二进制文件。 ## 高信噪比检测逻辑 最强的通用信号不是文档名或目标端口。而是**进程谱系**: ``` WINWORD.EXE → powershell.exe/pwsh.exe → cmd.exe ``` 额外的高价值信号: - Office 生成 PowerShell、Command Prompt、WScript、CScript、MSHTA、Rundll32、Regsvr32 或安装实用程序。 - PowerShell 以隐藏窗口、编码命令、下载、反射或在内存中执行模式启动。 - PowerShell 在 Word 启动后立即进行网络连接。 - 新打开的启用宏的 Office 文件随后执行了脚本解释器。 - PowerShell 或 `cmd.exe` 执行 `whoami`、`dir`、`systeminfo`、`ipconfig` 或类似的发现操作。 - 来自电子邮件或浏览器下载且移除了 Mark of the Web 的 Office 文件。 - 针对 Office 子进程或可执行内容的 ASR 审计/阻止事件。 参见: - [攻击链分析](docs/01-attack-chain.md) - [攻击者工具](docs/02-attacker-tooling.md) - [检测工程](docs/03-detection-engineering.md) - [安全加固](docs/04-hardening.md) - [事件响应](docs/05-incident-response.md) - [安全实验室](docs/06-safe-lab.md) - [截图演练](docs/07-screenshot-walkthrough.md) - [Microsoft Defender XDR KQL](detections/kql/microsoft-defender-xdr.kql) - [Sigma 规则](detections/sigma/) - [YARA 规则](detections/yara/suspicious_office_vba_strings.yar) ## MITRE ATT&CK 映射 | 技术 | ID | 展示的行为 | |---|---|---| | 鱼叉式网络钓鱼附件 | T1566.001 | 恶意 Office 附件作为投递载体 | | 用户执行:恶意文件 | T1204.002 | 受害者打开文档 | | 命令和脚本解释器:Visual Basic | T1059.005 | VBA 宏执行 | | 命令和脚本解释器:PowerShell | T1059.001 | PowerShell 加载器和第二阶段 | | 隐藏工件:隐藏窗口 | T1564.003 | 隐藏的 PowerShell 执行 | | 入站工具传输 | T1105 | 从分阶段服务器获取第二阶段脚本 | | 非应用层协议 | T1095 | 原始 TCP 风格的反向通道 | | 命令和脚本解释器:Windows Command Shell | T1059.003 | 交互式 `cmd.exe` shell | | 系统所有者/用户发现 | T1033 | `whoami` | | 文件和目录发现 | T1083 | `dir` | ## 仓库结构 ``` . ├── README.md ├── DISCLAIMER.md ├── NOTICE.md ├── SOURCES.md ├── docs/ │ ├── 01-attack-chain.md │ ├── 02-attacker-tooling.md │ ├── 03-detection-engineering.md │ ├── 04-hardening.md │ ├── 05-incident-response.md │ ├── 06-safe-lab.md │ └── 07-screenshot-walkthrough.md ├── detections/ │ ├── kql/ │ ├── sigma/ │ └── yara/ ├── samples/ │ ├── benign-vba/ │ └── mock-telemetry/ └── scripts/ └── Test-OfficeMacroAttackSurface.ps1 ``` ## 安全的文档分类 不要在生产工作站上双击可疑文档。请妥善保存并在隔离环境中进行分析。 有用的防御工具包括: - `oletools` 中的 `olevba` - `oledump.py` - `OfficeMalScanner` - YARA - Microsoft Defender Antivirus 和 AMSI - Sysmon - Microsoft Defender for Endpoint - Procmon 和 Process Explorer - Wireshark 或受控网络模拟器 静态分析工作流示例: ``` 1. Record SHA-256. 2. Preserve the original file and its Zone.Identifier stream. 3. Extract or enumerate VBA streams without opening the document in Office. 4. Search for auto-run functions, process creation, network APIs, and obfuscation. 5. Detonate only in a disposable, isolated VM with no production credentials. 6. Correlate document, process, script, file, and network telemetry. ``` ## 截图示例 这 17 张截图是 Dewald Pretorius 创作的原创、作者拥有的研究材料,在本仓库中用作说明性示例。 ## 延伸阅读 有关 Microsoft 和 MITRE 的主要参考资料,请参见 [SOURCES.md](SOURCES.md)。
标签:AI合规, AMSI绕过, Cloudflare, Libemu, MITRE ATT&CK, OpenCanary, 威胁检测, 库, 应急响应, 搜索语句(dork), 攻击链分析, 网络安全, 逆向工具, 防御研究, 隐私保护