analyzing-powershell-script-block-logging

Parse PowerShell Event ID 4104 EVTX logs to detect obfuscated commands.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/Axxxxxxaaann/KAIRI-Skills --skill analyzing-powershell-script-block-logging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: analyzing-powershell-script-block-logging
Source: https://github.com/Axxxxxxaaann/KAIRI-Skills/tree/main/skills/analyzing-powershell-script-block-logging
Command: npx skills add https://github.com/Axxxxxxaaann/KAIRI-Skills --skill analyzing-powershell-script-block-logging

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires python-evtx, lxml, and includes scripts (resource) and references (resource) components.

What problem does it solve?

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.

Core Features & Use Cases

  • Reconstruct multi-part ScriptBlockText from Event 4104 entries
  • Detect suspicious patterns such as -EncodedCommand, FromBase64String, Invoke-Expression, and AMSI bypass indicators
  • Entropy-based obfuscation detection and comprehensive reporting (including script previews and MITRE mappings)

Quick Start

Run the PowerShell Script Block Logging Analyzer on a PowerShell Operational EVTX file to reconstruct scripts and generate a findings report.

Frequently Asked Questions about analyzing-powershell-script-block-logging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I parse PowerShell Script Block logs from EVTX files for threat hunting?

You can parse PowerShell EVTX files by extracting Event ID 4104 entries to detect obfuscated commands and encoded payloads. The tool uses python-evtx to read EVTX files and reconstructs multi-block scripts by matching ScriptBlockId with MessageNumber and MessageTotal fields.

How does entropy analysis detect obfuscated PowerShell commands in Event 4104 logs?

Entropy analysis detects obfuscated PowerShell commands by measuring randomness in ScriptBlockText. High entropy scores indicate potential Base64-encoded payloads, which are then flagged alongside pattern matches for -EncodedCommand, FromBase64String, and Invoke-Expression abuse.

Do I need Python and specific dependencies to analyze PowerShell Operational EVTX files?

Yes, you need Python 3.8 or higher with the python-evtx and lxml dependencies installed to analyze PowerShell Operational EVTX files. These libraries handle EVTX parsing and XML processing for extracting and reconstructing ScriptBlockText.

Can I reconstruct multi-part PowerShell scripts split across multiple Event 4104 entries?

Yes, you can reconstruct multi-part PowerShell scripts split across multiple Event 4104 entries. The analyzer groups ScriptBlockText fragments by their ScriptBlockId and orders them using the MessageNumber and MessageTotal fields to rebuild the complete script.

What suspicious patterns can I detect in PowerShell Script Block logs during an incident investigation?

During an incident investigation, you can detect suspicious patterns in PowerShell Script Block logs including -EncodedCommand, FromBase64String, Invoke-Expression, AMSI bypass attempts, and download cradles, providing actionable findings with MITRE mappings.