smbclient for Pentesters: Accessing and Enumerating SMB Shares

Category: Pentesting Tools & Techniques
Tool Focus: SMB Enumeration, Looting, Anonymous Access

smbclient is a Linux command-line utility from the Samba suite that lets you interact with SMB (Server Message Block) services — similar to FTP.

It allows you to:

  • List available shares on a target
  • Connect to specific shares
  • Download or upload files
  • Test for anonymous access

Use smbclient early in your internal or AD pentest when:

  • You’ve found TCP port 445 or 139 open
  • You’re checking for anonymous or weak SMB access
  • You want to loot files, scripts, backups, or config dumps
  • You’re following up on Nmap/CrackMapExec results

It’s an essential post-scan tool for initial access, enumeration, and credential hunting.

If you’re on Kali or Parrot, it’s pre-installed. Otherwise:

sudo apt install smbclient -y
smbclient -L //<target-ip> -N
# -L = list shares
# -N = no password (anonymous)

Example:

smbclient -L //192.168.56.101 -N

If anonymous access is allowed, this will show all available shares.

smbclient -L //<target-ip> -U <username>

It will prompt for a password.

Example:

smbclient -L //192.168.56.101 -U administrator
smbclient //<target-ip>/<sharename> -N

Example:

smbclient //192.168.56.101/anonymous -N

This opens an interactive shell like FTP:

smb: \> ls

Once inside a share:

get <filename>     # Download a file

Example:

smb: \> get secrets.txt
put <filename>     # Upload a file

Useful for dropping webshells or tools in writable shares.

ls                  # List contents
cd <folder>         # Change directory
pwd                 # Print working directory
exit                # Quit

You Nmap a target and see port 445 is open. You try:

smbclient -L //192.168.56.101 -N

It lists:

Sharename       Type      Comment
---------       ----      -------
ADMIN$          Disk      Remote Admin
C$              Disk      Default share
public          Disk      Shared folder

You connect:

smbclient //192.168.56.101/public -N

You find backup.zip, download it:

get backup.zip

You crack the zip password, find a .pfx file with credentials. You now have initial access or a pivot to escalation.

  • Always check anonymous access first.
  • Look for writable shares like public, netlogon, or SYSVOL.
  • Use enum4linux, smbmap, and crackmapexec to complement smbclient.
  • Target shares like SYSVOL and NETLOGON for potential GPP files, scripts, or stored credentials.

Scroll to Top