Detection: Registry Keys Used For Persistence

Description

The following analytic identifies modifications to registry keys commonly used for persistence mechanisms. It leverages data from endpoint detection sources like Sysmon or Carbon Black, focusing on specific registry paths known to initiate applications or services during system startup. This activity is significant as unauthorized changes to these keys can indicate attempts to maintain persistence or execute malicious actions upon system boot. If confirmed malicious, this could allow attackers to achieve persistent access, execute arbitrary code, or maintain control over compromised systems, posing a severe threat to system integrity and security.

 1
 2| tstats `security_content_summariesonly`
 3  count min(_time) as firstTime
 4        max(_time) as lastTime
 5
 6FROM datamodel=Endpoint.Registry where
 7
 8Registry.action IN ("created", "modified")
 9
10Registry.registry_path IN (
11    "*\\Classes\\htmlfile\\shell\\open\\command",
12    "*\\CurrentControlSet\\Control\\Lsa\\OSConfig\\Security Packages",
13    "*\\CurrentControlSet\\Control\\Lsa\\Security Packages",
14    "*\\CurrentControlSet\\Control\\Session Manager\\BootExecute",
15    "*\\CurrentVersion\\Explorer\\SharedTaskScheduler",
16    "*\\CurrentVersion\\Explorer\\Shell Folders\\*",
17    "*\\CurrentVersion\\Explorer\\StartupApproved\\Run",
18    "*\\CurrentVersion\\Explorer\\User Shell Folders\\*",
19    "*\\CurrentVersion\\Image File Execution Options\\*\\Debugger",
20    "*\\CurrentVersion\\policies\\explorer\\run*",
21    "*\\CurrentVersion\\Run*",
22    "*\\CurrentVersion\\RunOnce",
23    "*\\CurrentVersion\\RunServices*",
24    "*\\CurrentVersion\\SilentProcessExit\\*",
25    "*\\CurrentVersion\\Svchost\\*",
26    "*\\CurrentVersion\\Windows\\Appinit_Dlls*",
27    "*\\CurrentVersion\\Windows\\Load",
28    "*\\CurrentVersion\\Winlogon\\Notify*",
29    "*\\CurrentVersion\\Winlogon\\Shell*",
30    "*\\CurrentVersion\\Winlogon\\Userinit*",
31    "*\\CurrentVersion\\Winlogon\\VmApplet*",
32    "*\\SOFTWARE\\Microsoft\\Netsh\\*"
33)
34
35by Registry.action Registry.dest Registry.process_guid Registry.process_id
36   Registry.registry_hive Registry.registry_path Registry.registry_key_name
37   Registry.registry_value_data Registry.registry_value_name Registry.registry_value_type
38   Registry.status Registry.user Registry.vendor_product
39
40
41| `drop_dm_object_name(Registry)`
42
43
44| `security_content_ctime(firstTime)`
45
46| `security_content_ctime(lastTime)`
47
48| `registry_keys_used_for_persistence_filter`

Data Source

Name Platform Sourcetype Source
Sysmon EventID 13 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational'
Cisco Endpoint Visibility Module Registry Value Activity Other 'cisco:evm:registry_value_activity' 'not_applicable'

Macros Used

Name Value
security_content_summariesonly summariesonly=summariesonly_config allow_old_summaries=oldsummaries_config fillnull_value=fillnull_config``
registry_keys_used_for_persistence_filter search *
registry_keys_used_for_persistence_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Finding (Notable) No
Creates Intermediate Finding (Risk Event) Yes
Anomaly detections generate Intermediate Findings (Risk Events). They do not generate a Finding (Notable) directly.

Implementation

To successfully implement this search, you must be ingesting data that records registry activity from your hosts to populate the endpoint data model in the registry node. This is typically populated via endpoint detection-and-response product, such as Carbon Black or endpoint data sources, such as Sysmon. The data used for this search is typically generated via logs that report reads and writes to the registry.

Known False Positives

There are many legitimate applications that must execute on system startup and will use these registry keys to accomplish that task.

Associated Analytic Story

Intermediate Findings

Message Entity Field Entity Type Risk Score
A registry entry [$registry_path$] in a location commonly used for persistence was set on [$dest$] by [$user$] with the value [$registry_value_data$]. dest system 20

Threat Objects

Field Type
registry_value_data registry_value_text

References

Atomic Tests

Learn more about Atomic Red Team tests here.

Atomic Test ID Atomic Test Name Supported Platform
e55be3fd-3521-4610-9d1a-e210e42dcf05 Reg Key Run Windows

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation ✅ Passing N/A N/A N/A
Unit ✅ Passing Dataset XmlWinEventLog:Microsoft-Windows-Sysmon/Operational XmlWinEventLog
Integration ✅ Passing Dataset XmlWinEventLog:Microsoft-Windows-Sysmon/Operational XmlWinEventLog

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub |

Version: 36