Detection rules › Splunk
Network Share Discovery Via Dir Command
The following analytic detects access to Windows administrative SMB shares (Admin$, IPC$, C$) using the 'dir' command. It leverages Windows Security Event Logs with EventCode 5140 to identify this activity. This behavior is significant as it is commonly used by tools like PsExec/PaExec for staging binaries before creating and starting services on remote endpoints, a technique often employed by adversaries for lateral movement and remote code execution. If confirmed malicious, this activity could allow attackers to propagate malware, such as IcedID, across the network, leading to widespread infection and potential data breaches.
Known false positives
- System Administrators may use tools like "net.exe", "net1.exe", or "dir" for troubleshooting or administrations tasks. However, this will typically come only from certain users and certain systems that can be added to an allow list.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Discovery |
Telemetry coverage
| Provider | Record / event type |
|---|---|
| Security-Auditing | Event ID 5140: A network share object was accessed. |
Rule body
name: Network Share Discovery Via Dir Command
id: dc1457d0-1d9b-422e-b5a7-db46c184d9aa
version: 7
creation_date: '2023-05-23'
modification_date: '2026-08-05'
author: Teoderick Contreras, Splunk
status: production
type: Hunting
description: |-
The following analytic detects access to Windows administrative SMB shares (Admin$, IPC$, C$) using the 'dir' command. It leverages Windows Security Event Logs with EventCode 5140 to identify this activity.
This behavior is significant as it is commonly used by tools like PsExec/PaExec for staging binaries before creating and starting services on remote endpoints, a technique often employed by adversaries for lateral movement and remote code execution.
If confirmed malicious, this activity could allow attackers to propagate malware, such as IcedID, across the network, leading to widespread infection and potential data breaches.
data_source:
- Windows Event Log Security 5140
search: |-
`wineventlog_security`
EventCode=5140
ShareName IN (
"\\\\*\\Admin$",
"\\\\*\\C$",
"\\\\*\\IPC$"
)
```
We select only read-related operations:
0x1 = ReadData (or ListDirectory)
```
| eval AccessMask_ = tonumber(AccessMask, 16)
| where (bit_and(AccessMask_, 1) != 0)
| stats min(_time) as firstTime
max(_time) as lastTime
count
by ShareName IpAddress ObjectType SubjectUserName
SubjectDomainName IpPort AccessMask Computer
| rename Computer as dest
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `network_share_discovery_via_dir_command_filter`
how_to_implement: |-
To successfully implement this search, you need to be ingesting Windows Security Event Logs with 5140 EventCode enabled. The Windows TA is also required. Also enable the object Audit access success/failure in your group policy.
known_false_positives: |-
System Administrators may use tools like "net.exe", "net1.exe", or "dir" for troubleshooting or administrations tasks.
However, this will typically come only from certain users and certain systems that can be added to an allow list.
references:
- https://thedfirreport.com/2023/05/22/icedid-macro-ends-in-nokoyawa-ransomware/
- https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-5140#table-of-file-access-codes
- https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-5140
analytic_story:
- IcedID
asset_type: Endpoint
atomic_guid:
- 13daa2cf-195a-43df-a8bd-7dd5ffb607b5
mitre_attack_id:
- T1135
product:
- Splunk Enterprise
- Splunk Enterprise Security
- Splunk Cloud
category: endpoint
security_domain: endpoint
Stages and Predicates
Stage 1: search
`wineventlog_security`
EventCode=5140
ShareName IN (
"\\\\*\\Admin$",
"\\\\*\\C$",
"\\\\*\\IPC$"
)
Stage 2: eval
| eval AccessMask_ = tonumber(AccessMask, 16)
Stage 3: where
| where (bit_and(AccessMask_, 1) != 0)
Stage 4: stats
| stats min(_time) as firstTime
max(_time) as lastTime
count
by ShareName IpAddress ObjectType SubjectUserName
SubjectDomainName IpPort AccessMask Computer
Stage 5: rename
| rename Computer as dest
Stage 6: search
| `security_content_ctime(firstTime)`
Stage 7: search
| `security_content_ctime(lastTime)`
Stage 8: search
| `network_share_discovery_via_dir_command_filter`
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
EventCode | eq |
| field:"EventID" kind:eq value:"5140" |
ShareName | in |
| field:"ShareName" kind:in |