Identify SMB running on a host. List only open ports.
sudonmap-sT-sU-sV-p135,137,138,139,445--open<IP>
Nmap Scripts
# Enumerate sharesnmap--scriptsmb-enum-shares-p445<IP># OS Discoverynmap--scriptsmb-os-discovery-p445<IP># Enumerate Usersnmap--script=smb-enum-users-p445<IP># Allnmap--script=smb-enum-users,smb-enum-shares,smb-os-discovery-p139,445<IP>
NULL / Anonymous Login
# On some configuration omitting '-N' will grant access.smbclient-U''-L \\\\<IP>smbclient-U''-N-L \\\\<IP>smbclient-U'%'-N-L \\\\<IP>smbclient-U'%'-N \\\\<IP>\\<Folder># Enter a random username with no password and try for anonymous login.crackmapexecsmb<IP>-u'anonymous'-p''crackmapexecsmb<IP>-u''-p''crackmapexecsmb<IP>-u''-p''--shares
Authenticated
# smbmap, list shares and view permissionssmbmap-H<IP>-u<User>-p<Password># Connect to share as user and prompt for passwordsmbclient-U<User> \\\\<IP>\\<Share>
Download Files
# Grab everything in a sharesmbclient'\\<IP>\<Share>'-N-c'prompt OFF;recurse ON; mget *'# Recursive pattern search for candidate files to downloadsmbmap-H<IP>-u<User>-p<Password>-d<Domain>-R-A"pass*"--depth20smbmap-H<IP>-u<User>-p<Password>-d<Domain>-R-A".txt|.log|.ps1|.vbs|.zip|.xml"