PowerShell WMI Service Enumeration for Unquoted Service Path Recon

Flags PowerShell WMI queries for Win32_Service fields to enumerate potential unquoted service path issues.

FreeUnreviewedSigmamediumv1
title: PowerShell WMI Service Enumeration for Unquoted Service Path Recon
id: 80b07b9c-b5ae-410a-8d74-cc0fa7497364
related:
  - id: 68bcd73b-37ef-49cb-95fc-edc809730be6
    type: similar
  - id: 09658312-bc27-4a3b-91c5-e49ab9046d1b
    type: derived
status: test
description: This rule identifies PowerShell script block content that uses WMI queries (Get-WmiObject/gwmi) to enumerate Win32_Service properties including Name, DisplayName, PathName, and StartMode. Attackers and pentesters commonly use this information to identify unquoted service paths that can be abused for privilege escalation. It relies on PowerShell Script Block Logging telemetry that captures ScriptBlockText matching the specified WMI query and Win32_Service field indicators.
references:
  - https://github.com/nccgroup/redsnarf/blob/35949b30106ae543dc6f2bc3f1be10c6d9a8d40e/redsnarf.py
  - https://github.com/S3cur3Th1sSh1t/Creds/blob/eac23d67f7f90c7fc8e3130587d86158c22aa398/PowershellScripts/jaws-enum.ps1
  - https://www.absolomb.com/2018-01-26-Windows-Privilege-Escalation-Guide/
  - https://github.com/SigmaHQ/sigma/blob/master/rules/windows/powershell/powershell_script/posh_ps_wmi_unquoted_service_search.yml
author: Nasreddine Bencherchali (Nextron Systems), Huntrule Team
date: 2022-06-20
modified: 2022-11-25
tags:
  - attack.execution
  - attack.t1047
logsource:
  product: windows
  category: ps_script
  definition: "Requirements: Script Block Logging must be enabled"
detection:
  selection:
    ScriptBlockText|contains:
      - "Get-WmiObject "
      - "gwmi "
    ScriptBlockText|contains|all:
      - " Win32_Service "
      - Name
      - DisplayName
      - PathName
      - StartMode
  condition: selection
falsepositives:
  - Unknown
level: medium
license: DRL-1.1

What it detects

This rule identifies PowerShell script block content that uses WMI queries (Get-WmiObject/gwmi) to enumerate Win32_Service properties including Name, DisplayName, PathName, and StartMode. Attackers and pentesters commonly use this information to identify unquoted service paths that can be abused for privilege escalation. It relies on PowerShell Script Block Logging telemetry that captures ScriptBlockText matching the specified WMI query and Win32_Service field indicators.

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.