Windows Security Event 4697 PowerShell Launch via cmd/stdin Obfuscation
Alerts on service creation events that run PowerShell through cmd with stdin-style obfuscation markers.
- Product
- windows
- Service
- security
- Author
- Jonathan Cheong, oscd.community (SigmaHQ), DRL 1.1
- Published
- 2020-10-15
- Updated
- 2026-07-31
ATT&CK techniques
Execution → Defense EvasionRecon
Resource Dev
Initial Access
Execution
Persistence
Priv Esc
Defense Evasion
Cred Access
Discovery
Lateral Movement
Collection
C2
Exfiltration
Impact
What it detects
This rule flags Windows systems where a Service Control Manager-created service (EventID 4697) contains a command-line referencing cmd and PowerShell, including patterns consistent with obfuscated stdin-driven execution. Attackers may use stdin or stdin-like constructs to conceal the final command or payload before execution, reducing visibility during investigation. It relies on Security log telemetry from EventID 4697 and string matches within the recorded ServiceFileName content.
Reporting behind it
Changelog
v2- v2Candidate ingested via manual entry.2026-07-31
- v1No changelog recorded for this version.2026-07-30
Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.
title: Windows Security Event 4697 PowerShell Launch via cmd/stdin Obfuscation
id: ab8abae0-89f5-4ed7-95c3-ef38015daf5c
related:
- id: 72862bf2-0eb1-11eb-adc1-0242ac120002
type: derived
- id: 0c718a5e-4284-4fb9-b4d9-b9a50b3a1974
type: derived
status: test
description: This rule flags Windows systems where a Service Control Manager-created service (EventID 4697) contains a command-line referencing cmd and PowerShell, including patterns consistent with obfuscated stdin-driven execution. Attackers may use stdin or stdin-like constructs to conceal the final command or payload before execution, reducing visibility during investigation. It relies on Security log telemetry from EventID 4697 and string matches within the recorded ServiceFileName content.
references:
- https://github.com/SigmaHQ/sigma/issues/1009
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/builtin/security/win_security_invoke_obfuscation_stdin_services_security.yml
author: Jonathan Cheong, oscd.community, Huntrule Team
date: 2020-10-15
modified: 2022-11-29
tags:
- attack.stealth
- attack.t1027
- attack.execution
- attack.t1059.001
logsource:
product: windows
service: security
definition: The 'System Security Extension' audit subcategory need to be enabled to log the EID 4697
detection:
selection:
EventID: 4697
ServiceFileName|contains|all:
- cmd
- powershell
selection2:
ServiceFileName|contains:
- ${input}
- noexit
selection3:
ServiceFileName|contains:
- " /c "
- " /r "
condition: all of selection*
falsepositives:
- Unknown
level: high
license: DRL-1.1