Event ID 5145
Event ID 5145: Detailed File Share Access
A network share object was checked to see whether client can be granted desired access
- Log source
- Security
- How to enable it
- Object Access > Audit Detailed File Share (Success and Failure)
- Category
- Lateral Movement
- Priority
- High
- Typical volume
- Very high
- MITRE ATT&CK
What Event ID 5145 means
5145 records each file, folder or named pipe that a client asks for through a share. No SACL is needed, so switching on the subcategory covers every share on the host at once, which is both its strength and its cost.
Named pipes make it special. Remote management protocols run over pipes on IPC$, and the pipe name appears in RelativeTargetName. svcctl means that someone is controlling services, atsvc that someone is creating tasks, winreg that someone is reading the registry, and samr or lsarpc that accounts are being enumerated.
On file servers the volume can reach millions of events a day. Enable it on domain controllers and on servers of high value first, and on workstations where inbound SMB is rare and therefore cheap to log and meaningful.
Key fields to inspect
| Field | Meaning | Suspicious when |
|---|---|---|
RelativeTargetName | File, folder or pipe inside the share. | PSEXESVC.exe, random .exe names, svcctl, atsvc, winreg, samr, or *.dit and *.vhdx. |
ShareName | Share, as \\*\name. | \\*\ADMIN$, \\*\C$ and \\*\IPC$ from a workstation. |
AccessMask | Rights that were requested, in hexadecimal. | Write rights (bit 0x2) on ADMIN$. |
IpAddress | Source address. | A host that does not manage this one. |
SubjectUserName | Account that asked. | A user, or a local administrator account. |
AccessReason | Why each right was granted or denied. | Granted by membership in Administrators. |
IpPort | Source port. | Useful for matching firewall records. |
Named pipes worth knowing
| Pipe | Service | Associated activity |
|---|---|---|
svcctl | Service Control Manager | PsExec and remote service creation |
atsvc | Task Scheduler | atexec and remote tasks |
winreg | Remote Registry | secretsdump reading SAM and LSA secrets |
samr | Security Account Manager | User and group enumeration |
lsarpc | Local Security Authority | SID and policy lookups |
srvsvc | Server service | Share and session enumeration |
spoolss | Print Spooler | Coerced authentication and print exploits |
efsrpc | Encrypting File System | Coerced authentication (PetitPotam) |
Detection queries
Find executables written to administrative shares, and sensitive pipes opened remotely. Adjust names and thresholds to your environment. About these queries.
Splunk SPL
index=windows source="XmlWinEventLog:Security" EventCode=5145
| eval write=if(match(ShareName, "(?i)ADMIN\$|C\$") AND match(RelativeTargetName, "(?i)\.(exe|dll|bat|ps1|sys)$"), 1, 0), pipe=if(match(ShareName, "(?i)IPC\$") AND match(RelativeTargetName, "(?i)^(svcctl|atsvc|winreg|efsrpc|spoolss|PSEXESVC)"), 1, 0)
| where write=1 OR pipe=1
| stats values(RelativeTargetName) AS targets values(AccessMask) AS masks count BY Computer IpAddress SubjectUserName Microsoft Sentinel KQL
SecurityEvent
| where EventID == 5145
| where (ShareName has_any ("ADMIN$", "C$") and RelativeTargetName matches regex @"(?i)\.(exe|dll|bat|ps1|sys)$") or (ShareName has "IPC$" and RelativeTargetName matches regex @"(?i)^(svcctl|atsvc|winreg|efsrpc|spoolss|PSEXESVC)")
| summarize Targets = make_set(RelativeTargetName, 30), Masks = make_set(AccessMask), Count = count() by Computer, IpAddress, SubjectUserName, bin(TimeGenerated, 10m) PowerShell
Get-WinEvent -FilterHashtable @{ LogName = 'Security'; Id = 5145; StartTime = (Get-Date).AddDays(-1) } |
ForEach-Object { $d = @{ Time = $_.TimeCreated }; ([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }; [pscustomobject]$d } |
Where-Object { $_.RelativeTargetName -match '^(svcctl|atsvc|winreg|efsrpc)|\.exe$' } |
Select-Object Time, SubjectUserName, IpAddress, ShareName, RelativeTargetName, AccessMask | Format-Table -AutoSize Attack scenarios
PsExec and Impacket
The sequence over a single session is IPC$ svcctl, ADMIN$ with a new .exe, and then a service (7045). Impacket's output files, such as __output, are read back through the same shares.
Remote credential dumping
secretsdump starts Remote Registry, opens winreg, saves hives to Windows\Temp or System32 with random .tmp names, and reads them over ADMIN$. Each step is visible.
Coerced authentication
A client opens efsrpc or spoolss on a domain controller to make it authenticate to a machine under the attacker's control, which relays the credentials to another service.
Investigation checklist
- List everything the same address and account requested within the minute.
- Match the session to 4624 and 4672 for the logon and its privileges.
- For executables, collect the file and check for 7045, 4698 and 4688.
- For winreg with temporary files, assume that local and cached credentials are stolen.
Common benign causes
- Management and deployment systems that use services, tasks and ADMIN$.
- Domain controllers, where samr, lsarpc and netlogon are constant.
- Print servers, for spoolss.
Event ID 5145 FAQ
Does event 5145 mean that a file was opened?
It means that access was checked, and the result is in the event. The client could have been denied or may only have asked for attributes. Use AccessMask, and 4663 if a SACL is present, to establish what was done.
Why is event 5145 so noisy?
It is written for every object checked on every share, including folder browsing. Restrict it to hosts where SMB is rare, and filter on administrative shares and named pipes when you collect.
Which named pipes indicate lateral movement?
svcctl for remote services and atsvc for remote tasks are the most direct. winreg with temporary hive files points to credential theft. Unknown pipe names with random letters can belong to command-and-control frameworks.