Windows Security Event 4697: Obfuscated PowerShell Invocation Through Stdin

Alerts on Service creation events where the service command line includes stdin-style PowerShell obfuscation indicators.

FreeReviewedSigma · High · v2
Product
windows
Service
security
Author
Nikita Nazarov, oscd.community (SigmaHQ), DRL 1.1
Published
2020-10-12
Updated
2026-07-31
title: "Windows Security Event 4697: Obfuscated PowerShell Invocation Through Stdin"
id: b6273dd9-0629-400a-9b5c-c9244d90212d
related:
  - id: 487c7524-f892-4054-b263-8a0ace63fc25
    type: derived
  - id: 80b708f3-d034-40e4-a6c8-d23b7a7db3d1
    type: derived
status: test
description: This rule flags Windows service installation events (Event ID 4697) where the service file command line appears to include PowerShell invocation patterns combined with standard input style input placeholders. Attackers often use obfuscated PowerShell to evade detection while executing payloads, and abusing stdin can help deliver encoded or hidden commands. The detection relies on telemetry from the Windows Security log (System Security Extension auditing for EID 4697) capturing the service file name/command line string.
references:
  - https://github.com/SigmaHQ/sigma/issues/1009
  - https://github.com/SigmaHQ/sigma/blob/master/rules/windows/builtin/security/win_security_invoke_obfuscation_via_stdin_services_security.yml
author: Nikita Nazarov, oscd.community, Huntrule Team
date: 2020-10-12
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:
      - set
      - "&&"
    ServiceFileName|contains:
      - environment
      - invoke
      - ${input)
  condition: selection
falsepositives:
  - Unknown
level: high
license: DRL-1.1