PowerShell Module: Obfuscated Stdin Invoke via Chained Set-and-Invoke Expressions

Detects obfuscated PowerShell module payloads using chained set and stdin/input invoke patterns.

FreeUnreviewedSigmahighv1
title: "PowerShell Module: Obfuscated Stdin Invoke via Chained Set-and-Invoke Expressions"
id: 2981abae-a6ca-49ad-ab24-adac93d5ba50
related:
  - id: 86b896ba-ffa1-4fea-83e3-ee28a4c915c7
    type: derived
  - id: c72aca44-8d52-45ad-8f81-f96c4d3c755e
    type: derived
status: test
description: This rule flags PowerShell module activity where the script payload contains obfuscated chained expressions that combine multiple `set` operations with an environment/input reference and a subsequent invoke pattern. Attackers may use this kind of stdin-driven obfuscation to conceal command intent while still routing data into execution. The detection relies on Windows PowerShell module telemetry that captures the `Payload` text and matches a case-insensitive regular expression for the chained set/input/invoke structure.
references:
  - https://github.com/SigmaHQ/sigma/issues/1009
  - https://github.com/SigmaHQ/sigma/blob/master/rules/windows/powershell/powershell_module/posh_pm_invoke_obfuscation_via_stdin.yml
author: Nikita Nazarov, oscd.community, Huntrule Team
date: 2020-10-12
modified: 2024-04-05
tags:
  - attack.stealth
  - attack.t1027
  - attack.execution
  - attack.t1059.001
logsource:
  product: windows
  category: ps_module
  definition: 0ad03ef1-f21b-4a79-8ce8-e6900c54b65b
detection:
  selection_4103:
    Payload|re: (?i)(set).*&&\s?set.*(environment|invoke|\$?\{?input).*&&.*"
  condition: selection_4103
falsepositives:
  - Unknown
level: high
license: DRL-1.1

What it detects

This rule flags PowerShell module activity where the script payload contains obfuscated chained expressions that combine multiple `set` operations with an environment/input reference and a subsequent invoke pattern. Attackers may use this kind of stdin-driven obfuscation to conceal command intent while still routing data into execution. The detection relies on Windows PowerShell module telemetry that captures the `Payload` text and matches a case-insensitive regular expression for the chained set/input/invoke structure.

Known false positives

  • Unknown

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.