Detection rules › Splunk
New AutoRun Registry Key (PowerShell)
Detects when common autorun scripts in the Windows registry are modified
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Persistence | T1547.001 Boot or Logon Autostart Execution: Registry Run Keys / Startup Folder |
| Privilege Escalation | T1547.001 Boot or Logon Autostart Execution: Registry Run Keys / Startup Folder |
Event coverage
| Provider | Event | Title |
|---|---|---|
| PowerShell | Event ID 4103 | Payload Context: ContextInfo User Data: UserData. |
| PowerShell | Event ID 4104 | Creating Scriptblock text (MessageNumber of MessageTotal). |
Rule body yaml
id: '1042.1065'
title: New AutoRun Registry Key
description: 'Detects when common autorun scripts in the Windows registry are modified.
-- Threat Actor Association: APT27/Emissary Panda, APT28, APT29/Nobelium/Cozy Bear,
APT33, APT37, APT40, APT43, Blind Eagle/APT-C-36, Carbanak, FIN6, FIN7, FIN13, Lazarus,
MuddyWater, Mustang Panda, NewsPenguin, RedEyes, RomCom, SaintBear (aka UAC-0056,
UNC2589, TA471), Sandworm Team, TA2541, TA505, UAC-0056, UNC4990 - Software Association:
ALPHV/BlackCat, Bazarloader, Blackbyte, Havex, LockBit, MirrorBlast, NanoCore, Phosphorus/Magic
Hound/APT35, Prometheus / Spook, Sodinokibi/REvil, Ransom Cartel, Remcos RAT, Trigona,
Vice Society, Zloader -- Atomics T1547.001 Test#3 Atomics T1547.001 Test#4'
logic_format: Splunk
logic: ' `get_endpoint_data` `get_endpoint_data_powershell` AND ( EventCode=4103 OR
EventCode=4104) AND ("Windows\\CurrentVersion\\RunOnce" OR "Windows\\CurrentVersion\\Run"
OR "Windows\\CurrentVersion\\RunServices" OR "Windows\\CurrentVersion\\RunServicesOnce"
OR "Windows\\CurrentVersion\\RunOnceEx") | table _time, host, user dvc, dvc_nt_host,
event_id, eventtype, host, index, parameters, process, process_id, process_name,
process_path, shell, signature_id, source, sourcetype, src_user, tag, user, user_id
| bin span=60s | stats values(*) as * by _time, host | rex field=process max_match=0
(?<registry_path>"[^\"]+Windows\\\CurrentVersion\\\Run[^\"]{0,}") | eventstats values(registry_path)
as registry_path by _time dvc '
techniques:
- persistence:boot or logon autostart execution:registry run keys / startup folder
- privilege-escalation:boot or logon autostart execution:registry run keys / startup
folder
technique_id:
- T1547.001
data_category:
- Windows Registry
- PowerShell logs
references: null
Stages and Predicates
Stage 1: search
`get_endpoint_data` `get_endpoint_data_powershell` AND ( EventCode=4103 OR EventCode=4104) AND ("Windows\\CurrentVersion\\RunOnce" OR "Windows\\CurrentVersion\\Run" OR "Windows\\CurrentVersion\\RunServices" OR "Windows\\CurrentVersion\\RunServicesOnce" OR "Windows\\CurrentVersion\\RunOnceEx")
Stage 2: table
| table _time, host, user dvc, dvc_nt_host, event_id, eventtype, host, index, parameters, process, process_id, process_name, process_path, shell, signature_id, source, sourcetype, src_user, tag, user, user_id
Stage 3: bucket
| bin span=60s
Stage 4: stats
| stats values(*) as * by _time, host
Stage 5: eval
| rex field=process max_match=0 (?<registry_path>"[^\"]+Windows\\\CurrentVersion\\\Run[^\"]{0,}")
Stage 6: eventstats
| eventstats values(registry_path) as registry_path by _time dvc
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
| Field | Kind | Values |
|---|---|---|
EventCode | eq |
|
Search terms
Bare-string tokens in the SPL search body. Splunk matches each token against _raw (the untyped raw event text) anywhere it appears, not against a specific field. These don't surface in the Indicators table because they aren't predicates on a known field.
| Stage | Term |
|---|---|
| 1 | "Windows\\CurrentVersion\\RunOnce" |
| 1 | "Windows\\CurrentVersion\\Run" |
| 1 | "Windows\\CurrentVersion\\RunServices" |
| 1 | "Windows\\CurrentVersion\\RunServicesOnce" |
| 1 | "Windows\\CurrentVersion\\RunOnceEx" |