Skip to content
WETNav

Investigation · Data access

Which files were accessed or staged over SMB shares?

Recover which files were touched over SMB: the share-level and per-file access events, local object auditing, and the session and source behind each access.

When you would ask thisYou suspect data was collected or staged over the network and need the specific files, the user, and the source host behind the access.

Steps

  1. 1

    See which shares were touched

    Event 5140 is written when a network share object is accessed, and records ShareName (for example \\*\C$, \\*\ADMIN$ or a named share), IpAddress, SubjectUserName and the AccessMask requested. It gives you the share-level picture: which user, from which host, reached which share and when. Access to the administrative shares C$ and ADMIN$ from an unexpected host is the pattern behind PsExec and SMB-exec staging, so start by listing distinct ShareName and IpAddress pairs.

  2. 2

    Get the per-file detail

    Event 5145 is the detailed network share access check and is the one that names individual files. Read ShareName, RelativeTargetName (the file path within the share), AccessMask and IpAddress. The mask is a bitmask: 0x1 is ReadData, 0x2 WriteData, 0x4 AppendData, 0x20 Execute and 0x10000 Delete. A sequence of 0x1 reads across many files under one share from one source is collection; writes of an executable into an admin share is staging a remote-exec payload.

    Files accessed over the C$ share (live host)
    Get-WinEvent -LogName Security `
      -FilterXPath "*[System[EventID=5145]] and *[EventData[Data[@Name='ShareName']='\\*\C$']]" |
      ForEach-Object { $x = [xml]$_.ToXml(); [pscustomobject]@{
        Time = $_.TimeCreated
        File = ($x.Event.EventData.Data | Where-Object Name -eq 'RelativeTargetName').'#text'
        IP   = ($x.Event.EventData.Data | Where-Object Name -eq 'IpAddress').'#text' } }
  3. 3

    Check for share creation and changes

    Staging sometimes needs a new share. Event 5142 records a share being added, 5143 a share being modified and 5144 a share being deleted. A share created in the incident window, used briefly and then deleted, is classic exfiltration or tool-delivery infrastructure. Correlate the share name against the 5140/5145 access that followed it, and note the SubjectUserName that created it, because an attacker standing up a share is a deliberate act that a legitimate admin change should also explain.

  4. 4

    Use local object-access auditing where present

    If the sensitive folders carry a SACL, local file access is logged regardless of the network path. Event 4663 records an attempt to access an object, with ObjectName (the full local path), AccessMask, ProcessName and HandleId; 4656 is the handle request, 4658 the close and 4660 a deletion. These catch access by a local process, not only over SMB, and the ProcessName tells you which tool read the file. This depends on a SACL being configured in advance, which is uncommon, so treat its presence as a bonus.

  5. 5

    Attribute access to a session and source

    Tie the file activity to a who and a where. The 5140/5145 IpAddress names the source host; join SubjectLogonId to the 4624 (typically LogonType 3) that opened the session to confirm the account and the source. Reads of many files in a short burst from one session point to staging or collection; follow the same session forward to a copy destination or an outbound transfer. This turns a list of touched files into an attributed data-access story suitable for a report.

Where it goes wrong

  • 5145 is written per file access check and is extremely high volume, and its Detailed File Share subcategory is off by default, so it often simply does not exist and, where it does, it is noisy.
  • 5140 and 5145 log the access check, not confirmed bytes read, so they prove an attempt and the rights requested, not that the full file was exfiltrated.
  • 4663 requires a SACL to have been configured on the folder before the activity, which is rare, so its absence tells you nothing about whether files were read.
  • Administrative-share access (C$, ADMIN$) is normal for administrators and backup software, so baseline the legitimate accessors before treating it as malicious.
  • AccessMask is a bitmask, so a single value can combine read, write and delete rights; decode the bits rather than matching whole numbers.
  • RelativeTargetName is relative to the share root, not an absolute path, so reconstruct the full path from ShareName plus RelativeTargetName.

Beyond event logs

$MFT and USN journal

The volume $MFT and $Extend\$UsnJrnl:$J on the file server

File-system metadata records file creation, modification and deletion with timestamps, confirming whether a file logged as accessed was actually copied, changed or removed, independent of the share events.

Shellbags and jump lists

On the source host: NTUSER.DAT / UsrClass.dat shellbags and the automatic jump lists

Show which remote folders a user browsed and which files were recently opened from the share, corroborating interactive access from the source side.

SRUM network usage

C:\Windows\System32\sru\SRUDB.dat

Records bytes sent and received per application, which helps estimate whether the volume of data matches a bulk copy off the share.

Staged file remnants

%TEMP%, C:\Windows\Temp, or an attacker staging folder on the source or destination

Collected files are often archived (for example into a .zip or .7z) before exfiltration; a staging archive dated to the access window ties the share reads to an exfiltration attempt.

References