Windows PowerShell Inline Execution via File Reads and Raw Parameters
Alerts on PowerShell command lines that inline-execute content read from files using -raw.
FreeUnreviewedSigmamediumv1
windows-powershell-inline-execution-via-file-reads-and-raw-parameters-ee218c12
title: Windows PowerShell Inline Execution via File Reads and Raw Parameters
id: 5daa22f6-89a4-4e39-b955-78286eb29093
status: test
description: This rule flags PowerShell process command lines that include inline execution-related commands (such as iex or Invoke-Expression/Invoke-Command variants) combined with file content reading indicators (cat/Get-Content/type) and a raw parameter (" -raw"). Attackers commonly use this pattern to execute dynamically loaded code while minimizing artifacts and leveraging standard PowerShell functionality. It relies on Windows process creation telemetry, specifically the CommandLine content of spawned PowerShell processes.
references:
- https://speakerdeck.com/heirhabarov/hunting-for-powershell-abuse?slide=50
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/proc_creation_win_powershell_exec_data_file.yml
author: frack113, Huntrule Team
date: 2022-12-25
tags:
- attack.execution
- attack.t1059.001
logsource:
product: windows
category: process_creation
detection:
selection_exec:
CommandLine|contains:
- "iex "
- "Invoke-Expression "
- "Invoke-Command "
- "icm "
selection_read:
CommandLine|contains:
- "cat "
- "get-content "
- "type "
selection_raw:
CommandLine|contains: " -raw"
condition: all of selection_*
falsepositives:
- Unknown
level: medium
license: DRL-1.1
related:
- id: ee218c12-627a-4d27-9e30-d6fb2fe22ed2
type: derived
What it detects
This rule flags PowerShell process command lines that include inline execution-related commands (such as iex or Invoke-Expression/Invoke-Command variants) combined with file content reading indicators (cat/Get-Content/type) and a raw parameter (" -raw"). Attackers commonly use this pattern to execute dynamically loaded code while minimizing artifacts and leveraging standard PowerShell functionality. It relies on Windows process creation telemetry, specifically the CommandLine content of spawned PowerShell processes.
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.