Detection rule
Security Privileges Enumeration Via Whoami.EXE
Overview
Detects a whoami.exe executed with the /priv command line flag instructing the tool to show all current user privileges. This is often used after a privilege escalation attempt.
- Rule id
97a80ec7-0e2f-4d05-9ef4-65760e634f6b- ATT&CK techniques
- T1033 System Owner/User Discovery
- Severity
- High
- Confidence
- Low
- Origin
- SigmaHQ (community)
- SigmaHQ status
test- Used in defense packs
- Akira, safepay, majinahanashi
Validation
- ExperimentalSyntax checked only. Not yet tested on events.
- Test-data validatedMatched positive test events and ignored near-miss events. Not yet run in a production SIEM.
- SIEM-validatedRun in a real SIEM, with a recorded result.
2 of 2 positive test events matched; 1 of 1 near-miss events were correctly ignored. Community rule reused unmodified from SigmaHQ. OffSet7 converted it and tested it on synthetic events.
Detection logic and queries
Queries are shown exactly as generated. Test them in your environment before you deploy them.
Sigma
Sigma (YAML) · 97a80ec7-0e2f-4d05-9ef4-65760e634f6b
title: Security Privileges Enumeration Via Whoami.EXE
id: 97a80ec7-0e2f-4d05-9ef4-65760e634f6b
status: test
description: Detects a whoami.exe executed with the /priv command line flag instructing the tool to show all current user privileges. This is often used after a privilege escalation attempt.
references:
- https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/whoami
author: Florian Roth (Nextron Systems)
date: 2021-05-05
modified: 2023-02-28
tags:
- attack.privilege-escalation
- attack.discovery
- attack.t1033
logsource:
category: process_creation
product: windows
detection:
selection_img:
- Image|endswith: '\whoami.exe'
- OriginalFileName: 'whoami.exe'
selection_cli:
CommandLine|contains:
- ' /priv'
- ' -priv'
condition: all of selection_*
falsepositives:
- Unknown
level: high
regression_tests_path: regression_data/rules/windows/process_creation/proc_creation_win_whoami_priv_discovery/info.ymlQRadar AQL
IBM QRadar AQL (hunting query)Hunting query
Hunting search for the Log Activity tab or the API. It is not a QRadar rule.
AQL search for the Log Activity tab or the API. It is NOT a deployable QRadar rule: real-time detection in QRadar is a CRE (Custom Rule Engine) rule, for which this build only writes a design specification (qradar_cre).
SELECT * FROM events WHERE devicetype=12 AND ((LOWER("Process Path") LIKE '%\whoami.exe' OR LOWER("Process Name") LIKE '%\whoami.exe') OR Filename='whoami.exe') AND (LOWER(Command) LIKE '% /priv%' OR LOWER(Command) LIKE '% -priv%')QRadar CRE
Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.
- Rule name
OffSet7: Security Privileges Enumeration Via Whoami.EXE- Rule type
- Event rule (Local)
- Log source types
- Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1
Building blocks
BB:OffSet7:Security Privileges Enumeration Via Whoami EXE:selection_img(match)Any of the groups matches (OR): build one BB per group and a parent BB "when an event matches any of" them.Process Path / Process Nameends with:\whoami.exeFilenameis equal to (case-insensitive):whoami.exe
BB:OffSet7:Security Privileges Enumeration Via Whoami EXE:selection_cli(match)All test lines must match (AND).Commandcontains:/priv,-priv
Main rule, option A (building blocks)
- when the event(s) were detected by one or more of these log source types:
Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1 - when an event matches the condition built from these building blocks:
(ALL of [BB:OffSet7:Security Privileges Enumeration Via Whoami EXE:selection_img, BB:OffSet7:Security Privileges Enumeration Via Whoami EXE:selection_cli])
Main rule, option B (AQL filter test)
- when the event matches this AQL filter query:
devicetype=12 AND ((LOWER("Process Path") LIKE '%\whoami.exe' OR LOWER("Process Name") LIKE '%\whoami.exe') OR Filename='whoami.exe') AND (LOWER(Command) LIKE '% /priv%' OR LOWER(Command) LIKE '% -priv%')
Rule response
- Severity 7, credibility 6, relevance 7
- Ensure the detected event is part of an offense; index offense on Log Source (host) and annotate with the rule title and OffSet7 rule id
- Respond no more than once per 30 minutes per Log Source (tune per environment)
Limitations
- QRadar AQL LIKE / CRE string tests are case-sensitive unless the property is lower-cased; the AQL option uses LOWER() where the backend applied it.
Splunk
Splunk SPLSearch
Search for Splunk with Windows/Sysmon field names. A scheduled search or ES correlation search also needs a schedule, time range, throttling and an adaptive response, set in your environment.
(Image="*\\whoami.exe" OR OriginalFileName="whoami.exe") (CommandLine IN ("* /priv*", "* -priv*"))Splunk savedsearches.conf stanzaScheduled search template
Template stanza. Review schedule, alert actions and index/sourcetype for your environment before enabling.
[default]
dispatch.earliest_time = -30d
dispatch.latest_time = now
[Security Privileges Enumeration Via Whoami.EXE]
description = Detects a whoami.exe executed with the /priv command line flag instructing the tool to show all current user privileges. This is often used after a privilege escalation attempt.
search = (Image="*\\whoami.exe" OR OriginalFileName="whoami.exe") (CommandLine IN ("* /priv*", "* -priv*"))Microsoft Sentinel
Microsoft Sentinel KQL (ASIM)Hunting query
Hunting query over ASIM-normalized tables. An analytics rule also needs a schedule, entity mapping and alert grouping.
imProcessCreate
| where (TargetProcessName endswith "\\whoami.exe" or TargetProcessFileOriginalName =~ "whoami.exe") and (TargetProcessCommandLine contains " /priv" or TargetProcessCommandLine contains " -priv")Defender XDR
Microsoft Defender XDR KQLHunting query
Advanced hunting query. A custom detection rule also needs a frequency, impacted entities and actions.
DeviceProcessEvents
| where (FolderPath endswith "\\whoami.exe" or ProcessVersionInfoOriginalFileName =~ "whoami.exe") and (ProcessCommandLine contains " /priv" or ProcessCommandLine contains " -priv")Elastic
Elastic Lucene (ECS)Hunting query
Lucene query over ECS fields (Winlogbeat/Elastic Agent Windows mappings). A detection rule also needs an index pattern, schedule and actions.
(process.executable:*\\whoami.exe OR process.pe.original_file_name:whoami.exe) AND (process.command_line:(*\ \/priv* OR *\ \-priv*))Elastic EQL (ECS)Hunting query
EQL query over ECS fields. Usable in an Elastic Security EQL rule after review; index pattern and schedule are set per environment.
any where (process.executable:"*\\whoami.exe" or process.pe.original_file_name:"whoami.exe") and (process.command_line like~ ("* /priv*", "* -priv*"))Elastic ES|QL (ECS)Hunting query
ES|QL query over ECS fields; the FROM clause uses * and must be narrowed to your indices.
from * metadata _id, _index, _version | where (ends_with(process.executable, "\\whoami.exe") or process.pe.original_file_name=="whoami.exe") and (process.command_line like "* /priv*" or process.command_line like "* -priv*")Required telemetry
- Log source
product: windows · category: process_creation- Fields used
CommandLineImageOriginalFileName
False positives
- Unknown
Investigation and response
No OffSet7 investigation guidance has been written for this rule yet. Start from the false positives above and the ATT&CK technique pages.
References
Author and attribution
- Author
- Florian Roth (Nextron Systems)
- Source
- SigmaHQ ·
rules/windows/process_creation/proc_creation_win_whoami_priv_discovery.yml - Upstream commit
9688134317a2- Licence
- Detection Rule License (DRL) 1.1
Version history
- Version 1Imported from SigmaHQ
- OffSet7 build · SigmaHQ
9688134317a2