SMB Share Enumeration
SMB share enumeration identifies every share exposed on a target, maps read and write permissions for the current credential set, and explores file contents inside accessible shares. Exposed shares frequently contain configuration files, scripts, backups, and credential material.
List Shares and Permissions with nxc
SMB 10.10.10.5 445 DC01 Share Permissions Remark SMB 10.10.10.5 445 DC01 ADMIN$ Remote Admin SMB 10.10.10.5 445 DC01 Backups READ,WRITE SMB 10.10.10.5 445 DC01 C$ Default share SMB 10.10.10.5 445 DC01 IPC$ READ Remote IPC SMB 10.10.10.5 445 DC01 NETLOGON READ Logon server share SMB 10.10.10.5 445 DC01 SYSVOL READ Logon server share
Explain command
| $TARGET_IP | Target host IP address to connect to via SMB. |
| -u $USER | Username to authenticate with. |
| -p $PASSWORD | Password to authenticate with. |
| --shares | Enumerate available SMB shares on the target. |
READ,WRITE on a non-default share is worth exploring immediately. ADMIN$ and C$ with access means admin-level credentials — pivot to Pass-the-Hash over SMB or AD Remote Execution. SYSVOL and NETLOGON are readable by any domain user — check them for Group Policy files and logon scripts.
Anonymous share listing:
Explain command
| $TARGET_IP | Target host IP address to connect to via SMB. |
| -u '' | Authenticate with an empty/null username (anonymous auth). |
| -p '' | Authenticate with an empty/null password (anonymous auth). |
| --shares | Enumerate accessible SMB shares on the target. |
Spider Share Contents with nxc
After identifying readable shares, search their contents without manual browsing:
Explain command
| $TARGET_IP | Target host IP address to connect to via SMB. |
| -u $USER | Username for SMB authentication. |
| -p $PASSWORD | Password for SMB authentication. |
| --spider $SHARE | Recursively spider the specified SMB share for files. |
| --pattern '\..txt$|\..xml$|\..ini$|\..conf$|\..config$|\..ps1$|\..bat$' | Regex pattern to filter files by extension during spidering. |
Search file content for credential patterns:
Explain command
| $TARGET_IP | Target host IP address to connect to via SMB. |
| -u $USER | Username to authenticate with. |
| -p $PASSWORD | Password to authenticate with. |
| --spider $SHARE | Recursively spider the specified SMB share. |
| --content | Download and search file contents during spidering. |
| --pattern 'password|passwd|secret|token' | Regex pattern to match sensitive strings in file contents. |
smbclient for Interactive Browsing
List shares:
Explain command
| -L | List available shares on the specified SMB server. |
| //$TARGET_IP | Target SMB server IP address in UNC path format. |
| -U $USER%$PASSWORD | Authenticate with specified username and password (user%pass format). |
Connect to a share:
Explain command
| //$TARGET_IP/$SHARE | UNC-style path specifying target IP and SMB share name to connect to |
| -U $USER%$PASSWORD | Specifies the username and password separated by % for authentication |
Useful commands inside the session:
ls list current directory
cd PATH change directory
get filename download a single file
recurse ON enable recursive listing
prompt OFF disable download prompts
mget * download everything recursively
Recursive listing in one command:
Explain command
| //$TARGET_IP/$SHARE | UNC-style path specifying target IP and SMB share name to connect to. |
| -U $USER%$PASSWORD | Authenticates with the specified username and password (user%pass format). |
| -c 'recurse ON; ls' | Executes SMB commands: enables recursive listing then lists all files. |
Recursive download of an entire share:
Explain command
| //$TARGET_IP/$SHARE | UNC-style path specifying target SMB server IP and share name. |
| -U $USER%$PASSWORD | Authenticate with specified username and password separated by %. |
| -c 'prompt OFF; recurse ON; mget *' | Run commands: disable prompts, enable recursion, download all files. |
smbmap for Permission Mapping
Explain command
| -H $TARGET_IP | Specifies the target host IP address to connect to. |
| -u $USER | Specifies the username for SMB authentication. |
| -p $PASSWORD | Specifies the password for SMB authentication. |
Recursive listing of a specific share:
Explain command
| -H $TARGET_IP | Specifies the target host IP address to connect to. |
| -u $USER | Specifies the username for SMB authentication. |
| -p $PASSWORD | Specifies the password for SMB authentication. |
| -r $SHARE | Recursively lists the contents of the specified share. |
Download a specific file:
Explain command
| -H $TARGET_IP | Specifies the target host IP address to connect to. |
| -u $USER | Specifies the username for SMB authentication. |
| -p $PASSWORD | Specifies the password for SMB authentication. |
| --download '$SHARE\path\to\file.txt' | Downloads the specified file from the given SMB share path. |
impacket-smbclient
Works well when smbclient has issues with SMB signing requirements or dialect negotiation. Also handles pass-the-hash directly:
Explain command
| $DOMAIN/$USER:$PASSWORD@$TARGET_IP | Target credentials and host in domain/user:password@host format. |
Pass-the-hash:
Explain command
| -hashes :$NTHASH | Authenticate using LM:NT hash pair; LM left empty, NT hash provided. |
| $DOMAIN/$USER@$TARGET_IP | Target specifying domain, username, and IP address for SMB connection. |
The same ls, cd, get, and mget commands apply inside the session.
Mounting Shares
Mounting gives access to local tools like grep and find against share contents:
Explain command
| -p | Create parent directories as needed, no error if existing. |
| -t cifs | Specifies the filesystem type as CIFS (SMB protocol). |
| //$TARGET_IP/$SHARE | UNC-style path to the remote SMB share host and name. |
| /mnt/smb | Local mount point directory for the remote share. |
| -o username=$USER | SMB authentication username for the remote share. |
| -o password=$PASSWORD | SMB authentication password for the remote share. |
| -o domain=$DOMAIN | Windows domain or workgroup for SMB authentication. |
Anonymous mount:
Explain command
| -t cifs | Specifies the filesystem type as CIFS (SMB protocol). |
| //$TARGET_IP/$SHARE | UNC-style path to the remote SMB share on the target host. |
| /mnt/smb | Local mount point directory where the share will be attached. |
| -o guest | Mounts the share without authentication using guest access. |
After mounting, search for credential material:
Explain command
| -r | Recursively search through all subdirectories. |
| -i | Perform case-insensitive pattern matching. |
| 'password\|passwd\|secret\|connectionstring' | Regex pattern matching common credential-related keywords. |
| /mnt/smb/ | Target directory; mounted SMB share to search within. |
| 2>/dev/null | Suppress stderr output by redirecting errors to null. |
| /mnt/smb | Root directory to search; mounted SMB share. |
| -name "*.xml" | Match files with .xml extension. |
| -name "*.config" | Match files with .config extension. |
| -name "*.ini" | Match files with .ini extension. |
| -name "*.ps1" | Match PowerShell script files with .ps1 extension. |
| -o | Logical OR operator to combine multiple -name expressions. |
Unmount when done:
High-Value Shares
SYSVOL and NETLOGON on domain controllers contain Group Policy files and logon scripts. Check for Groups.xml, Services.xml, Scheduledtasks.xml, and Datasources.xml — these may contain cpassword values encrypted with a publicly documented Microsoft key:
Explain command
| /mnt/smb | Starting directory for the search, typically a mounted SMB share. |
| -name "*.xml" | Match files with .xml extension. |
| 2>/dev/null | Suppress stderr by redirecting errors to null device. |
| -l | Print only filenames of files containing the match, not the lines. |
| "cpassword" | Search term targeting GPP encrypted passwords in Group Policy XML files. |
Backup shares frequently contain database dumps, configuration archives, and directory backups.
IT and scripts shares commonly hold PowerShell and batch scripts with hardcoded credentials.
References
-
Pennyw0rth/NetExecgithub.com/Pennyw0rth/NetExec (opens in new tab)
nxc SMB share listing, spidering, and content search
-
smb-enum-shares NSE Scriptnmap.org/nsedoc/scripts/smb-enum-shares.html (opens in new tab)
Nmap-based share enumeration
-
fortra/impacketgithub.com/fortra/impacket (opens in new tab)
impacket-smbclient for SMB access including pass-the-hash
Was this helpful?
Your feedback helps improve this page.