Detection rules › Sigma

PSScriptPolicyTest Creation By Uncommon Process

Status
test
Severity
medium
Log source
category file_event, product windows
Author
Nasreddine Bencherchali (Nextron Systems)
Source
github.com/SigmaHQ/sigma

Detects the creation of the "PSScriptPolicyTest" PowerShell script by an uncommon process. This file is usually generated by Microsoft Powershell to test against Applocker.

MITRE ATT&CK coverage

TacticTechniques
StealthNo specific technique

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 11: FileCreate

Rule body

title: PSScriptPolicyTest Creation By Uncommon Process
id: 1027d292-dd87-4a1a-8701-2abe04d7783c
status: test
description: Detects the creation of the "PSScriptPolicyTest" PowerShell script by an uncommon process. This file is usually generated by Microsoft Powershell to test against Applocker.
references:
    - https://www.paloaltonetworks.com/blog/security-operations/stopping-powershell-without-powershell/
author: Nasreddine Bencherchali (Nextron Systems)
date: 2023-06-01
modified: 2026-07-28
tags:
    - attack.stealth
logsource:
    product: windows
    category: file_event
detection:
    selection:
        TargetFilename|contains: '__PSScriptPolicyTest_'
    filter_main_powershell:
        Image:
            - 'C:\Program Files\PowerShell\7-preview\pwsh.exe'
            - 'C:\Program Files\PowerShell\7\pwsh.exe'
            - 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe'
            - 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
            - 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell_ise.exe'
            - 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe'
    filter_main_pwsh_preview:
        Image|contains:
            - 'C:\Program Files\WindowsApps\Microsoft.PowerShellPreview'
            - '\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShellPreview'
        Image|endswith: '\pwsh.exe'
    filter_main_generic:
        Image:
            - 'C:\Windows\System32\dsac.exe'
            - 'C:\Windows\System32\sdiagnhost.exe'
            - 'C:\Windows\System32\ServerManager.exe'
            - 'C:\Windows\System32\wsmprovhost.exe'
            - 'C:\Windows\SysWOW64\sdiagnhost.exe'
    filter_optional_gethelp:
        Image|startswith: 'C:\Program Files\WindowsApps\Microsoft.GetHelp_'
        Image|endswith: '\GetHelp.exe'
    condition: selection and not 1 of filter_main_* and not 1 of filter_optional_*
falsepositives:
    - Unknown
level: medium

Stages and Predicates

Stage 0: condition

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

Stage 1: selection

selection:
    TargetFilename|contains: '__PSScriptPolicyTest_'

Stage 2: not filter_main_*

filter_main_powershell:
    Image:
        - 'C:\Program Files\PowerShell\7-preview\pwsh.exe'
        - 'C:\Program Files\PowerShell\7\pwsh.exe'
        - 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe'
        - 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
        - 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell_ise.exe'
        - 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe'
filter_main_pwsh_preview:
    Image|contains:
        - 'C:\Program Files\WindowsApps\Microsoft.PowerShellPreview'
        - '\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShellPreview'
    Image|endswith: '\pwsh.exe'
filter_main_generic:
    Image:
        - 'C:\Windows\System32\dsac.exe'
        - 'C:\Windows\System32\sdiagnhost.exe'
        - 'C:\Windows\System32\ServerManager.exe'
        - 'C:\Windows\System32\wsmprovhost.exe'
        - 'C:\Windows\SysWOW64\sdiagnhost.exe'

Stage 3: not filter_optional_gethelp

filter_optional_gethelp:
    Image|startswith: 'C:\Program Files\WindowsApps\Microsoft.GetHelp_'
    Image|endswith: '\GetHelp.exe'

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
ImagematchC:\Program Files\WindowsApps\Microsoft.PowerShellPreviewexcludes:Image field:"Image" value:"C:\Program Files\WindowsApps\Microsoft.PowerShellPreview"
Imagematch\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShellPreviewexcludes:Image field:"Image" value:"\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShellPreview"
Imageends_with\pwsh.exeexcludes:Image field:"Image" value:"\pwsh.exe"
ImageeqC:\Program Files\PowerShell\7-preview\pwsh.exeexcludes:Image field:"Image" value:"C:\Program Files\PowerShell\7-preview\pwsh.exe"
ImageeqC:\Program Files\PowerShell\7\pwsh.exeexcludes:Image field:"Image" value:"C:\Program Files\PowerShell\7\pwsh.exe"
ImageeqC:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exeexcludes:Image field:"Image" value:"C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe"
ImageeqC:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell_ise.exeexcludes:Image field:"Image" value:"C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell_ise.exe"
ImageeqC:\Windows\SysWOW64\sdiagnhost.exeexcludes:Image field:"Image" value:"C:\Windows\SysWOW64\sdiagnhost.exe"
ImageeqC:\Windows\System32\ServerManager.exeexcludes:Image field:"Image" value:"C:\Windows\System32\ServerManager.exe"
ImageeqC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exeexcludes:Image field:"Image" value:"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
ImageeqC:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exeexcludes:Image field:"Image" value:"C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe"
ImageeqC:\Windows\System32\dsac.exeexcludes:Image field:"Image" value:"C:\Windows\System32\dsac.exe"
ImageeqC:\Windows\System32\sdiagnhost.exeexcludes:Image field:"Image" value:"C:\Windows\System32\sdiagnhost.exe"
ImageeqC:\Windows\System32\wsmprovhost.exeexcludes:Image field:"Image" value:"C:\Windows\System32\wsmprovhost.exe"
Imageends_with\GetHelp.exeexcludes:Image field:"Image" value:"\GetHelp.exe"
Imagestarts_withC:\Program Files\WindowsApps\Microsoft.GetHelp_excludes:Image field:"Image" value:"C:\Program Files\WindowsApps\Microsoft.GetHelp_"

Indicators

These rows show field, operator, and value matches.