Detection: Windows Process Executed From Removable Media

Description

This analytic is used to identify when a removable media device is attached to a machine and then a process is executed from the same drive letter assigned to the removable media device. Adversaries and Insider Threats may use removable media devices for several malicious activities, including initial access, execution, and exfiltration.

 1
 2| tstats `security_content_summariesonly` count values(Processes.process) as process min(_time) as firstTime max(_time) as lastTime FROM datamodel=Endpoint.Processes
 3  WHERE Processes.process_current_directory=*
 4    AND
 5    NOT Processes.process_current_directory IN ("C:\\*","*\\sysvol\\*")
 6  BY Processes.action Processes.dest Processes.original_file_name
 7     Processes.parent_process Processes.parent_process_exec Processes.parent_process_guid
 8     Processes.parent_process_id Processes.parent_process_name Processes.parent_process_path
 9     Processes.process Processes.process_exec Processes.process_guid
10     Processes.process_hash Processes.process_id Processes.process_integrity_level
11     Processes.process_name Processes.process_path Processes.user
12     Processes.user_id Processes.vendor_product Processes.process_current_directory
13
14| `drop_dm_object_name(Processes)`
15
16| rex field=process_current_directory "^(?<object_handle>[^\\\]+\\\)"
17
18| where isnotnull(object_handle)
19
20| `security_content_ctime(firstTime)`
21
22| `security_content_ctime(lastTime)`
23
24| join dest,object_handle
25[
26
27| tstats `security_content_summariesonly` count values(Registry.action) as action values(Registry.process_guid) as process_guid values(Registry.process_id) as process_id values(Registry.registry_hive) as registry_hive values(Registry.registry_key_name) as registry_key_name values(Registry.registry_value_name) as registry_value_name values(Registry.registry_value_type) as registry_value_type values(Registry.status) as status values(Registry.user) as user values(Registry.vendor_product) as vendor_product FROM datamodel=Endpoint.Registry
28  WHERE Registry.registry_value_data="*:\\*"
29    AND
30    Registry.registry_path="*USBSTOR*"
31    AND
32    Registry.registry_path IN ("HKLM\\SOFTWARE\\Microsoft\\Windows Portable Devices\\Devices\\*","HKLM\\System\\CurrentControlSet\\Enum\\SWD\\WPDBUSENUM\\*")
33  BY Registry.dest,Registry.registry_value_data, Registry.registry_path
34
35| `drop_dm_object_name(Registry)`
36
37| eval object_handle = registry_value_data, object_name = replace(mvindex(split(mvindex(split(registry_path, "??"),1),"&amp;"),2),"PROD_","")
38    ]
39
40| `windows_process_executed_from_removable_media_filter`

Data Source

Name Platform Sourcetype Source
Sysmon EventID 1 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational'
Sysmon EventID 13 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
windows_process_executed_from_removable_media_filter search *
windows_process_executed_from_removable_media_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1200 Hardware Additions Initial Access
T1025 Data from Removable Media Collection
T1091 Replication Through Removable Media Initial Access
Delivery
Exploitation
DE.AE
CIS 10

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 Risk Event True
This configuration file applies to all detections of type anomaly. These detections will use Risk Based Alerting.

Implementation

To successfully implement this search, you must ingest endpoint logging that tracks changes to the HKLM\SOFTWARE\Microsoft\Windows Portable Devices\Devices\ or HKLM\System\CurrentControlSet\Enum\SWD\WPDBUSENUM\ registry keys as well as Process Execution commands. Ensure that the field from the event logs is being mapped to the proper fields in the Endpoint.Registry data model. This analytic joins the Process and Registry datamodels together based on the drive letter extract to the "object_handle" field from both datasets.

Known False Positives

Legitimate USB activity will also be detected. Please verify and investigate as appropriate.

Associated Analytic Story

Risk Based Analytics (RBA)

Risk Message:

The process [$process_name$] was launched using files on a removable storage device named [$object_name$] by [$user$] on $dest$

Risk Object Risk Object Type Risk Score Threat Objects
user user 35 object_name, process_name, object_handle
dest system 35 object_name, process_name, object_handle

References

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: 7