Windows Security 4697: Obfuscated PowerShell Execution via rundll32/shell32.dll

Alert on Security EID 4697 where service installation references rundll32/shell32.dll to launch PowerShell.

FreeUnreviewedSigmamediumv1
title: "Windows Security 4697: Obfuscated PowerShell Execution via rundll32/shell32.dll"
id: 0f5a6917-77a4-46a8-991e-3101ab1e3664
related:
  - id: 11b52f18-aaec-4d60-9143-5dd8cc4706b9
    type: derived
  - id: f241cf1b-3a6b-4e1a-b4f9-133c00dd95ca
    type: derived
status: test
description: This rule flags Windows Security audit Event ID 4697 when a service is installed with a binary path containing rundll32.exe, shell32.dll, the shellexec_rundll export, and the string powershell. Attackers often use rundll32 with shell32 components to launch PowerShell indirectly and reduce detection by hiding the original command line. The detection relies on Security event telemetry for service-install activity (EID 4697) and string matching on the recorded ServiceFileName field.
references:
  - https://github.com/SigmaHQ/sigma/issues/1009
  - https://github.com/SigmaHQ/sigma/blob/master/rules/windows/builtin/security/win_security_invoke_obfuscation_via_rundll_services_security.yml
author: Timur Zinniatullin, oscd.community, Huntrule Team
date: 2020-10-18
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:
      - rundll32.exe
      - shell32.dll
      - shellexec_rundll
      - powershell
  condition: selection
falsepositives:
  - Unknown
level: medium
license: DRL-1.1

What it detects

This rule flags Windows Security audit Event ID 4697 when a service is installed with a binary path containing rundll32.exe, shell32.dll, the shellexec_rundll export, and the string powershell. Attackers often use rundll32 with shell32 components to launch PowerShell indirectly and reduce detection by hiding the original command line. The detection relies on Security event telemetry for service-install activity (EID 4697) and string matching on the recorded ServiceFileName field.

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.