analyzing-powershell-script-block-logging
从 EVTX 文件中解析 Windows PowerShell 脚本块日志(事件 ID 4104),以检测混淆命令、编码载荷和离地攻击技术(living-off-the-land)。使用 python-evtx 提取并重建多块脚本,通过熵分析和模式匹配检测 Base64 编码命令、Invoke-Expression 滥用、下载植入器(download cradles)和 AMSI 绕过尝试。
Best use case
analyzing-powershell-script-block-logging is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
从 EVTX 文件中解析 Windows PowerShell 脚本块日志(事件 ID 4104),以检测混淆命令、编码载荷和离地攻击技术(living-off-the-land)。使用 python-evtx 提取并重建多块脚本,通过熵分析和模式匹配检测 Base64 编码命令、Invoke-Expression 滥用、下载植入器(download cradles)和 AMSI 绕过尝试。
Teams using analyzing-powershell-script-block-logging should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/analyzing-powershell-script-block-logging/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How analyzing-powershell-script-block-logging Compares
| Feature / Agent | analyzing-powershell-script-block-logging | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
从 EVTX 文件中解析 Windows PowerShell 脚本块日志(事件 ID 4104),以检测混淆命令、编码载荷和离地攻击技术(living-off-the-land)。使用 python-evtx 提取并重建多块脚本,通过熵分析和模式匹配检测 Base64 编码命令、Invoke-Expression 滥用、下载植入器(download cradles)和 AMSI 绕过尝试。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
## 使用说明
1. 安装依赖: `pip install python-evtx lxml`
2. 收集 PowerShell 操作日志: `Microsoft-Windows-PowerShell%4Operational.evtx`
3. 使用 python-evtx 解析事件 ID 4104 条目,提取 ScriptBlockText、ScriptBlockId 以及 MessageNumber/MessageTotal,用于多块脚本重建。
4. 应用检测启发式规则:
- Base64 编码命令(`-EncodedCommand`、`FromBase64String`)
- 下载植入器(`DownloadString`、`DownloadFile`、`Invoke-WebRequest`、`Net.WebClient`)
- AMSI 绕过模式(`AmsiUtils`、`amsiInitFailed`)
- 混淆指标(高熵、反引号插入、字符串拼接)
5. 生成报告,包含重建脚本、风险评分和 MITRE ATT&CK 映射。
```bash
python scripts/agent.py --evtx-file /path/to/PowerShell-Operational.evtx --output ps_analysis.json
```
## 示例
### 检测编码命令执行
```python
import base64
if "-encodedcommand" in script_text.lower():
encoded = script_text.split()[-1]
decoded = base64.b64decode(encoded).decode("utf-16-le")
```
### 重建多块脚本
拆分在多个 4104 事件中的脚本共享一个 `ScriptBlockId`。按 `MessageNumber` 顺序拼接各块以恢复完整脚本。Related Skills
implementing-web-application-logging-with-modsecurity
配置带有 OWASP 核心规则集(CRS)的 ModSecurity WAF,实现 Web 应用程序日志记录, 调整规则以减少误报,分析审计日志进行攻击检测,并为应用程序特定威胁实现自定义 SecRules。 分析师配置 SecRuleEngine、SecAuditEngine 和 CRS 偏执级别,以在安全覆盖范围和运营稳定性之间取得平衡。 适用于涉及 WAF 配置、ModSecurity 规则调整、Web 应用审计日志或 CRS 部署的场景。
implementing-log-integrity-with-blockchain
使用 SHA-256 哈希链构建仅追加式日志完整性链以实现篡改检测。每条日志条目与前一条条目的哈希值 一起进行哈希运算,形成类似区块链的结构,修改任一条目将使后续所有哈希值失效。 实现日志摄取、链完整性验证、精确定位的篡改检测,以及定期向外部时间戳服务锚定检查点。
hunting-for-persistence-via-wmi-subscriptions
通过监控 WMI 消费者、过滤器和绑定创建事件,狩猎攻击者利用 Windows Management Instrumentation 事件订阅实现的持久化,这些订阅在系统事件触发时执行恶意代码。
hunting-for-anomalous-powershell-execution
通过分析脚本块日志(事件 4104)、模块日志(事件 4103)和进程创建事件,狩猎恶意 PowerShell 活动。 分析员解析 Windows 事件日志 EVTX 文件,检测混淆命令、AMSI 绕过尝试、编码 payload、 凭据转储关键词和可疑下载器(download cradles)。适用于涉及 PowerShell 威胁狩猎、脚本块分析、 编码命令检测或 AMSI 绕过识别的场景。
exploiting-prototype-pollution-in-javascript
检测并利用客户端和服务器端应用程序中的 JavaScript 原型链污染漏洞,通过属性注入实现 XSS、RCE 和身份验证绕过。
detecting-suspicious-powershell-execution
检测可疑的 PowerShell 执行模式,包括编码命令、下载器(download cradles)、AMSI 绕过尝试以及受限语言模式规避。
deobfuscating-powershell-obfuscated-malware
使用 AST 分析、动态追踪以及 PSDecode 和 PowerDecode 等工具,系统地对多层 PowerShell 恶意软件进行去混淆,以揭示隐藏的载荷和 C2 基础设施。
deobfuscating-javascript-malware
通过逆向编码层、eval 调用链、字符串操作和控制流混淆, 对 Web 攻击、钓鱼页面和投放器脚本中使用的恶意 JavaScript 代码进行去混淆, 以还原原始恶意逻辑。适用于 JavaScript 恶意软件分析、脚本去混淆、 Web 嗅探器分析或混淆投放器调查等请求。
configuring-windows-event-logging-for-detection
配置 Windows 事件日志与高级审计策略,以生成高质量安全事件用于威胁检测和取证调查。 适用于为登录事件、进程创建、权限使用和对象访问启用审计策略,以支撑 SIEM 检测规则的场景。
analyzing-windows-shellbag-artifacts
分析 Windows ShellBag 注册表取证痕迹,使用 SBECmd 和 ShellBags Explorer 重建文件夹浏览活动,检测对可移动介质和网络共享的访问,并在删除后仍能确认用户与目录的交互行为。
analyzing-windows-registry-for-artifacts
提取并分析 Windows 注册表配置单元,以发现用户活动、已安装软件、自启动条目及系统入侵证据。
analyzing-windows-prefetch-with-python
使用 windowsprefetch Python 库解析 Windows Prefetch 文件,重建应用程序执行历史,检测重命名或伪装的二进制文件,并识别可疑的程序执行模式。