Detection: Windows MsMpEng Writing to System32

Description

Detects MsMpEng.exe creating a file in C:\Windows\System32\. This should never happen under normal operation Windows Defender does not install kernel drivers at runtime. In the BlueHammer exploit, the TOCTOU race causes MsMpEng (SYSTEM) to write the attacker's driver payload directly into the drivers directory.

 1`sysmon`
 2(EventID=15 OR EventID=11)
 3Image="*\\MsMpEng.exe"
 4TargetFilename="*:\\Windows\\System32\\*"
 5
 6| fillnull
 7
 8| stats count min(_time) as firstTime
 9              max(_time) as lastTime
10  by Computer Image TargetFilename EventID dest dvc
11     file_hash file_name file_path action process_exec
12     process_guid process_id process_name process_path
13     signature signature_id user_id vendor_product
14
15| `security_content_ctime(firstTime)`
16
17| `security_content_ctime(lastTime)`
18
19| `windows_msmpeng_writing_to_system32_filter`

Data Source

Name Platform Sourcetype Source
Sysmon EventID 15 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational'
Sysmon EventID 11 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational'

Macros Used

Name Value
sysmon (source=WinEventLog:Microsoft-Windows-Sysmon/Operational OR source=XmlWinEventLog:Microsoft-Windows-Sysmon/Operational OR source=Syslog:Linux-Sysmon/Operational)
windows_msmpeng_writing_to_system32_filter search *
windows_msmpeng_writing_to_system32_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

CVE

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) Yes
Rule Title %name%
Rule Description %description%
Notable Event Fields user, dest
Creates Intermediate Finding (Risk Event) No
TTP detections generate a Finding (Notable) and may generate Intermediate Findings (Risk Events) for associated entities.

Implementation

The detection is based on data that originates from Endpoint Detection and Response (EDR) agents. These agents are designed to provide security-related telemetry from the endpoints where the agent is installed. To implement this search, you must ingest logs that contain the process GUID, process name, and parent process. Additionally, you must ingest complete command-line executions. These logs must be processed using the appropriate Splunk Technology Add-ons that are specific to the EDR product. The logs must also be mapped to the Processes node of the Endpoint data model. Use the Splunk Common Information Model (CIM) to normalize the field names and speed up the data modeling process.

Known False Positives

No false positives have been identified at this time.

Associated Analytic Story

Finding

Title Entity Field Entity Type Risk Score
$Image$ wrote a File or an Alternate Data Stream $TargetFilename$ on $dest$. dest system 50

Threat Objects

Field Type
Image process
TargetFilename file_path

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