Detection rules › Splunk

Executable File Written in Administrative SMB Share

Status
production
Severity
medium
Group by
ObjectType, SourcePort, access_mask, dest, relative_target_name, share_name, signature_id, src_ip, user
Author
Teoderick Contreras, Mauricio Velazco, Splunk
Source
github.com/splunk/security_content

The following analytic detects executable files (.exe, .dll, etc.) being written to Windows administrative SMB shares (Admin$, IPC$, C$). It leverages Windows Security Event Logs with EventCode 5145 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 for lateral movement and remote code execution. If confirmed malicious, this activity could allow an attacker to execute arbitrary code remotely, potentially compromising additional systems within the network.

Known false positives

  • System Administrators may use tools like PsExec 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

Telemetry coverage

Rule body

name: Executable File Written in Administrative SMB Share
id: f63c34fe-a435-11eb-935a-acde48001122
version: 14
creation_date: '2021-04-26'
modification_date: '2026-08-05'
author: Teoderick Contreras, Mauricio Velazco, Splunk
status: production
type: TTP
description: |-
    The following analytic detects executable files (.exe, .dll, etc.) being written to Windows administrative SMB shares (Admin$, IPC$, C$). It leverages Windows Security Event Logs with EventCode 5145 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 for lateral movement and remote code execution.
    If confirmed malicious, this activity could allow an attacker to execute arbitrary code remotely, potentially compromising additional systems within the network.
data_source:
    - Windows Event Log Security 5145
search: |-
    `wineventlog_security`
    EventCode=5145
    RelativeTargetName IN (
        "*.cpl",
        "*.dll",
        "*.exe",
        "*.sys"
    )
    ObjectType=File
    ShareName IN (
        "\\\\*\\Admin$",
        "\\\\*\\C$",
        "\\\\*\\IPC$"
    )
    
    | eval AccessMask_ = tonumber(AccessMask, 16)
    | where (bit_and(AccessMask_, 2) != 0) OR (bit_and(AccessMask_, 4) != 0)
    
    | stats min(_time) as firstTime
            max(_time) as lastTime count
    
      by EventCode ShareName RelativeTargetName ObjectType
         AccessMask src_user src_port IpAddress dest
    
    | `security_content_ctime(firstTime)`
    | `security_content_ctime(lastTime)`
    | `executable_file_written_in_administrative_smb_share_filter`
how_to_implement: |-
    To successfully implement this search, you need to be ingesting Windows Security Event Logs with 5145 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 PsExec 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://attack.mitre.org/techniques/T1021/002/
    - https://www.rapid7.com/blog/post/2013/03/09/psexec-demystified/
    - https://labs.vipre.com/trickbot-and-its-modules/
    - https://whitehat.eu/incident-response-case-study-featuring-ryuk-and-trickbot-part-2/
    - 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-5145#table-of-file-access-codes
finding:
    title: The [$src_user$] dropped or created an executable file in known sensitive SMB share. Share name=[$ShareName$], Target name=[$RelativeTargetName$], and Access mask=[$AccessMask$]
    entity:
        field: src_user
        type: user
        score: 50
analytic_story:
    - Active Directory Lateral Movement
    - BlackSuit Ransomware
    - IcedID
    - Prestige Ransomware
    - Industroyer2
    - Data Destruction
    - Graceful Wipe Out Attack
    - Compromised Windows Host
    - Hermetic Wiper
    - Trickbot
    - VanHelsing Ransomware
asset_type: Endpoint
mitre_attack_id:
    - T1021.002
product:
    - Splunk Enterprise
    - Splunk Enterprise Security
    - Splunk Cloud
category: endpoint
security_domain: endpoint

Stages and Predicates

Stage 1: search

`wineventlog_security`
EventCode=5145
RelativeTargetName IN (
    "*.cpl",
    "*.dll",
    "*.exe",
    "*.sys"
)
ObjectType=File
ShareName IN (
    "\\\\*\\Admin$",
    "\\\\*\\C$",
    "\\\\*\\IPC$"
)

Stage 2: eval

| eval AccessMask_ = tonumber(AccessMask, 16)

Stage 3: where

| where (bit_and(AccessMask_, 2) != 0) OR (bit_and(AccessMask_, 4) != 0)

Stage 4: stats

| stats min(_time) as firstTime
        max(_time) as lastTime count

  by EventCode ShareName RelativeTargetName ObjectType
     AccessMask src_user src_port IpAddress dest

Stage 5: search

| `security_content_ctime(firstTime)`

Stage 6: search

| `security_content_ctime(lastTime)`

Stage 7: search

| `executable_file_written_in_administrative_smb_share_filter`

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
EventCodeeq
  • 5145 corpus 23 (splunk 16, elastic 5, kusto 2)
field:"EventID" kind:eq value:"5145"
ObjectTypeeq
  • File corpus 10 (sigma 8, splunk 2)
field:"ObjectType" kind:eq value:"File"
RelativeTargetNamein
  • "*.cpl"
  • "*.dll"
  • "*.exe"
  • "*.sys"
field:"RelativeTargetName" kind:in
ShareNamein
  • "\\\\*\\Admin$"
  • "\\\\*\\C$"
  • "\\\\*\\IPC$"
field:"ShareName" kind:in