SMB — Hub

What is SMB?

Server Message Block (SMB) is a network file-sharing protocol used by Windows for sharing files, printers, and named pipes across a network. It runs over TCP and is one of the most commonly attacked services in a Windows environment.

OSCP relevance: SMB is almost always present on Windows targets. It enables file share access, user enumeration, relay attacks, credential dumping, and lateral movement.


Ports

PortProtocolDescription
139/TCPNetBIOS Session ServiceOlder SMB over NetBIOS
445/TCPSMB Direct (CIFS)Modern SMB — target this one
137/UDPNetBIOS Name ServiceName resolution
138/UDPNetBIOS Datagram ServiceConnectionless data

SMB Versions

VersionOSNotes
SMBv1Windows XP / 2003 / 7Vulnerable to EternalBlue (MS17-010). Disabled by default in modern Windows.
SMBv2Windows Vista / 2008+More efficient; still widely used
SMBv3Windows 8 / 2012+Encryption support; current standard

Quick Enumeration Flow

1. Nmap scan — confirm ports 139/445 open, grab version banner
2. Anonymous / null session test — can you list shares without creds?
3. Enumerate shares — what shares exist? what can you access?
4. Enumerate users / groups — via RPC or SMB
5. Check for known vulns — EternalBlue, PrintNightmare, etc.
6. Authenticated access — use creds to read/write shares, exec commands

1. Nmap — Initial SMB Recon

# Version + default SMB scripts
nmap -p 139,445 -sV --script smb-security-mode,smb2-security-mode,smb-os-discovery 10.10.10.10
 
# Full SMB script suite
nmap -p 139,445 --script smb-enum-shares,smb-enum-users,smb-vuln* 10.10.10.10
 
# Check for EternalBlue specifically
nmap -p 445 --script smb-vuln-ms17-010 10.10.10.10
 
# SMB signing check (important for relay attacks)
nmap -p 445 --script smb2-security-mode 10.10.10.10

2. Null / Anonymous Session

A null session uses no username or password — works on older or misconfigured systems:

smbclient -L //10.10.10.10 -N           # List shares anonymously
smbmap -H 10.10.10.10                   # Map shares, show permissions
enum4linux -a 10.10.10.10               # Full anonymous enumeration
crackmapexec smb 10.10.10.10            # Quick banner + signing info

Sub-Notes (This Folder)

NoteCovers
smbclientBrowse and interact with SMB shares interactively
smbmapEnumerate shares and permissions, recursive listing, file search
enum4linuxFull SMB/RPC enumeration — users, groups, shares, OS info
rpcclientLow-level RPC commands for user/group/SID enumeration
CrackMapExec - nxcSpray credentials, exec commands, dump hashes across many hosts
NoteCovers
ImpacketHub — all Impacket scripts
Remote Executionpsexec, wmiexec, smbexec, atexec
secretsdumpRemote hash dump (SAM, NTDS)
Kerberos ScriptsGetUserSPNs, GetNPUsers, ticketer
ntlmrelayxNTLM relay attacks
mssqlclientMSSQL shell
Impacket Enumerationlookupsid, rpcdump, smbclient, reg
NoteCovers
ResponderLLMNR/NBT-NS poisoning → capture NTLMv2 hashes; NTLM relay with ntlmrelayx

Common Attack Paths

ScenarioTool
List shares anonymouslysmbclient, smbmap, enum4linux
Enumerate users without credsenum4linux, rpcclient
Password spray across subnetCrackMapExec - nxc
Login and browse sharessmbclient, smbmap
Execute commands with valid credsCrackMapExec - nxc, Remote Execution
Dump NTLM hashessecretsdump, CrackMapExec - nxc
EternalBlue (MS17-010)MetaSploit exploit/windows/smb/ms17_010_eternalblue
Pass-the-HashCrackMapExec - nxc, Remote Execution
LLMNR/NBT-NS poisoning → capture NTLMv2Responder
NTLM relay (no cracking needed)Responder + ntlmrelayx
Kerberoasting / AS-REPKerberos Scripts, Kerberoast