smbclient: Complete Guide to SMB File Sharing, Enumeration, and Remote Access Using Kali Linux

smbclient: Complete Guide to SMB File Sharing, Enumeration, and Remote Access Using Kali Linux

smbclient is part of the official Samba software suite and provides an FTP-like command-line client for accessing SMB/CIFS shares on Windows and Samba servers. Unlike higher-level wrapper tools such as enum4linux, smbclient gives direct, interactive access to a target’s file-sharing service: listing shares, browsing directories, uploading/downloading files, and even sending old-style WinPopup messages. Because it is the reference SMB client shipped with Samba, it is extremely reliable and supports the full range of SMB dialects (SMB1 through SMB3).

In an enumeration context, smbclient is typically used to:

Installation

# Kali Linux (preinstalled as part of smbclient/samba-client package)
sudo apt update
sudo apt install smbclient -y

# Verify
smbclient --version
which smbclient

Syntax

smbclient //<server>/<share> [password] [options]
smbclient -L //<server> [options]

Command-Line Options

OptionDescription
-L, --listList available shares on the host instead of connecting to one
-U username[%password]Specify username (and optionally password)
-N, --no-passAttempt connection with no password (null session)
-I, --ip-addressSpecify IP address to connect to explicitly
-p, --portSpecify port to connect on (default 445)
-W, --workgroupSet workgroup/domain name
-m, --max-protocolSet maximum SMB protocol version to negotiate (e.g., SMB3)
-c, --commandExecute semicolon-separated commands and exit (non-interactive)
-g, --grepableProduce grepable output for -L
-k, --kerberosUse Kerberos authentication
-A, --authentication-fileRead username/password/domain from a file
-t, --timeoutSet connection timeout in seconds
-d, --debuglevelSet debug/verbosity level (0–10)
--pw-nt-hashSupply an NT hash instead of a plaintext password (pass-the-hash)

Interactive shell commands (once connected to a share):

CommandDescription
ls / dirList files in current remote directory
cd <dir>Change remote directory
lcd <dir>Change local directory
get <file>Download a file
mget <pattern>Download multiple files matching a pattern
put <file>Upload a file
mput <pattern>Upload multiple files
mkdir <dir>Create a remote directory
rmdir <dir>Remove a remote directory
del <file>Delete a remote file
recurseToggle recursive mode for mget/mput
promptToggle interactive prompting for mget/mput
more <file>View a file’s contents via pager
exit / quitClose the connection

Basic Usage

List all shares on a target using a null session:

smbclient -L //192.168.56.101/ -N

Expected output:

Anonymous login successful

	Sharename       Type      Comment
	---------       ----      -------
	print$          Disk      Printer Drivers
	tmp             Disk      oh noes!
	opt             Disk
	IPC$            IPC       IPC Service (metasploitable server (Samba 3.0.20-Debian))
	ADMIN$          IPC       IPC Service (metasploitable server (Samba 3.0.20-Debian))
	Server               Comment
	---------            -------
	METASPLOITABLE       metasploitable server (Samba 3.0.20-Debian)
	Workgroup            Master
	---------            -------
	WORKGROUP            METASPLOITABLE

Practical Examples

Example 1 — Anonymous share listing

smbclient -L //192.168.56.101 -N
Anonymous login successful
Sharename       Type      Comment
---------       ----      -------
tmp             Disk      oh noes!

Example 2 — Connect to a share interactively

smbclient //192.168.56.101/tmp -N
Anonymous login successful
Try "help" to get a list of possible commands.
smb: \>

Example 3 — List directory contents once connected

smb: \> ls
  .                                   D        0  Wed Jul 15 05:23:11 2026
  ..                                  D        0  Wed Jul 15 05:23:11 2026
  vulnerable.jpg                      N   214233  Sun Jun  1 12:00:00 2026
  notes.txt                           N       42  Wed Jul 15 05:23:11 2026

		9846680 blocks of size 1024. 5877684 blocks available

Example 4 — Download a file of interest

smb: \> get notes.txt
getting file \notes.txt of size 42 as notes.txt (0.5 KiloBytes/sec)

Example 5 — Recursively download an entire share

smbclient //192.168.56.101/tmp -N -c "recurse ON; prompt OFF; mget *"
getting file \notes.txt of size 42 as notes.txt
getting file \subdir\backup.zip of size 10240 as subdir/backup.zip

Example 6 — Authenticated connection with credentials

smbclient //192.168.56.101/opt -U msfadmin%msfadmin
Try "help" to get a list of possible commands.
smb: \>

Example 7 — Grepable share listing for scripting

smbclient -L //192.168.56.101 -N -g
Disk|print$|Printer Drivers
Disk|tmp|oh noes!
Disk|opt|
IPC|IPC$|IPC Service (metasploitable server (Samba 3.0.20-Debian))
IPC|ADMIN$|IPC Service (metasploitable server (Samba 3.0.20-Debian))

Example 8 — One-shot non-interactive command execution

smbclient //192.168.56.101/tmp -N -c "ls"
  .                                   D        0  Wed Jul 15 05:23:11 2026
  ..                                  D        0  Wed Jul 15 05:23:11 2026
  notes.txt                           N       42  Wed Jul 15 05:23:11 2026

Example 9 — Testing IPC$ share for null session validity

smbclient -L //192.168.56.101 -N -m SMB2
protocol negotiation failed: NT_STATUS_CONNECTION_RESET

(host does not support SMB2; retry without -m)

Example 10 — Uploading a file to a writable share

smb: \> put shell.php
putting file shell.php as \shell.php (12.4 kb/s) (average 12.4 kb/s)

Example 11 — Pass-the-hash authentication

smbclient //192.168.56.101/C$ -U administrator --pw-nt-hash 31d6cfe0d16ae931b73c59d7e0c089c0
Try "help" to get a list of possible commands.
smb: \>

Example 12 — Connecting on a non-default port

smbclient -L //192.168.56.101 -N -p 4455
Anonymous login successful
[share listing as usual]

Common Use Cases

Automation with Bash

#!/bin/bash
# smbclient_share_dump.sh - list and recursively pull every accessible share on a host
TARGET="$1"
OUTDIR="./smb_dump_${TARGET}"
mkdir -p "$OUTDIR"

shares=$(smbclient -L "//$TARGET" -N -g 2>/dev/null | grep -i '^Disk' | cut -d'|' -f2)

for share in $shares; do
    echo "[*] Pulling share: $share"
    mkdir -p "$OUTDIR/$share"
    smbclient "//$TARGET/$share" -N \
        -c "prompt OFF; recurse ON; lcd $OUTDIR/$share; mget *" 2>/dev/null
done

echo "[+] Done. Files saved under $OUTDIR"

Tips and Best Practices

Troubleshooting

ProblemLikely CauseSolution
NT_STATUS_LOGON_FAILUREInvalid credentialsRe-check username/password/domain, try -W for workgroup
NT_STATUS_ACCESS_DENIED on connectAnonymous access disabled for that shareSupply valid credentials with -U
protocol negotiation failed: NT_STATUS_CONNECTION_RESETSMB1 disabled on target (default since Win10 1709+/Server 2019+)Force protocol: smbclient -L //ip -N -m SMB3
Connection hangs indefinitelyPort 445 filtered/blocked by firewallConfirm with nmap -p445 <ip>; try NetBIOS port 139 instead
Unable to connect with SMB1 -- no workgroup availableNetBIOS name resolution failureAdd -I <ip> to bypass name resolution

References

Exit mobile version