SMB (with NTLM)
Server Message Block is Windows file sharing, and much more: named pipes for remote administration (RPC), printer sharing, and the transport for NTLM and Kerberos logins. It is the protocol behind most lateral movement in Windows networks.
- OSI layer
- 7 Application
- Carried in
- TCP (also QUIC on 443/udp)
- Ports
- 445/tcp, 139/tcp (over NetBIOS, legacy)
- Specs
- MS-SMB2, MS-NLMP
- Wireshark filter
smb2 || smb || ntlmssp- Encrypted
- no
Packet structure
Every SMB2/3 message starts with this 64-byte header, followed by a command-specific body:
Select a field to see what it does.
Over port 445 each message is prefixed with a 4-byte length (Direct TCP transport). Over 139 the same 4 bytes are a NetBIOS session header. With SMB 3 encryption, a 52-byte transform header (0xFD 'SMB') replaces the clear header and everything after it is encrypted.
How it works
sequenceDiagram
participant C as Client
participant S as Server :445
C->>S: NEGOTIATE (dialects 2.0.2 to 3.1.1)
S->>C: NEGOTIATE response (dialect, signing required?, GSS token)
C->>S: SESSION_SETUP (NTLM NEGOTIATE or Kerberos AP-REQ)
S->>C: SESSION_SETUP (NTLM CHALLENGE, STATUS_MORE_PROCESSING_REQUIRED)
C->>S: SESSION_SETUP (NTLM AUTHENTICATE)
S->>C: SESSION_SETUP response (success, Session ID)
C->>S: TREE_CONNECT \\server\share
S->>C: Tree ID
C->>S: CREATE / READ / WRITE / IOCTL / CLOSE
- Negotiate: the client lists the dialects it speaks; the server picks one and says whether signing is required. SMB 3.1.1 protects this step with a pre-authentication hash.
- Session setup: authentication through SPNEGO, which picks Kerberos if the client has a ticket for the server name, otherwise NTLM.
- Tree connect: connect to a share.
IPC$is special: it gives access to named pipes such as\srvsvc,\samr,\lsarpc,\svcctland\winreg, which carry DCE/RPC calls for remote administration. - File operations: CREATE returns a file handle, then READ, WRITE, QUERY_INFO, CLOSE.
NTLM inside SMB
NTLM is a challenge-response login in three messages, carried in the SESSION_SETUP security blob (the same messages appear in HTTP, LDAP, RDP and others):
| Message | Direction | Content |
|---|---|---|
NEGOTIATE (type 1) | Client → server | Supported features (flags) |
CHALLENGE (type 2) | Server → client | 8-byte random server challenge, target info (domain, host names, timestamp) |
AUTHENTICATE (type 3) | Client → server | User name, domain, workstation and the response, computed from the challenge and the user’s NT hash |
The server cannot check the response itself for a domain account: it forwards it to a domain controller (Netlogon). The password never crosses the wire, but the response is enough to crack it offline or to relay it.
In Wireshark
| Filter | Shows |
|---|---|
smb2 | SMB2/3 |
smb | SMB1 (should be empty) |
smb2.cmd == 1 | Session setups (logins) |
ntlmssp.messagetype == 3 | NTLM AUTHENTICATE: user, domain, workstation |
ntlmssp.auth.username | Add as a column to list who logs in |
smb2.nt_status == 0xc000006d | Failed logins (spraying shows many) |
smb2.cmd == 3 | Tree connects (which shares, e.g. ADMIN$, C$) |
smb2.filename contains "svcctl" | Service control pipe (PsExec-style remote execution) |
smb2.flags.signature == 0 && smb2.cmd > 1 | Unsigned messages after login |
smb2.cmd == 5 && smb2.filename | Opened files and pipes |
File › Export Objects › SMB extracts transferred files. With the user’s password (or NT hash) configured under NTLMSSP preferences, Wireshark decrypts SMB 3 encrypted sessions.
What normal looks like: clients talk SMB to file servers and domain controllers (SYSVOL, NETLOGON for group policy). Workstation-to-workstation SMB, connections to ADMIN$ or C$, or a new service created over \svcctl are typical lateral movement. SMB to the internet should not exist (leaks NTLM hashes).
Security notes
- NTLM relay: an attacker who receives an NTLM login (from LLMNR/NBT-NS poisoning, a coerced authentication like PetitPotam, or a malicious link to
\\attacker\share) forwards it to another server and logs in as the victim. Prevented by SMB signing required on all hosts (default on Windows 11 24H2 and Server 2025), EPA/channel binding on LDAP and HTTP, and disabling NTLM where possible. - Hash capture and cracking: the NTLMv2 response in a capture can be cracked offline (
hashcat -m 5600). NTLMv1 is much weaker and should be disabled (LmCompatibilityLevel 5). - Pass-the-hash: the NT hash alone is enough to compute NTLM responses, so a dumped hash logs in without the password.
- Lateral movement: PsExec, Impacket
smbexec/wmiexecand many ransomware families copy a binary toADMIN$and start it through the service control manager pipe. - SMB1 vulnerabilities: EternalBlue (MS17-010, WannaCry, NotPetya). SMB1 should be disabled everywhere;
smb(notsmb2) traffic is a finding. - SMBGhost (CVE-2020-0796): a bug in SMB 3.1.1 compression.
- Enumeration: null sessions and anonymous
IPC$access list shares, users and groups (enum4linux,netexec). - Exposed 445: blocked at the internet edge by most ISPs and firewalls, for good reason.
Versions and related
- SMB1 / CIFS: the original (
0xFF 'SMB'header), insecure, off by default since Windows 10 1709. - SMB 2.0.2 / 2.1: Vista / 7, far fewer commands, larger reads and writes.
- SMB 3.0 / 3.0.2 / 3.1.1: encryption (AES-CCM, AES-GCM), pre-auth integrity, multichannel. SMB over QUIC (Windows Server 2022+) runs on UDP 443 with TLS 1.3.
- NTLMv1, NTLMv2, Kerberos: the logins SMB carries; Kerberos is preferred and NTLM is being phased out by Microsoft.
- NetBIOS (137, 138/udp, 139/tcp) and LLMNR / mDNS: name resolution whose poisoning feeds NTLM relay.
- Samba: the open-source SMB implementation on Linux and NAS devices.
- Runs over TCP; directory lookups use LDAP.
References
- MS-SMB2: SMB 2 and 3 protocol specification
- MS-NLMP: NTLM authentication protocol
- Microsoft: SMB signing overview
- MS17-010 (EternalBlue)