analyzing-powershell-script-block-logging — скилл для Claude Code
Скилл разбирает журналы PowerShell Script Block Logging из EVTX и находит обфусцированные команды, Base64-полезные нагрузки и попытки обхода AMSI.
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-powershell-script-block-logging -a claude-codeЧто делает analyzing-powershell-script-block-logging
Скилл читает файл Microsoft-Windows-PowerShell%4Operational.evtx и вытаскивает события с идентификатором 4104. Из каждого берётся текст блока скрипта, его ScriptBlockId и номера MessageNumber с MessageTotal. Скрипты, разбитые на несколько событий, собираются обратно по общему ScriptBlockId и порядку номеров — так восстанавливается целая команда, а не обрывок.
Дальше идёт поиск по шаблонам: команды с -EncodedCommand и FromBase64String, загрузка полезной нагрузки через DownloadString, DownloadFile, Invoke-WebRequest и Net.WebClient, следы обхода AMSI вроде AmsiUtils и amsiInitFailed. К этому добавляется оценка энтропии, вставка обратных кавычек и склейка строк — типичные приёмы маскировки. На выходе получается отчёт с восстановленными скриптами, оценкой риска и привязкой к MITRE ATT&CK.
Для работы нужен Python 3.8 или новее и пакеты python-evtx и lxml: pip install python-evtx lxml. Запуск идёт через python scripts/agent.py --evtx-file /path/to/PowerShell-Operational.evtx --output ps_analysis.json. Если журнал PowerShell Operational не включён на хосте, событий 4104 в файле просто не будет — это первое, что стоит проверить перед разбором.
Какие задачи решает
- восстановить скрипт, разбитый на несколько событий 4104
- найти команду, спрятанную в Base64
- отловить загрузку файла через
Net.WebClient - заметить попытку обхода AMSI в журнале
- собрать отчёт с привязкой находок к MITRE ATT&CK
Примеры запросов агенту
- разбери
PowerShell-Operational.evtxи покажи восстановленные скрипты с оценкой риска - найди в журнале события 4104 с
-EncodedCommandи раскодируй их - проверь журнал на паттерны обхода AMSI и загрузки через
DownloadString
Как установить analyzing-powershell-script-block-logging
1Через Skills CLI (Vercel)
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-powershell-script-block-logging -a claude-code2Вручную: положить файлы
~/.claude/skills/analyzing-powershell-script-block-logging/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/analyzing-powershell-script-block-logging/
1Через Skills CLI (Vercel)
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-powershell-script-block-logging -a codex2Вручную: положить файлы
.agents/skills/analyzing-powershell-script-block-logging/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-powershell-script-block-logging -a cursor2Вручную: положить файлы
.cursor/skills/analyzing-powershell-script-block-logging/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install mukul975/Anthropic-Cybersecurity-Skills analyzing-powershell-script-block-logging2Вручную: положить файлы
.github/skills/analyzing-powershell-script-block-logging/SKILL.md1Через Skills CLI (Vercel)
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-powershell-script-block-logging -a gemini-cli2Командой платформы
gemini skills install https://github.com/mukul975/Anthropic-Cybersecurity-Skills --path skills/analyzing-powershell-script-block-loggingВручную: положить файлы
.devin/skills/analyzing-powershell-script-block-logging/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-powershell-script-block-logging -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о analyzing-powershell-script-block-logging
Как установить analyzing-powershell-script-block-logging в Claude?
Выполните npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-powershell-script-block-logging -a claude-code. Скилл окажется в ~/.claude/skills/analyzing-powershell-script-block-logging/SKILL.md.
Что делает этот скилл?
Разбирает журналы PowerShell Script Block Logging (Event ID 4104) из EVTX, восстанавливает многочастные скрипты и ищет обфускацию, кодированные команды, загрузчики и попытки обхода AMSI.
Что нужно для работы скилла?
Python 3.8 или новее и пакеты python-evtx и lxml. Ещё нужен сам файл журнала PowerShell Operational — без него событий 4104 не будет.
Исходный текст
SKILL.md · Apache-2.0
---
name: analyzing-powershell-script-block-logging
description: 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.
domain: cybersecurity
subdomain: security-operations
tags:
- powershell
- script-block-logging
- event-id-4104
- obfuscation-detection
- windows-forensics
- endpoint-security
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- DE.CM-01
- RS.MA-01
- GV.OV-01
- DE.AE-02
mitre_attack:
- T1059.001
- T1027.010
- T1140
- T1105
---
# 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.
```bash
python scripts/agent.py --evtx-file /path/to/PowerShell-Operational.evtx --output ps_analysis.json
```
## Examples
### Detect Encoded Command Execution
```python
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.
© mahipal · Apache-2.0 · mukul975/Anthropic-Cybersecurity-Skills