Aller au contenu
Skillpedia
Déploiement et cloud (DevOps)35k · #7777

deobfuscating-powershell-obfuscated-malware

Ce qu’il fait

Cet outil aide à mettre au jour du code PowerShell malveillant qui a été caché (obfusqué). Il analyse le code, exécute prudemment certaines parties et utilise d'autres outils pour révéler ce que le code fait réellement, par exemple voler des informations ou communiquer avec des serveurs malveillants.

Quand l’utiliser

  • ✓Lorsque vous trouvez un script PowerShell suspect et que vous voulez savoir ce qu'il fait.
  • ✓Lorsque vous analysez un ordinateur après une attaque pour comprendre comment le logiciel malveillant a agi.
  • ✓Lors de tests de sécurité autorisés, pour vérifier si un système est vulnérable à ce type d'attaque.

Lien du skill

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

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/deobfuscating-powershell-obfuscated-malware/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Désobfusque ce script PowerShell malveillant : [collez le script ici]”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'outil analyse la structure du code PowerShell, identifie la manière dont il a été dissimulé (encodage, assemblage de textes, etc.) et tente d'annuler ces techniques. Il peut exécuter certaines parties du code dans un environnement sécurisé pour voir le résultat final.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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:

…
Questions fréquentes

Qu'est-ce que l'« obfuscation » dans le code ?

C'est un peu comme cacher un message en brouillant les lettres ou en utilisant des codes secrets. Dans PowerShell, les auteurs de logiciels malveillants s'en servent pour rendre leur code plus difficile à détecter par les logiciels de sécurité.

Pourquoi PowerShell est-il utilisé par les logiciels malveillants ?

PowerShell est un outil puissant, déjà installé sur Windows, capable d'effectuer de nombreuses tâches système. Il est donc utile aussi bien aux administrateurs qu'aux attaquants.

Est-il sûr d'utiliser cet outil ?

L'outil est conçu pour être utilisé dans un environnement sécurisé (comme une machine virtuelle isolée) afin d'éviter que le logiciel malveillant ne cause des dégâts. Il cherche à révéler le code sans l'exécuter de manière dangereuse.

Détails

Description originale de l’auteur

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

Popularité

Étoiles GitHub
35k
Position au classement
#7777
Licence
Apache-2.0
Mis à jour
31/08/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires