Hacker Directory — Understand what you hack.Hacker Directory — Understand what you hack.
Continue learning
TR
Contents15 chapters · 82 lessons
LESSON 01.04DERİN TEKNİK İNCELEME

What happens from start to finish when a user accesses a file share?

Finding the target for a UNC path is different from establishing an SMB session and authorizing a file operation. The client first reaches the server and establishes SMB session and share context; the file server then makes the final access decision using the requested rights, the client security context, and permissions on the resource.

1. Core mechanism

The client application and Windows SMB client operate between the SMB service and resource manager on the file server. This lesson separates discovery, the SMB session, the share connection, and the file-open decision; Kerberos message detail belongs in 06.x, and DACL evaluation in 05.03–05.04.

Interfaces and specifications

  • UNC name: \server\share\path identifies the target server, share, and relative path.
  • MS-SMB2: NEGOTIATE establishes connection capabilities; SESSION_SETUP establishes the user security context; TREE_CONNECT establishes share context; CREATE requests that a file or directory be opened.
  • SSPI: during SESSION_SETUP, SMB uses Kerberos or another suitable Windows authentication package; Kerberos is not the only option.
  • CREATE request: the target object and requested access mask become inputs to the file-server resource decision.
  • Windows Security Event 5145 records the subject, share, relative target, and audited access fields on the resource host.

Finding a path is not granting access

When an application requests \FS01\Finance\reports\summary.txt, the first step is to determine which address and current connection state correspond to FS01. This stage only resolves how to reach the target.

After connecting to the server, the SMB client selects common protocol features with NEGOTIATE. Completing negotiation does not show that the user identity was verified or that the Finance share can be opened.

Each stage supplies input to the next, but success at an earlier stage does not predetermine the next decision.

The session and share are separate contexts

SESSION_SETUP uses the selected authentication package through SSPI and establishes an SMB session security context representing the client on the server. Depending on the environment and conditions, a supported package other than Kerberos may be used.

TREE_CONNECT binds the session to a specific share. Authentication to the server does not mean that every share connection will be accepted.

This distinction is important in the event review: the ticket operation on the domain controller does not replace the session and share request on FS01.

The file decision is made at CREATE

The client carries the target and requested rights in the CREATE message. CREATE does not mean only “make a new file”; it also requests that an existing file or directory be opened.

The server evaluates the client token or security context against share and file-system security definitions. Authentication supplies a principal for that evaluation; it does not guarantee the result.

A reliable evidence chain records the user or session, share, relative target, requested right, and host that made the decision separately.

State and data flow

  1. The application requests a UNC path; the client resolves the target server and selects a connection.
  2. The client and FS01 negotiate the SMB version and connection capabilities with NEGOTIATE messages.
  3. SESSION_SETUP authenticates through SSPI and establishes a session security context on FS01.
  4. TREE_CONNECT binds that session to the Finance share.
  5. CREATE carries the requested access mask for reports\summary.txt.
  6. FS01 evaluates the security context against share and file-system permissions.
  7. The allowed operation proceeds; evidence for a rejected stage is sought at that stage’s observation point.

2. Exploitation

Broken trust assumption

Broken assumption: the party using valid identity material is necessarily the account owner, and successful authentication is sufficient to access the target file.

Technical prerequisites

  • Available account, ticket or existing session material.
  • Access to the file server and the target share is available.
  • The represented principal has at least one relevant share and file right on the target.

Exploitation mechanism

An attacker uses the legitimate SMB flow to establish a session as the represented principal and requests listing, reading, or writing within that principal’s existing rights. The mechanism does not bypass the DACL: an incorrect target, unusable credential, closed network path, or insufficient right stops the operation.

A valid session does not upgrade authorization

Acceptance of SESSION_SETUP shows only that the server established a security context. The target resource still makes the subsequent share and file decisions.

The effect of a captured secret is limited to the rights the account actually has. A credential does not automatically open every share and file.

The attack boundary for this lesson

This lesson does not describe credential extraction, relay, or ticket-forging steps. Its purpose is to show which trust assumption normal access flow carries when identity material is available.

To measure impact, record the resource host, share, target path, and requested right along with the principal name.

3. Defense & Detection

Telemetry scope

  • Enable the Audit Detailed File Share subcategory for Success and/or Failure on the resource file server.
  • A share SACL is not required for 5145, but measure scope and storage before enabling collection because event volume can be high.
  • 5145 Failure indicates a denial at the share level; the same failure record may not be generated for an NTFS-level denial.
  • Domain-controller ticket events support the ticket process; they do not by themselves prove that a file was opened.

Events and relevant fields

  • 5145 / SubjectUserSid, SubjectUserName, SubjectDomainName, SubjectLogonId: security context that made the request.
  • 5145 / IpAddress, IpPort: the client network context.
  • 5145 / ShareName, ShareLocalPath, RelativeTargetName: the share and relative target on the resource.
  • 5145 / AccessMask, AccessList, AccessReason: requested rights and the decision reason reported by Windows.
  • 5145 / Version 0: the documented schema applies at least to Windows Vista and Windows Server 2008.

What question does 5145 answer?

Event 5145 shows which subject requested access to which share and relative target on the resource host. It is therefore a more direct observation point for the file target than a ticket record on the DC.

The evidence boundary still matters: a final NTFS decision is not the same as a share-level event.

Strengthening the correlation evidence

With 4624 on the same resource host, SubjectLogonId can be compared using client address and time. Account for collection delay and field normalization when assessing the match.

Ticket, session, and object-request evidence may come from different hosts. The absence of one event does not automatically disprove success at another stage.

Detection logic · Sigma

title: Hassas SMB hedefinde ayrintili dosya paylasimi istegi
status: experimental
logsource:
  product: windows
  service: security
detection:
  selection:
    EventID: 5145
    ShareName|endswith: '\\Finance'
  condition: selection
fields:
  - SubjectUserName
  - SubjectDomainName
  - SubjectLogonId
  - IpAddress
  - ShareName
  - RelativeTargetName
  - AccessMask
  - AccessReason
falsepositives:
  - Yetkili kullanici ve uygulamalarin normal dosya islemleri
level: low

Query assumptions

  • The field names are Windows EventData/Data[@Name] names; map them if the target backend normalizes fields.
  • The rule selects candidate events only; it does not by itself establish success, an NTFS result, or file content access.
  • Collectors may store ShareName with different escaping or normalization.
  • The rule was not run against a real SIEM or dataset.

False positives

  • Normal file access by authorized users and applications.
  • Backup, software-distribution, antivirus-scanning, and indexing processes.
  • High event volume is expected on busy shares such as SYSVOL.

Hardening

  • Manage share and NTFS permissions with least privilege and remove unnecessary shares.
  • Enable Success auditing for critical paths, then introduce Failure auditing gradually for broader coverage.
  • Document the current workflow and rollback path before a change, then verify the resource-host telemetry for the access result.

Read the examples

READ THE EXAMPLE TOGETHER

SYNTHETIC TEACHING EXAMPLE

Who requested which right on which file?

5145 · detailed file-share request (Event XML, Version 0)

01
Requesting account SIDS-1-5-21-111111111-222222222-333333333-1104

SubjectUserSid identifies the requesting account. Account name and domain are separate fields; this SID is not the file owner.

02
Share\\*\Finance

The share receiving the request. RelativeTargetName is a path within it; ShareLocalPath is the server-local path.

03
Target within the sharereports\summary.txt

This example requests reports\summary.txt. Read it with the share name; the field does not establish a completed read.

04
Requested right0x1

In this synthetic file example, 0x1 requests ReadData. AccessMask describes requested access, not NTFS permission or completed I/O.

What to take away

Read the account, share, target path and requested right together in 5145. This excerpt omits AccessReason and the audit outcome; do not infer the share-check result, NTFS decision or completed read.

This guide explains selected fields of the synthetic fixture. Editing returns to generic reading; no Windows operation or event authenticity is verified.

Scope of this example

Synthetic, schema-oriented selection of fields; it is not a real Windows or lab record. EventData names, EventID 5145, and Version 0 are included for parser-level review. AccessReason does not include the complete event context and cannot prove that the file was opened, read, or passed the NTFS check.

Open the raw record · EVENT-XML
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-Security-Auditing" />
    <EventID>5145</EventID>
    <Version>0</Version>
    <Channel>Security</Channel>
    <Computer>FILE01.besiktas.example</Computer>
  </System>
  <EventData>
    <Data Name="SubjectUserSid">S-1-5-21-111111111-222222222-333333333-1104</Data>
    <Data Name="SubjectUserName">kayra</Data>
    <Data Name="SubjectDomainName">BESIKTAS</Data>
    <Data Name="SubjectLogonId">0x123</Data>
    <Data Name="ObjectType">File</Data>
    <Data Name="IpAddress">192.0.2.10</Data>
    <Data Name="IpPort">50123</Data>
    <Data Name="ShareName">\\*\Finance</Data>
    <Data Name="ShareLocalPath">\??\D:\Shares\Finance</Data>
    <Data Name="RelativeTargetName">reports\summary.txt</Data>
    <Data Name="AccessMask">0x1</Data>
  </EventData>
</Event>

Two reality checks

Assumption: If a Kerberos service ticket was issued, access to the file was granted.
In fact: A service ticket supports authentication to the target service. After the SMB session is established, the resource host evaluates share and file rights; the ticket alone is not evidence of that decision.
Assumption: If no 5145 Failure is visible, all file access succeeded.
In fact: 5145 Failure indicates a share-level denial. Under Microsoft’s documented boundary, an NTFS-level denial may not produce 5145 Failure; verify the result with other resource-host evidence.

YOUR TURN

Work through this story.

Go beyond recall: change a condition, read evidence, explain the reason for a decision.

1 / 3 · PREDICT

SMB NEGOTIATE succeeds. What follows?

Choose an answer

A hint

Does this message negotiate identity or connection capabilities?

Read the answer reasoning

Connection/protocol capabilities were negotiated; file permission is still unknown.

SESSION_SETUP, share and CREATE/resource decisions remain separate.

2 / 3 · READ EVIDENCE

Why does no 5145 Failure on FS01 not prove every file read succeeded?

Synthetic resource-host observation summary.
Producer / Üreten host
FS01
Examined event / İncelenen event
5145 Failure
Observation / Gözlem
Not found
NTFS outcome / Sonuç
Not separately observed
Choose an answer

A hint

Consider this event’s share-level scope.

Read the answer reasoning

An NTFS-level denial may not produce 5145 Failure; separate outcome evidence is needed.

Do not turn event absence into proof of success outside its scope.

3 / 3 · EXPLAIN

Why should SMB CREATE not be read only as “creating a new file”?

A hint

Consider the request target and requested access.

Read the answer reasoning

CREATE can also request opening the existing Reports file. FS01 evaluates the target and requested access mask against share/file-system conditions; the message name alone proves neither creation nor success.

  • I stated that it can cover opening an existing file/directory.
  • I identified requested access and the FS01 resource decision.

Your explanation is not automatically graded. Compare the checkpoints with your answer.

Open the case terminal · PowerShell / CMD

Training simulation · Commands and outputs belong to this case.

Read the account name and SID of this session.

Run the prepared script as supplied, or try the everyday commands below.

WS01 · Windows PowerShell 5.1SAMPLE SESSION
IYELABS\tunahanstudent0104 · lesson workspace

Ctrl / ⌘ + Enter: run · Shift + Enter: new line

Curious? Try everyday commands

Tap a command, then Run. User and network details follow the selected sample computer.

These are learning practices; they do not affect certification exam scores.

Sources