smbclient
Table of Contents
smbclient is an FTP-like command-line client for interacting with SMB/CIFS shares — the standard tool for browsing, downloading from, and uploading to Windows file shares from Linux without mounting them. Part of the Samba suite.
Related: Active Directory Nmap BloodHound Snaffler File Transfers
Enumerating Available Shares
# List shares on a target — anonymous/null session smbclient -L //10.10.10.10/ -N # List shares with credentials smbclient -L //10.10.10.10/ -U 'username%password' # Against a domain-joined target, specify the domain smbclient -L //10.10.10.10/ -U 'DOMAIN\username%password'
The `-N` flag suppresses the password prompt for a null/anonymous session attempt — worth trying first on any discovered SMB service, since misconfigured anonymous access is a common and fast win.
Connecting to a Share
# Connect interactively to a specific share smbclient //10.10.10.10/sharename -N smbclient //10.10.10.10/sharename -U 'username%password' # Once connected, an interactive prompt accepts FTP-like commands: # ls, cd, get <file>, put <file>, mget *, prompt (toggle confirmation)
Common Interactive Commands
| Command | Effect |
|---|---|
ls |
List files in current remote directory |
cd <dir> |
Change remote directory |
lcd <dir> |
Change local directory (where downloads land) |
get <file> |
Download a single file |
mget * |
Download multiple files (prompts per file unless prompt toggled off) |
put <file> |
Upload a file |
recurse |
Toggle recursive mode for directory operations |
prompt |
Toggle confirmation prompts on mget=/=mput |
Non-Interactive / Scripted Usage
For automation or quick one-off retrieval without entering the interactive prompt:
# Run a single command non-interactively smbclient //10.10.10.10/sharename -N -c 'ls' # Download a specific file directly smbclient //10.10.10.10/sharename -N -c 'get flag.txt' # Recursively download an entire share smbclient //10.10.10.10/sharename -N -c 'prompt OFF; recurse ON; mget *'
Enumerating with Null Sessions
A null session (no username/password) sometimes grants read access to shares that shouldn't be exposed — always worth checking early in SMB enumeration:
# Full share listing with a null session smbclient -L //10.10.10.10/ -N # If a share like IPC$ or a named share responds without error, # attempt to connect and browse smbclient //10.10.10.10/IPC$ -N
Combine with `enum4linux` or `enum4linux-ng` for broader null-session enumeration (users, groups, password policy) beyond just shares — smbclient alone only covers the file-share angle.
Tips
- Always try `-N` (anonymous) first before assuming credentials are required — misconfigured shares with anonymous read/write access are a common finding, and smbclient makes confirming it a single command
- If a share allows write access, that's a potential foothold vector worth investigating — an uploaded webshell or malicious file dropped into a share that a service later executes from is a classic chain
- Watch for shares named after usernames or generic terms like
backup,scripts,IT, orusers$— these often contain higher-value content than the default administrative shares (C$,ADMIN$,IPC$) smbmapis a useful companion tool for quickly seeing read/write permissions across all shares in one pass, rather than checking each one individually with smbclient — reach for it first to triage which shares are worth a deeper smbclient session- Credentials found elsewhere on an engagement (config files, Kerberoasting, password reuse) should always be tried against SMB shares — file shares are a common place to find sensitive documents, scripts with hardcoded credentials, or backup files worth cracking