Detectionmediumexperimental

PowerShell Dynamic Module Invocation Via ExportedCommands Array Index - PS Script

Detects obfuscated PowerShell scripts that enumerate Microsoft.PowerShell.Utility exported commands and invoke cmdlets indirectly by array index. This can be used to evade detections that look for explicit strings such as Invoke-RestMethod or Invoke-Expression.

Convert In Phoenix Studio

Open this Sigma rule in the converter with the YAML preloaded and ready for backend selection.

Launch
Norbert Jaśniewicz (AlphaSOC)Created Tue Oct 064ff4ad3e-9fb5-4a70-9962-d6ea58090318windows
Log Source
WindowsPowerShell Script
ProductWindows← raw: windows
CategoryPowerShell Script← raw: ps_script

Definition

Requirements: Script Block Logging must be enabled

Detection Logic
Detection Logic2 selectors
detection:
    selection_module_export_enum:
        ScriptBlockText|contains:
            - 'Get-Module '
            - 'gmo '
        ScriptBlockText|contains|all:
            - 'ListAvailable'
            - 'Microsoft.PowerShell.Utility'
            - 'ExportedCommands'
            - 'Values'
    selection_index_used:
        ScriptBlockText|contains: '[*]'
    condition: all of selection_*
False Positives

Legitimate use of exported commands array indexing in PowerShell scripts (should be rare)

Testing & Validation

Regression Tests

by Swachchhanda Shrawan Poudel (Nextron Systems)
Positive Detection Test1 matchevtx

Microsoft-Windows-Sysmon