Skip to main content
skill CX Codex

analyzing-powershell-script-block-logging — Claude Code skill: parse

This skill parses PowerShell Script Block Logging events from EVTX files and flags obfuscated commands, Base64 payloads and AMSI bypass attempts.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-powershell-script-block-logging -a claude-code
Open on GitHub

What analyzing-powershell-script-block-logging does

The skill reads Microsoft-Windows-PowerShell%4Operational.evtx and pulls out Event ID 4104 entries. From each one it takes the script block text, the ScriptBlockId, and the MessageNumber and MessageTotal values. Scripts split across several events share a ScriptBlockId, so the skill concatenates the blocks in message order to recover the full command instead of a fragment.

Pattern matching then covers -EncodedCommand and FromBase64String, download cradles built on DownloadString, DownloadFile, Invoke-WebRequest and Net.WebClient, and AMSI bypass strings such as AmsiUtils and amsiInitFailed. Entropy scoring, tick-mark insertion and string concatenation catch the quieter obfuscation tricks. Output is a report with reconstructed scripts, risk scores and MITRE ATT&CK mappings.

You need Python 3.8 or newer plus python-evtx and lxml: pip install python-evtx lxml. The run line is python scripts/agent.py --evtx-file /path/to/PowerShell-Operational.evtx --output ps_analysis.json. If PowerShell Operational logging was never turned on for the host, there are no 4104 events in the file at all — check that before you dig in.

What it helps with

  • rebuild a script split across several 4104 events
  • decode a command hidden in Base64
  • catch a download cradle built on Net.WebClient
  • spot an AMSI bypass attempt in the log
  • produce a report with MITRE ATT&CK mappings

Example prompts for the agent

  • parse PowerShell-Operational.evtx and list the reconstructed scripts with risk scores
  • find 4104 events with -EncodedCommand and decode them
  • check the log for AMSI bypass patterns and DownloadString cradles

How to install analyzing-powershell-script-block-logging

1Skills CLI (Vercel)

npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-powershell-script-block-logging -a claude-code

2Manually: put the files in place

~/.claude/skills/analyzing-powershell-script-block-logging/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/analyzing-powershell-script-block-logging/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about analyzing-powershell-script-block-logging

How do I install analyzing-powershell-script-block-logging in Claude?

Run npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-powershell-script-block-logging -a claude-code. The skill lands in ~/.claude/skills/analyzing-powershell-script-block-logging/SKILL.md.

What does analyzing-powershell-script-block-logging do?

It parses PowerShell Script Block Logging (Event ID 4104) entries from EVTX files, reconstructs multi-block scripts and looks for obfuscation, encoded commands, download cradles and AMSI bypass attempts.

What do I need to run it?

Python 3.8 or newer with python-evtx and lxml installed. You also need the PowerShell Operational log file itself — without it there are no 4104 events to parse.

Source text

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

Similar skills

Everything for Security →

From the same set89

exploiting-api-injection-vulnerabilities Audits API parameters, headers, and request bodies for injection flaws like SQLi and SSRF. Helps assess backend input validation against OWASP API standards. CX Codex +1 311installs analyzing-outlook-pst-for-email-forensics This skill parses Outlook PST and OST files to extract messages, headers, attachments, and deleted items. Use it for email forensics or incident response. CX Codex +1 308installs abusing-shadow-credentials-for-privesc Guides Active Directory account takeover by writing keys to msDS-KeyCredentialLink without password resets. Built for authorized red-team engagements when rights like GenericWrite appear in BloodHound. CX Codex +1 307installs testing-for-host-header-injection Tests web applications for HTTP Host header injection and related password reset, cache poisoning, SSRF, and virtual host routing risks. CX Codex +1 306installs testing-for-xss-vulnerabilities-with-burpsuite Walks your agent through finding and confirming XSS in a web app, from site map to CSP bypass. Meant for authorized penetration tests. CX Codex +1 307installs analyzing-packed-malware-with-upx-unpacker This skill walks you through unpacking a disguised UPX sample and recovering the original executable for static analysis. CX Codex +1 303installs analyzing-ransomware-leak-site-intelligence Collects structured victim data from ransomware data leak sites and tracks group trends. Helps threat intelligence teams build risk assessments. CX Codex +1 303installs analyzing-ransomware-encryption-mechanisms Analyzes ransomware encryption schemes, key management routines, and file structures. Helps evaluate whether encrypted files can be recovered without paying a ransom. CX Codex +1 302installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor