Skip to content

meltedinhex/analyst-ai-pack / skills/deobfuscating-malicious-powershell

deobfuscating-malicious-powershell

Verified

Deobfuscates malicious PowerShell by decoding -EncodedCommand, reversing string and format obfuscation, resolving base64/gzip/IEX layers, and recovering the final payload and IOCs. Activates for requests to deobfuscate, decode, or analyze obfuscated PowerShell commands or scripts.

FileKindSize
LICENSEother340 B
SKILL.mdskill md3.4 KB
references/api-reference.mdmarkdown1.4 KB
scripts/analyst.pyscript3.2 KB

references/api-reference.md

View on GitHub
# API Reference: Deobfuscating Malicious PowerShell

## Overview

`scripts/analyst.py` decodes `-EncodedCommand` (base64 UTF-16LE), peels nested base64 plus
gzip/deflate layers, neutralizes execution sinks (`IEX`, `Invoke-Expression`), and extracts
URLs. It never runs PowerShell.

## Dependencies

| Package | Version | Purpose |
|---------|---------|---------|
| (stdlib) | — | base64, gzip, zlib, regex |

## External tools

| Tool | Purpose |
|------|---------|
| PSDecode | Emulated unrolling of heavily layered scripts |
| CyberChef | Interactive multi-step decoding |

## Core functions

### `decode_encodedcommand(b64)`
Decodes a `-EncodedCommand`/`-enc` blob (base64 of UTF-16LE) to text.

### `peel_layers(text, max_depth)`
Iteratively decodes the largest base64 blob and attempts gzip/deflate/UTF-16 decompression,
returning each layer.

### `neutralize(text)`
Replaces `IEX`/`Invoke-Expression` with output statements so recovered scripts are not run.

### `extract_iocs(text)`
Collects URLs across all decoded layers.

## Usage

```bash
python scripts/analyst.py decode --encodedcommand "<base64>"
python scripts/analyst.py deobfuscate payload.ps1
```

## Sources

- PowerShell `-EncodedCommand` semantics (UTF-16LE base64) — https://learn.microsoft.com/powershell/
- PSDecode — https://github.com/R3MRUM/PSDecode
- Common PowerShell obfuscation transforms (format operator, char codes, reversal)
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall