Detection rules › Sigma

Non Interactive PowerShell Process Spawned

Status
test
Severity
low
Log source
category process_creation, product windows
Author
Roberto Rodriguez @Cyb3rWard0g (rule), oscd.community (improvements)
Source
github.com/SigmaHQ/sigma

Detects non-interactive PowerShell activity by looking at the "powershell" process with a non-user GUI process such as "explorer.exe" as a parent.

Known false positives

  • Likely. Many admin scripts and tools leverage PowerShell in their BAT or VB scripts which may trigger this rule often. It is best to add additional filters or use this to hunt for anomalies

MITRE ATT&CK coverage

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

title: Non Interactive PowerShell Process Spawned
id: f4bbd493-b796-416e-bbf2-121235348529
status: test
description: Detects non-interactive PowerShell activity by looking at the "powershell" process with a non-user GUI process such as "explorer.exe" as a parent.
references:
    - https://web.archive.org/web/20200925032237/https://threathunterplaybook.com/notebooks/windows/02_execution/WIN-190410151110.html
author: Roberto Rodriguez @Cyb3rWard0g (rule), oscd.community (improvements)
date: 2019-09-12
modified: 2025-02-28
tags:
    - attack.execution
    - attack.t1059.001
logsource:
    category: process_creation
    product: windows
detection:
    selection:
        - Image|endswith:
              - '\powershell.exe'
              - '\pwsh.exe'
        - OriginalFileName:
              - 'PowerShell.EXE'
              - 'pwsh.dll'
    filter_main_generic:
        ParentImage|endswith:
            - ':\Windows\explorer.exe'
            - ':\Windows\System32\CompatTelRunner.exe'
            - ':\Windows\SysWOW64\explorer.exe'
    filter_main_windows_update:
        ParentImage: ':\$WINDOWS.~BT\Sources\SetupHost.exe' # During Windows updates/upgrades
        # CommandLine: powershell.exe -ExecutionPolicy Restricted -Command Write-Host 'Final result: 1';
    filter_optional_vscode:
        # Triggered by VsCode when you open a Shell inside the workspace
        ParentImage|endswith: '\AppData\Local\Programs\Microsoft VS Code\Code.exe'
        ParentCommandLine|contains: ' --ms-enable-electron-run-as-node '
    filter_optional_terminal:
        ParentImage|contains: ':\Program Files\WindowsApps\Microsoft.WindowsTerminal_'
        ParentImage|endswith: '\WindowsTerminal.exe'
    filter_optional_defender:
        ParentImage|endswith: ':\Program Files\Windows Defender Advanced Threat Protection\SenseIR.exe'
    condition: selection and not 1 of filter_main_* and not 1 of filter_optional_*
falsepositives:
    - Likely. Many admin scripts and tools leverage PowerShell in their BAT or VB scripts which may trigger this rule often. It is best to add additional filters or use this to hunt for anomalies
level: low

Stages and Predicates

Stage 0: condition

selection and not 1 of filter_main_* and not 1 of filter_optional_*

Stage 1: selection

selection:
    - Image|endswith:
          - '\powershell.exe'
          - '\pwsh.exe'
    - OriginalFileName:
          - 'PowerShell.EXE'
          - 'pwsh.dll'

Stage 2: not filter_main_*

filter_main_generic:
    ParentImage|endswith:
        - ':\Windows\explorer.exe'
        - ':\Windows\System32\CompatTelRunner.exe'
        - ':\Windows\SysWOW64\explorer.exe'
filter_main_windows_update:
    ParentImage: ':\$WINDOWS.~BT\Sources\SetupHost.exe'

Stage 3: not filter_optional_*

filter_optional_vscode:
    ParentImage|endswith: '\AppData\Local\Programs\Microsoft VS Code\Code.exe'
    ParentCommandLine|contains: ' --ms-enable-electron-run-as-node '
filter_optional_terminal:
    ParentImage|contains: ':\Program Files\WindowsApps\Microsoft.WindowsTerminal_'
    ParentImage|endswith: '\WindowsTerminal.exe'
filter_optional_defender:
    ParentImage|endswith: ':\Program Files\Windows Defender Advanced Threat Protection\SenseIR.exe'

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
ParentImageends_with:\Windows\SysWOW64\explorer.exeexcludes:ParentImage field:"ParentImage" value:":\Windows\SysWOW64\explorer.exe"
ParentImageends_with:\Windows\System32\CompatTelRunner.exeexcludes:ParentImage field:"ParentImage" value:":\Windows\System32\CompatTelRunner.exe"
ParentImageends_with:\Windows\explorer.exeexcludes:ParentImage field:"ParentImage" value:":\Windows\explorer.exe"
ParentImageeq:\$WINDOWS.~BT\Sources\SetupHost.exeexcludes:ParentImage field:"ParentImage" value:":\$WINDOWS.~BT\Sources\SetupHost.exe"
ParentCommandLinematch --ms-enable-electron-run-as-node excludes:ParentCommandLine field:"ParentCommandLine" value:" --ms-enable-electron-run-as-node "
ParentImageends_with\AppData\Local\Programs\Microsoft VS Code\Code.exeexcludes:ParentImage field:"ParentImage" value:"\AppData\Local\Programs\Microsoft VS Code\Code.exe"
ParentImageends_with\WindowsTerminal.exeexcludes:ParentImage field:"ParentImage" value:"\WindowsTerminal.exe"
ParentImagematch:\Program Files\WindowsApps\Microsoft.WindowsTerminal_excludes:ParentImage field:"ParentImage" value:":\Program Files\WindowsApps\Microsoft.WindowsTerminal_"
ParentImageends_with:\Program Files\Windows Defender Advanced Threat Protection\SenseIR.exeexcludes:ParentImage field:"ParentImage" value:":\Program Files\Windows Defender Advanced Threat Protection\SenseIR.exe"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
Imageends_with
  • \powershell.exe corpus 179 (sigma 178, kusto 1)
  • \pwsh.exe corpus 165 (sigma 164, kusto 1)
field:"Image" kind:ends_with
OriginalFileNameeq
  • PowerShell.EXE corpus 138 (sigma 84, splunk 30, elastic 24)
  • pwsh.dll corpus 112 (sigma 79, splunk 30, elastic 3)
field:"OriginalFileName" kind:eq