Deobfuscating malicious powershell

From meltedinhex/analyst-ai-pack · View interactive version

Deobfuscating malicious powershell is an AI agent skill from the GitHub repository meltedinhex/analyst-ai-pack. 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.

How to use this skill

Skill file

Deobfuscating Malicious PowerShell

When to Use

Do not use Invoke-Expression or run the script to "see what it does" on a working host.

Decode statically; only execute in the isolated lab with logging if dynamic confirmation is

required.

Prerequisites

Safety & Handling

output (print) when transforming.

Workflow

Step 1: Decode -EncodedCommand

-EncodedCommand (-enc) is base64 of UTF-16LE. Decode it first:

python scripts/analyst.py decode --encodedcommand "<base64>"

Step 2: Identify the obfuscation style

Common patterns:

String reversal      : [array]::Reverse / -join with [-1..]
Format operator      : ("{1}{0}" -f 'b','a') -> 'ab'
Char codes           : [char]104 + [char]105
Concatenation/splits : 'po'+'wer'+'shell', -split / -replace tricks
Backtick/casing noise : I`E`X, iEx, &('i'+'ex')

Step 3: Unroll encoding layers

Resolve nested FromBase64String, gzip/deflate (IO.Compression), and re-IEX layers until

you reach plain script. The script peels base64/gzip layers automatically.

python scripts/analyst.py deobfuscate payload.ps1

Step 4: Neutralize execution sinks

Replace IEX, Invoke-Expression, &, and .Invoke() with a print so the recovered script

is rendered, not run.

Step 5: Extract IOCs

Pull DownloadString/DownloadFile URLs, C2 hosts, dropped paths, and any embedded

base64 shellcode for separate analysis.

Validation

Pitfalls

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.