Zum Inhalt springen
Skillpedia
Deployment & Cloud (DevOps)35k · #7777

deobfuscating-powershell-obfuscated-malware

Was er macht

Dieses Tool hilft dir, schädlichen PowerShell-Code aufzudecken, der verschleiert wurde. Es analysiert den Code, führt Teile davon sicher aus und nutzt weitere Tools, um herauszufinden, was der Code tatsächlich macht, zum Beispiel Daten stehlen oder mit schädlichen Servern kommunizieren.

Wann du ihn nutzt

  • ✓Wenn du ein verdächtiges PowerShell-Skript findest und wissen willst, was es macht.
  • ✓Wenn du nach einem Angriff einen Computer analysierst, um zu verstehen, wie die Malware vorgegangen ist.
  • ✓Bei autorisierten Sicherheitstests, um zu prüfen, ob ein System für diese Art von Angriff anfällig ist.

Link zum Skill

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/deobfuscating-powershell-obfuscated-malware/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/deobfuscating-powershell-obfuscated-malware/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Entschlüssle dieses schädliche PowerShell-Skript: [Skript hier einfügen]”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Das Tool analysiert den Aufbau des PowerShell-Codes und erkennt, wie er verschleiert wurde (etwa durch Kodierung oder das Zusammenfügen von Textteilen). Danach versucht es, diese Techniken umzukehren. Es kann Teile des Codes in einer sicheren Umgebung ausführen, um das Endergebnis zu sehen.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

Deobfuscating PowerShell Obfuscated Malware

Overview

PowerShell is heavily abused by malware authors due to its deep Windows integration and powerful scripting capabilities. Obfuscation techniques include string concatenation, Base64 encoding, character substitution, Invoke-Expression layering, SecureString abuse, environment variable manipulation, and tick-mark insertion. Modern malware uses multiple obfuscation layers requiring iterative deobfuscation. Tools like PSDecode, PowerDecode, and PowerPeeler automate much of this process, while manual AST (Abstract Syntax Tree) analysis handles custom obfuscation. PowerPeeler achieves a 95% deobfuscation correctness rate using instruction-level dynamic analysis of expression-related AST nodes.

When to Use

  • When performing authorized security testing that involves deobfuscating powershell obfuscated malware
  • When analyzing malware samples or attack artifacts in a controlled environment
  • When conducting red team exercises or penetration testing engagements
  • When building detection capabilities based on offensive technique understanding

Prerequisites

  • Python 3.9+ with base64, re, subprocess modules
  • PowerShell 5.1+ or PowerShell 7+ (for AST access)
  • PSDecode (Install-Module PSDecode)
  • PowerDecode (https://github.com/Malandrone/PowerDecode)
  • Isolated VM or sandbox for safe script execution
  • CyberChef for manual encoding transformations
  • Understanding of PowerShell AST and Invoke-Expression patterns

Key Concepts

Common Obfuscation Techniques

PowerShell malware employs layered obfuscation to evade static detection. String concatenation splits commands across variables ($a='In'+'voke'). Base64 encoding wraps entire scripts in -EncodedCommand parameters. Character code arrays use [char] casting ([char[]](73,69,88)|%{$r+=$_}). Environment variable abuse reads substrings from $env: paths. Tick-mark insertion adds backticks between characters that PowerShell ignores (Invoke-Expression`). SecureString conversion encrypts strings using ConvertTo-SecureString with embedded keys.

AST-Based Deobfuscation

PowerShell's Abstract Syntax Tree exposes the parsed structure of scripts regardless of surface-level obfuscation. By walking the AST and evaluating expression nodes, analysts can resolve concatenated strings, decode encoded values, and reconstruct the original commands. PowerPeeler uses this approach at the instruction level, monitoring the execution process to correlate AST nodes with their evaluated results.

Dynamic Execution Tracing

By replacing Invoke-Expression (IEX) with Write-Output, analysts can safely capture the deobfuscated script content that would normally be executed. This technique works across multiple layers by iteratively replacing IEX calls until the final payload is revealed.

Workflow

Step 1: Identify Obfuscation Layers

#!/usr/bin/env python3
"""Identify and classify PowerShell obfuscation techniques."""
import re
import base64
import sys


def analyze_obfuscation(script_content):
    """Identify obfuscation techniques used in PowerShell script."""
    techniques = []

    # Check for Base64 encoded command
    b64_pattern = re.compile(
        r'-[Ee](?:nc(?:odedcommand)?)\s+([A-Za-z0-9+/=]{20,})',
        re.IGNORECASE
    )
    if b64_pattern.search(script_content):
        techniques.append("Base64 EncodedCommand")

    # Check for FromBase64String
    if re.search(r'\[Convert\]::FromBase64String', script_content, re.IGNORECASE):
        techniques.append("Base64 FromBase64String")

    # Check for string concatenation
    concat_count = script_content.count("'+'") + script_content.count('"+"')
    if concat_count > 3:
        techniques.append(f"String Concatenation ({concat_count} joins)")

    # Check for char array construction
    if re.search(r'\[char\]\s*\d+', script_content, re.IGNORECASE):
        techniques.append("Character Code Array")

    # Check for Invoke-Expression variants
    iex_patterns = [
        r'Invoke-Expression',
        r'\bIEX\b',
        r'\.\s*\(\s*\$',
        r'&\s*\(\s*\$',
        r'\|\s*IEX',
        r'\|\s*Invoke-Expression',
    ]
    for pattern in iex_patterns:
        if re.search(pattern, script_content, re.IGNORECASE):
            techniques.append(f"Invoke-Expression variant: {pattern}")

    # Check for tick-mark obfuscation
    tick_count = script_content.count('`')
    if tick_count > 5:

…
Häufige Fragen

Was bedeutet „Verschleierung“ bei Code?

Das ist vergleichbar mit einer Nachricht, die du durch vertauschte Buchstaben oder geheime Codes versteckst. In PowerShell nutzen Malware-Entwickler das, damit Sicherheitssoftware den schädlichen Code schwerer erkennt.

Warum nutzt Malware PowerShell?

Weil PowerShell ein mächtiges Werkzeug ist, das auf Windows bereits vorinstalliert ist und viele Systemaufgaben erledigen kann. Das macht es sowohl für Administratoren als auch für Angreifer nützlich.

Ist es sicher, dieses Tool zu verwenden?

Das Tool ist für eine sichere Umgebung gedacht, etwa eine isolierte virtuelle Maschine, damit die eigentliche Malware keinen Schaden anrichten kann. Es versucht, den Code aufzudecken, ohne ihn gefährlich auszuführen.

Details

Originalbeschreibung des Autors

Systematically deobfuscates multi-layer PowerShell malware using AST analysis, dynamic tracing, and tools like PSDecode and PowerDecode to reveal hidden payloads and C2 infrastructure. Use during incident response or malware analysis when a PowerShell script is obfuscated with encoding, string manipulation, or invocation tricks and you need to recover the underlying commands, dropped payloads, or

repo: mukul975/Anthropic-Cybersecurity-Skills

Beliebtheit

GitHub-Sterne
35k
Platz im Ranking
#7777
Lizenz
Apache-2.0
Aktualisiert
31.8.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills