跳到正文
Skillpedia
分析与电子表格35k · #7646

analyzing-powershell-script-block-logging

它能做什么

这个工具会分析 PowerShell 日志,找出可疑或伪装过的命令。它会查找黑客在 Windows 上运行恶意代码时常用的手法。

适用场景

  • ✓在调查安全事件时。
  • ✓在设置告警以发现危险操作时。
  • ✓在检查安全系统能否捕获已知攻击时。

技能链接

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-powershell-script-block-logging/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-powershell-script-block-logging/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“分析一下这个 PowerShell 日志文件,看看有没有可疑的内容。”

每周 5 个新技能,1 分钟读完。

工作原理

工具会读取 PowerShell 日志,把被拆分的脚本片段重新拼接起来,并查找常见的攻击模式,比如经过编码的命令,或者试图关闭安全防护的操作。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Analyzing PowerShell Script Block Logging

When to Use

  • When investigating security incidents that require analyzing powershell script block logging
  • When building detection rules or threat hunting queries for this domain
  • When SOC analysts need structured procedures for this analysis type
  • When validating security monitoring coverage for related attack techniques

Prerequisites

  • Familiarity with security operations concepts and tools
  • Access to a test or lab environment for safe execution
  • Python 3.8+ with required dependencies installed
  • Appropriate authorization for any testing activities

Instructions

  1. Install dependencies: pip install python-evtx lxml
  2. Collect PowerShell Operational logs: Microsoft-Windows-PowerShell%4Operational.evtx
  3. Parse Event ID 4104 entries using python-evtx to extract ScriptBlockText, ScriptBlockId, and MessageNumber/MessageTotal for multi-part script reconstruction.
  4. Apply detection heuristics:
    • Base64-encoded commands (-EncodedCommand, FromBase64String)
    • Download cradles (DownloadString, DownloadFile, Invoke-WebRequest, Net.WebClient)
    • AMSI bypass patterns (AmsiUtils, amsiInitFailed)
    • Obfuscation indicators (high entropy, tick-mark insertion, string concatenation)
  5. Generate a report with reconstructed scripts, risk scores, and MITRE ATT&CK mappings.
python scripts/agent.py --evtx-file /path/to/PowerShell-Operational.evtx --output ps_analysis.json

Examples

Detect Encoded Command Execution

import base64
if "-encodedcommand" in script_text.lower():
    encoded = script_text.split()[-1]
    decoded = base64.b64decode(encoded).decode("utf-16-le")

Reconstruct Multi-Block Script

Scripts split across multiple 4104 events share a ScriptBlockId. Concatenate blocks ordered by MessageNumber to recover the full script.

常见问题

什么是“脚本块日志”(Script Block Logs)?

这是 Windows 在 PowerShell 运行命令时生成的详细记录,有助于了解到底执行了哪些内容。

什么是“离地攻击”(living-off-the-land)技术?

这是攻击者滥用 PowerShell 等系统自带的合法工具来实施攻击的方法,这样就不需要额外安装恶意软件。

这里说的“熵”(entropy)是什么意思?

它衡量的是一段文本看起来有多随机或“杂乱”。熵值很高的文本,可能说明某条命令经过了编码,目的是隐藏其真实用途。

详情

作者的原始描述

Parse Windows PowerShell Script Block Logs (Event ID 4104) from EVTX files to detect obfuscated commands, encoded payloads, and living-off-the-land techniques. Uses python-evtx to extract and reconstruct multi-block scripts, applies entropy analysis and pattern matching for Base64-encoded commands, Invoke-Expression abuse, download cradles, and AMSI bypass attempts.

repo: mukul975/Anthropic-Cybersecurity-Skills

热度

GitHub 星标
35k
排名
#7646
许可证
Apache-2.0
更新时间
2026/8/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能