Remote Execution via File Shares
Identifies the execution of a file that was created by the virtual system process. This may indicate lateral movement via network file shares.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2020/11/03"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2026/09/18"
6[transform]
7[[transform.osquery]]
8label = "Osquery - Retrieve DNS Cache"
9query = "SELECT * FROM dns_cache"
10
11[[transform.osquery]]
12label = "Osquery - Retrieve All Services"
13query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
14
15[[transform.osquery]]
16label = "Osquery - Retrieve Services Running on User Accounts"
17query = """
18SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
19NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
20user_account == null)
21"""
22
23[[transform.osquery]]
24label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
25query = """
26SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
27services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
28authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
29"""
30
31
32[rule]
33author = ["Elastic"]
34description = """
35Identifies the execution of a file that was created by the virtual system process. This may indicate lateral movement
36via network file shares.
37"""
38from = "now-9m"
39index = ["logs-endpoint.events.process-*", "logs-endpoint.events.file-*"]
40language = "eql"
41license = "Elastic License v2"
42name = "Remote Execution via File Shares"
43note = """## Triage and analysis
44
45### Investigating Remote Execution via File Shares
46
47Adversaries can use network shares to host tooling to support the compromise of other hosts in the environment. These tools can include discovery utilities, credential dumpers, malware, etc.
48
49> **Note**:
50> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/current/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
51
52#### Possible investigation steps
53
54- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
55- Review adjacent login events (e.g., 4624) in the alert timeframe to identify the account used to perform this action.
56- Investigate other alerts associated with the user/host during the past 48 hours.
57- Examine the host for derived artifacts that indicate suspicious activities:
58 - Analyze the process executable using a private sandboxed analysis system.
59 - Observe and collect information about the following activities in both the sandbox and the alert subject host:
60 - Attempts to contact external domains and addresses.
61 - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' `process.entity_id`.
62 - Examine the DNS cache for suspicious or anomalous entries.
63 - $osquery_0
64 - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
65 - Examine the host services for suspicious or anomalous entries.
66 - $osquery_1
67 - $osquery_2
68 - $osquery_3
69 - Retrieve the files' SHA-256 hash values using the PowerShell `Get-FileHash` cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
70- Investigate potentially compromised accounts. Analysts can do this by searching for login events (for example, 4624) to the target host after the registry modification.
71
72### False positive analysis
73
74- This activity can happen legitimately. Consider adding exceptions if it is expected and noisy in your environment.
75
76### Response and remediation
77
78- Initiate the incident response process based on the outcome of the triage.
79- Isolate the involved host to prevent further post-compromise behavior.
80- If the triage identified malware, search the environment for additional compromised hosts.
81 - Implement temporary network rules, procedures, and segmentation to contain the malware.
82 - Stop suspicious processes.
83 - Immediately block the identified indicators of compromise (IoCs).
84 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
85- Remove and block malicious artifacts identified during triage.
86- Review the privileges needed to write to the network share and restrict write access as needed.
87- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
88- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
89- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
90"""
91
92setup = """## Setup
93
94This rule is designed for data generated by [Elastic Defend](https://www.elastic.co/security/endpoint-security), which provides native endpoint detection and response, along with event enrichments designed to work with our detection rules.
95
96Setup instructions: https://ela.st/install-elastic-defend
97"""
98
99references = [
100 "http://web.archive.org/web/20230329172636/https://blog.menasec.net/2020/08/new-trick-to-detect-lateral-movement.html",
101 "https://www.elastic.co/security-labs/hunting-for-lateral-movement-using-event-query-language",
102]
103risk_score = 47
104rule_id = "ab75c24b-2502-43a0-bf7c-e60e662c811e"
105severity = "medium"
106tags = [
107 "Domain: Endpoint",
108 "OS: Windows",
109 "Use Case: Threat Detection",
110 "Tactic: Lateral Movement",
111 "Resources: Investigation Guide",
112 "Data Source: Elastic Endgame",
113 "Data Source: Elastic Defend",
114 "Noise: Medium",
115 "Performance: Normal",
116 "Rule Type: Event Correlation (EQL)",
117 "Platform: Windows",
118 "Resources: Osquery",
119]
120type = "eql"
121
122query = '''
123sequence with maxspan=1m
124 [file where host.os.type == "windows" and event.type in ("creation", "change") and
125 process.pid == 4 and (file.extension : ("exe", "scr", "pif", "com") or file.Ext.header_bytes : "4d5a*")] by host.id, file.path
126 [process where host.os.type == "windows" and event.type == "start" and
127 not (
128 (
129 process.code_signature.trusted == true and
130 process.code_signature.subject_name : (
131 "Veeam Software Group GmbH",
132 "Elasticsearch, Inc.",
133 "PDQ.com Corporation",
134 "CrowdStrike, Inc.",
135 "Microsoft Windows Hardware Compatibility Publisher",
136 "ZOHO Corporation Private Limited",
137 "BeyondTrust Corporation",
138 "CyberArk Software Ltd.",
139 "Sophos Ltd",
140 "AO Kaspersky Lab",
141 "Anthropic, PBC",
142 "Adobe Inc.",
143 "Netwrix Corporation"
144 )
145 ) or
146 (
147 process.executable : (
148 "?:\\Windows\\ccmsetup\\ccmsetup.exe",
149 "?:\\Windows\\SoftwareDistribution\\Download\\Install\\*.exe",
150 "?:\\Windows\\CAInvokerService.exe",
151 "?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\*\\OneDriveSetup.exe"
152 ) and process.code_signature.trusted == true
153 ) or
154 (
155 process.executable : "?:\\SMS_*\\srvboot.exe" and
156 process.code_signature.trusted == true and process.code_signature.subject_name : "Microsoft Corporation"
157 )
158 )
159 ] by host.id, process.executable
160'''
161
162
163[[rule.threat]]
164framework = "MITRE ATT&CK"
165
166[[rule.threat.technique]]
167id = "T1021"
168name = "Remote Services"
169reference = "https://attack.mitre.org/techniques/T1021/"
170
171[[rule.threat.technique.subtechnique]]
172id = "T1021.002"
173name = "SMB/Windows Admin Shares"
174reference = "https://attack.mitre.org/techniques/T1021/002/"
175
176[[rule.threat.technique]]
177id = "T1570"
178name = "Lateral Tool Transfer"
179reference = "https://attack.mitre.org/techniques/T1570/"
180
181[rule.threat.tactic]
182id = "TA0008"
183name = "Lateral Movement"
184reference = "https://attack.mitre.org/tactics/TA0008/"
Triage and analysis
Investigating Remote Execution via File Shares
Adversaries can use network shares to host tooling to support the compromise of other hosts in the environment. These tools can include discovery utilities, credential dumpers, malware, etc.
Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
Possible investigation steps
- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
- Review adjacent login events (e.g., 4624) in the alert timeframe to identify the account used to perform this action.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Examine the host for derived artifacts that indicate suspicious activities:
- Analyze the process executable using a private sandboxed analysis system.
- Observe and collect information about the following activities in both the sandbox and the alert subject host:
- Attempts to contact external domains and addresses.
- Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process'
process.entity_id. - Examine the DNS cache for suspicious or anomalous entries.
- $osquery_0
- Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process'
- Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
- Examine the host services for suspicious or anomalous entries.
- $osquery_1
- $osquery_2
- $osquery_3
- Attempts to contact external domains and addresses.
- Retrieve the files' SHA-256 hash values using the PowerShell
Get-FileHashcmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
- Investigate potentially compromised accounts. Analysts can do this by searching for login events (for example, 4624) to the target host after the registry modification.
False positive analysis
- This activity can happen legitimately. Consider adding exceptions if it is expected and noisy in your environment.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved host to prevent further post-compromise behavior.
- If the triage identified malware, search the environment for additional compromised hosts.
- Implement temporary network rules, procedures, and segmentation to contain the malware.
- Stop suspicious processes.
- Immediately block the identified indicators of compromise (IoCs).
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
- Remove and block malicious artifacts identified during triage.
- Review the privileges needed to write to the network share and restrict write access as needed.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- Adding Hidden File Attribute via Attrib
- Execution from Unusual Directory - Command Line
- ImageLoad via Windows Update Auto Update Client
- Lateral Movement via Startup Folder
- Local Account TokenFilter Policy Disabled