Network Share Discovery Via Dir Command
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.
Query · spl
`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`
Implementation guide
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.
Analyst notes
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.