Windows System Service Creation with Obfuscated PowerShell IEX Invocation Patterns

Flags Windows service creations whose ImagePath contains obfuscated PowerShell IEX invocation strings.

FreeUnreviewedSigmahighv1
title: Windows System Service Creation with Obfuscated PowerShell IEX Invocation Patterns
id: e444e4a5-e628-4f04-9eac-e361d63fb106
status: test
description: This rule identifies Windows system service creation events whose ImagePath matches patterns associated with obfuscated PowerShell IEX invocation code produced by Invoke-Obfuscation. Service creation with embedded obfuscated commands is a stealth technique attackers can use to execute PowerShell without clear command text. The detection relies on System telemetry, specifically EventID 7045 fields that contain the service ImagePath content.
references:
  - https://github.com/danielbohannon/Invoke-Obfuscation/blob/f20e7f843edd0a3a7716736e9eddfa423395dd26/Out-ObfuscatedStringCommand.ps1#L873-L888
  - https://github.com/SigmaHQ/sigma/blob/master/rules/windows/builtin/system/service_control_manager/win_system_invoke_obfuscation_obfuscated_iex_services.yml
author: Daniel Bohannon (@Mandiant/@FireEye), oscd.community, Huntrule Team
date: 2019-11-08
modified: 2022-11-27
tags:
  - attack.stealth
  - attack.t1027
logsource:
  product: windows
  service: system
detection:
  selection_eid:
    EventID: 7045
  selection_imagepath:
    - ImagePath|re: \$PSHome\[\s*\d{1,3}\s*\]\s*\+\s*\$PSHome\[
    - ImagePath|re: \$ShellId\[\s*\d{1,3}\s*\]\s*\+\s*\$ShellId\[
    - ImagePath|re: \$env:Public\[\s*\d{1,3}\s*\]\s*\+\s*\$env:Public\[
    - ImagePath|re: \$env:ComSpec\[(\s*\d{1,3}\s*,){2}
    - ImagePath|re: \\*mdr\*\W\s*\)\.Name
    - ImagePath|re: \$VerbosePreference\.ToString\(
    - ImagePath|re: \String\]\s*\$VerbosePreference
  condition: all of selection_*
falsepositives:
  - Unknown
level: high
license: DRL-1.1
related:
  - id: 51aa9387-1c53-4153-91cc-d73c59ae1ca9
    type: derived

What it detects

This rule identifies Windows system service creation events whose ImagePath matches patterns associated with obfuscated PowerShell IEX invocation code produced by Invoke-Obfuscation. Service creation with embedded obfuscated commands is a stealth technique attackers can use to execute PowerShell without clear command text. The detection relies on System telemetry, specifically EventID 7045 fields that contain the service ImagePath content.

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.