PowerShell Obfuscation Through stdin via ScriptBlockText
Detects obfuscated PowerShell script blocks that use chained stdin/environment/input patterns.
FreeUnreviewedSigmahighv1
powershell-obfuscation-through-stdin-via-scriptblocktext-86b896ba
title: PowerShell Obfuscation Through stdin via ScriptBlockText
id: 9cc577c9-de1c-4b41-a05f-2a3c9d1b2c95
status: test
description: This rule flags PowerShell script blocks where the ScriptBlockText contains patterns consistent with chained commands that manipulate environment/input and invoke activity using stdin. Attackers often use obfuscation and stdin-driven input to hinder analysis and execute logic indirectly. The detection relies on ScriptBlockText content from PowerShell script block logging, matching a case-insensitive regular expression over the script block text.
references:
- https://github.com/SigmaHQ/sigma/issues/1009
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/powershell/powershell_script/posh_ps_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_script
definition: "Requirements: Script Block Logging must be enabled"
detection:
selection_4104:
ScriptBlockText|re: (?i)(set).*&&\s?set.*(environment|invoke|\$\{?input).*&&.*"
condition: selection_4104
falsepositives:
- Unknown
level: high
license: DRL-1.1
related:
- id: 86b896ba-ffa1-4fea-83e3-ee28a4c915c7
type: derived
What it detects
This rule flags PowerShell script blocks where the ScriptBlockText contains patterns consistent with chained commands that manipulate environment/input and invoke activity using stdin. Attackers often use obfuscation and stdin-driven input to hinder analysis and execute logic indirectly. The detection relies on ScriptBlockText content from PowerShell script block logging, matching a case-insensitive regular expression over the script block text.
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.