| ID | Technique | Tactic |
|---|---|---|
| T1012 | Query Registry | Discovery |
Detection: Windows Hosts File Access
Description
This Analytic detects the execution of a process attempting to access the hosts file. The hosts file is a critical file for network configuration and DNS resolution. If an attacker gains access to it, they can redirect traffic to malicious websites, serve fake content or block legitimate security websites.
Search
1`wineventlog_security`
2EventCode=4663
3object_file_path="*:\\Windows\\System32\\drivers\\etc\\hosts"
4NOT process_path IN (
5 "*:\\Windows\\explorer.exe",
6 "*:\\Windows\\System32\\lsass.exe",
7 "*:\\Windows\\System32\\SearchIndexer.exe",
8 "*:\\Windows\\System32\\services.exe",
9 "*:\\Windows\\System32\\svchost.exe",
10 "*:\\Windows\\SysWow64\\SearchIndexer.exe",
11 "*:\\Windows\\SysWow64\\svchost.exe"
12)
13
14| stats count
15 by _time object_file_path object_file_name dest process_name
16 process_path process_id EventCode
17
18| eval process_path = lower(process_path)
19
20| lookup browser_process_and_path browser_process_path as process_path OUTPUT is_valid_browser_path
21
22| eval is_valid_browser_path=coalesce(is_valid_browser_path,"false")
23
24| where is_valid_browser_path = "false"
25
26| `security_content_ctime(firstTime)`
27
28| `security_content_ctime(lastTime)`
29
30| `windows_hosts_file_access_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Windows Event Log Security 4663 | 'XmlWinEventLog' |
'XmlWinEventLog:Security' |
Macros Used
| Name | Value |
|---|---|
| security_content_ctime | convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$) |
| windows_hosts_file_access_filter | search * |
windows_hosts_file_access_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 Risk Event | True |
Implementation
To successfully implement this search, you must ingest Windows Security Event logs and track event code 4663. For 4663, enable "Audit Object Access" in Group Policy. Then check the two boxes listed for both "Success" and "Failure." This search may trigger on a browser application that is not included in the browser_app_list lookup file.
Known False Positives
Administrator may access this registry for product key recovery purposes.
Associated Analytic Story
Risk Based Analytics (RBA)
Risk Message:
A [$process_name$] attempting to access the hosts file [$object_file_path$] on [$dest$].
| Risk Object | Risk Object Type | Risk Score | Threat Objects |
|---|---|---|---|
| dest | system | 20 | process_name |
References
Detection Testing
| Test Type | Status | Dataset | Source | Sourcetype |
|---|---|---|---|---|
| Validation | ✅ Passing | N/A | N/A | N/A |
| Unit | ✅ Passing | Dataset | XmlWinEventLog:Security |
XmlWinEventLog |
| Integration | ✅ Passing | Dataset | XmlWinEventLog:Security |
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