EXPLORE
← Back to Explore
splunk_escuHunting

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.

Detection Query

`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`

Author

Teoderick Contreras, Splunk

Data Sources

Windows Event Log Security 5140
Raw Content
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
tests:
    - name: True Positive Test
      attack_data:
        - data: https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1135/net_share_discovery_via_dir/smb_access_security_xml.log
          source: XmlWinEventLog:Security
          sourcetype: XmlWinEventLog
      test_type: unit