GO KALI FREE

SMBClient

Information Gathering

Beginnermedium risk

SMBClient is an FTP-like command-line client from the Samba suite for accessing SMB/CIFS file shares on Windows, Samba, and NAS devices. It lets you list shares, browse directories, download and upload files, and test anonymous or authenticated access on remote systems over SMB ports 139 and 445. Use it after Nmap discovers open SMB ports to enumerate shares, test permissions, and transfer files during authorized security assessments.

Installation

sudo apt install smbclient

Basic Syntax

smbclient //<host>/<share> [options]

Quick Facts

Category
SMB Client / File Transfer
Platform
Linux (Samba suite)
Protocol
SMB/CIFS (ports 139/445)
Difficulty
Beginner-Friendly
Common Usage
Share Access & File Transfer
Default Port
445 (SMB), 139 (NetBIOS)
License
GPL v3 (Samba)
Dependencies
Samba client libraries

Tool Overview

SMBClient is an interactive command-line utility included in the Samba suite that provides FTP-like access to SMB/CIFS (Server Message Block/Common Internet File System) resources on Windows, Samba, and other SMB-compatible servers. It enables users to browse shared folders, list directory contents, and transfer files to and from remote systems over the SMB protocol.

The tool operates by establishing SMB sessions to target hosts on ports 139 (NetBIOS Session Service) or 445 (Direct Host SMB), authenticating with optional credentials, and providing an interactive shell where users can execute file operations. SMBClient supports anonymous (null session) access for testing misconfigured shares, authenticated access with username/password combinations, and domain authentication for enterprise Active Directory environments.

For penetration testers and security auditors, SMBClient is essential for verifying share access permissions, testing anonymous login configurations, downloading files for analysis, and assessing SMB security posture. Unlike automated enumeration tools, SMBClient provides hands-on interactive access that allows deep inspection of share contents, permission testing, and file-level operations critical for comprehensive security assessments.

Common Commands

smbclient -L //192.168.1.1 -NList shares anonymously — see all available shares on the target without entering any credentials
smbclient //192.168.1.1/share -U username%passwordConnect to a share with username and password — access a specific shared folder using credentials
smbclient //192.168.1.1/share -NAnonymous connection — connect to a shared folder without a password to test for misconfigured shares
get filenameDownload file (interactive) — retrieve a single file from the share after connecting
put filenameUpload file (interactive) — transfer a local file to the share after connecting
smbclient -L //192.168.1.1 -U domain\user%passwordDomain authenticated listing — list shares using Active Directory domain credentials
smbclient //192.168.1.1/share -c 'ls'Non-interactive directory listing — list share contents from the command line without entering the shell
smbclient //192.168.1.1/share -U user -c 'get remote.txt local.txt'Direct file download — download a specific file without entering the interactive shell
smbclient //192.168.1.1/share -U user -c 'put local.txt remote.txt'Direct file upload — upload a specific file without entering the interactive shell
smbclient //192.168.1.1/share -N -c 'recurse; ls'Recursive directory listing — list all files and subdirectories recursively using the -c flag
smbclient //192.168.1.1/share -N -c 'tarmode archive compress; tar c files.tar *'Recursive tar download — archive the entire share contents into a local tar file for bulk extraction
smbclient -L //192.168.1.1 -N -d 3Debug connection — list shares with debug level 3 to see detailed protocol and connection information
smbclient //192.168.1.1/share -U user -m SMB2Force SMB2 protocol — explicitly connect using the SMB2 protocol instead of auto-negotiating
smbclient //192.168.1.1/share -U user -W WORKGROUPSet workgroup — connect to a share using a specific Windows workgroup or domain name
smbclient //192.168.1.1/share -N -c 'mask *.log; mget *'Bulk download with mask — download all files matching a specific pattern from the share

Step-by-Step Guide

  1. 1Install SMBClient if it is not already present: sudo apt install smbclient. On Kali Linux it ships pre-installed as part of the Samba suite — verify with smbclient --version.
  2. 2Discover the target IP and confirm SMB ports are open. Run Nmap: nmap -p 139,445 <target_ip>. You need at least one port open before proceeding.
  3. 3List available shares without credentials first: smbclient -L //<target_ip> -N. This tests for anonymous access and shows every share the server exposes.
  4. 4Analyze the share listing. Look for Disk shares (file shares), administrative shares (ADMIN$, C$, IPC$), and any shares whose comments reveal their purpose. Ignore Print and IPC shares for file access.
  5. 5Connect to the most interesting share: smbclient //<target_ip>/<share_name> -U <username>%<password>. If you found anonymous access, use -N instead of -U.
  6. 6Browse the share interactively. Use ls to list files, cd to change directories, get to download a file, and put to upload one. Type help to see every available command.
  7. 7For bulk operations, enable recursive mode with recurse on, then use mget * to download everything. Use mask *.ext before mget to filter by file type.
  8. 8Use tar archiving for large shares: tarmode archive; tar c backup.tar *. This creates a compressed archive of the entire share, which is faster than downloading files individually.
  9. 9Test write permissions by uploading a harmless test file: put /tmp/test.txt test_write.txt. If you get NT_STATUS_ACCESS_DENIED the share is read-only.
  10. 10Type exit or quit to close the session cleanly. Document every accessible share, downloaded file, and permission level in your assessment report.

Warnings

Use Cases

Share Access Testing

Verify whether SMB shares are accessible anonymously or with provided credentials, testing for misconfigurations that expose sensitive data to unauthorized users.

File Exfiltration Testing

Download files from accessible shares during penetration tests to demonstrate data exposure risks and assess the sensitivity of information stored on network shares.

Security Audit Verification

After Enum4Linux or NBTScan discovers shares, use SMBClient to manually verify access permissions, test write capabilities, and confirm share-level security controls.

Incident Response File Recovery

Access compromised file shares during incident response to recover deleted files, examine staged attacker data, or verify backup integrity on network storage.

Network Share Enumeration

Interactive exploration of discovered SMB shares to understand their contents, identify sensitive documents, and map the data landscape of Windows networks.

Automated File Operations

Use non-interactive mode (-c flag) to script file downloads, uploads, and directory listings for automated security testing pipelines and batch operations.

Key Features

People Also Ask

What is the difference between SMBClient and SMBMap?

SMBClient is interactive with an FTP-like shell for manual exploration; SMBMap is non-interactive and optimized for automated enumeration and bulk downloads. Use SMBClient for hands-on testing, SMBMap for scripting.

Does SMBClient support SMB3 encryption?

Yes, SMBClient supports SMB2 and SMB3 including encryption. Use '-m SMB3' to force SMB3 protocol negotiation. Encryption protects credentials and data in transit on untrusted networks.

How do I use Pass-the-Hash with SMBClient?

Use '--password=ntlm_hash' instead of a plaintext password: 'smbclient //10.10.10.10/share -U administrator --password=aad3b435b51404ee...'. This authenticates using the NTLM hash directly, useful when you have extracted hashes but not cracked them.

What are common SMBClient error codes?

NT_STATUS_ACCESS_DENIED (wrong perms), NT_STATUS_LOGON_FAILURE (bad creds), NT_STATUS_BAD_NETWORK_NAME (wrong share), connection refused (port blocked/firewall). Debug with '-d 3' to see the full SMB exchange.

Is SMBClient installed on Kali Linux by default?

Yes. SMBClient is part of the Samba suite and comes pre-installed on Kali Linux. Verify with 'smbclient --version'. On other distributions, install via 'sudo apt install smbclient' or 'sudo dnf install samba-client'.

Learning Path

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

Related Tools

Enum4Linux

SMB Enumeration

Comprehensive SMB enumeration tool for extracting users, shares, groups, and policies from Windows systems.

Enum4Linux-NG

SMB Enumeration

Next-generation Python 3 rewrite of Enum4linux with JSON export and improved performance.

NBTScan

NetBIOS Scanner

Fast NetBIOS scanner for discovering Windows hosts and their NetBIOS names, workgroups, and MAC addresses.

Nmap

Network Scanner

Versatile network scanner for port discovery, service detection, and OS fingerprinting across networks.

CrackMapExec

Post-Exploitation

Post-exploitation tool for enumerating and attacking SMB services across large networks efficiently.

Hydra

Password Attacks

Fast network brute-force tool for testing credentials against various services including SMB.

NetExec

Post-Exploitation

Next-generation post-exploitation tool with modern Active Directory enumeration and attack capabilities.

Frequently Asked Questions

What is SMBClient?

SMBClient is a command-line utility from the Samba suite that provides FTP-like access to SMB/CIFS file shares on Windows, Samba, and NAS devices. It allows you to browse directories, download files, upload files, and perform file operations on remote SMB shares using the SMB protocol on ports 139 or 445.

How does SMBClient work?

SMBClient establishes an SMB session to the target host on port 445 (or 139 for NetBIOS), authenticates using optional credentials, and provides an interactive shell where you can execute file operations like ls (list), get (download), put (upload), and tar (archive). It supports anonymous, password, domain, and Kerberos authentication.

How do I use SMBClient?

Basic usage: smbclient -L //<ip> -N to list shares anonymously. smbclient //<ip>/<share> -U user%pass to connect with credentials. Once connected, use ls to list files, get to download, put to upload, and exit to quit. Use -c for non-interactive commands: smbclient //host/share -U user -c 'ls'.

How do I connect to a Windows share?

Connect using: smbclient //<windows_ip>/<share_name> -U <username>%<password>. For domain authentication: smbclient //<ip>/<share> -U CORP\admin%pass. For anonymous access: smbclient //<ip>/<share> -N. First list available shares with smbclient -L //<ip> -N to find share names.

How do I list SMB shares?

List shares anonymously: smbclient -L //<target_ip> -N. List with credentials: smbclient -L //<ip> -U user%pass. The output shows share names, types (Disk, IPC, Print), and comments. Use -d 3 for debug output if the listing fails.

How do I download files from SMBClient?

Download a file: connect to the share, then use 'get filename.txt'. For bulk downloads: 'recurse on; mget *'. For pattern downloads: 'mask *.log; mget *'. Non-interactive download: smbclient //host/share -U user -c 'get remote.txt local.txt'. For archive downloads: 'tarmode archive; tar c backup.tar *'.

How do I upload files with SMBClient?

Upload a file: connect to the share, then use 'put local_file.txt'. For bulk uploads: 'recurse on; mput *.txt'. Non-interactive upload: smbclient //host/share -U user -c 'put local.txt remote.txt'. Ensure you have write permissions on the share — NT_STATUS_ACCESS_DENIED means the share is read-only.

How do I install SMBClient on Ubuntu?

Install SMBClient on Ubuntu/Debian: sudo apt install smbclient. It is pre-installed on Kali Linux. On other distributions: sudo yum install samba-client (RHEL/CentOS), sudo pacman -S samba (Arch), or sudo zypper install samba-client (openSUSE). Verify installation: smbclient --version.

How do I install SMBClient on Kali Linux?

SMBClient is pre-installed on Kali Linux as part of the Samba suite. If missing: sudo apt update && sudo apt install smbclient. Verify with smbclient --version. Kali includes all necessary Samba client libraries for SMB1, SMB2, and SMB3 support.

What port does SMBClient use?

SMBClient uses port 445 (Direct Host SMB) by default for modern Windows systems, and port 139 (NetBIOS Session Service) for older systems and Samba. It also uses port 137 (NetBIOS Name Service) for name resolution. Verify ports with Nmap: nmap -p 137,138,139,445 <target>.

Can SMBClient access SMBv1?

Yes, SMBClient supports SMB1, SMB2, and SMB3 protocols. Use -m SMB1 to force SMB1, -m SMB2 for SMB2, or -m SMB3 for SMB3. SMBClient auto-negotiates the highest mutually supported protocol by default. Note that SMB1 is deprecated and disabled on modern Windows systems due to security vulnerabilities.

What is the difference between SMBClient and SMBMap?

SMBClient provides interactive FTP-like access for exploring shares, while SMBMap offers non-interactive automated output for listing and downloading files. SMBClient is better for manual exploration and troubleshooting; SMBMap is better for scripting and automation. SMBClient supports upload (put); SMBMap has limited upload support. Both are part of the Samba ecosystem.

Can SMBClient work anonymously?

Yes, SMBClient supports anonymous (null session) access using the -N flag: smbclient -L //<target> -N. This tests whether shares allow unauthenticated access — a common security misconfiguration. Not all shares permit anonymous access; modern Windows systems often restrict null sessions. Always test anonymous access first before trying credentials.

How do I troubleshoot SMBClient?

Common fixes: 'connection refused' — verify SMB ports are open with Nmap. 'NT_STATUS_ACCESS_DENIED' — provide valid credentials or try a different share. 'NT_STATUS_LOGON_FAILURE' — check username/password and domain format (domain\user). 'NT_STATUS_BAD_NETWORK_NAME' — verify share name with -L listing. Use -d 3 for debug output to diagnose issues.

Is SMBClient legal to use?

SMBClient is legal when used with explicit written authorization on systems you own or have permission to test. Unauthorized SMB access is illegal under computer fraud laws (CFAA, Computer Misuse Act). Use SMBClient only in lab environments, CTF competitions, or authorized penetration testing engagements. Always obtain written consent before testing.

Can SMBClient connect without authentication?

Yes, use the -N flag for null session (anonymous) access: smbclient -L //192.168.1.1 -N. This tests whether SMB shares allow unauthenticated access. Not all shares permit anonymous connections — modern Windows systems restrict null sessions by default. Always test anonymous access first before attempting credential-based authentication.

Does SMBClient support Kerberos authentication?

Yes, use the -k flag to enable Kerberos authentication: smbclient //dc01/share -k CORP.USER@DOMAIN.COM. Kerberos authentication is required for many Active Directory environments and avoids sending plaintext passwords over the network. Ensure your system has a valid Kerberos ticket (obtain with kinit) before using -k.

What is the difference between SMBClient and smbmap?

SMBClient provides interactive FTP-like access for browsing and transferring files on SMB shares, while smbmap is a non-interactive tool designed for automated share enumeration and file listing across multiple hosts. SMBClient is better for hands-on exploration and file operations; smbmap is better for scripted reconnaissance and quick share mapping.

How do I browse files on an SMB share interactively?

Connect to the share: smbclient //192.168.1.1/share -U user%pass. Once connected, use 'ls' to list files, 'cd' to change directories, 'get' to download, 'put' to upload, and 'exit' to quit. Use 'help' to see all available commands. The interactive shell provides FTP-like commands for full share exploration.

How do I upload files to an SMB share?

Connect to the share with write permissions, then use 'put local_file.txt' to upload a single file. For bulk uploads: 'recurse on; mput *.txt'. Non-interactive upload: smbclient //host/share -U user -c 'put local.txt remote.txt'. If you receive NT_STATUS_ACCESS_DENIED, the share is read-only and you cannot upload.

Can SMBClient download entire shares recursively?

Yes, use tar archiving for bulk downloads: smbclient //host/share -N -c 'tarmode archive; tar c share.tar *'. This creates a tar archive of the entire share contents. For non-archived recursive download, use 'recurse on' then 'mget *'. The tar method is faster for large shares with many files and preserves directory structure.

How do I use SMBClient to list all available shares on a server?

Use the -L flag to list shares: smbclient -L //server -U user%password. This displays all shares including hidden and administrative shares (ADMIN$, C$, IPC$). For null session enumeration: smbclient -L //server -N. Share listings reveal the server's purpose and accessible resources for further exploitation.

Can SMBClient connect to SMBv1 servers?

Yes, SMBClient supports SMBv1, SMBv2, and SMBv3 protocols. By default it negotiates the highest available version. To force SMBv1: smbclient //server/share -U user -m SMB1. SMBv1 is insecure and vulnerable to EternalBlue (MS17-010), but may be required for legacy Windows XP/2003 systems in older environments.

How do I use SMBClient for lateral movement in Active Directory?

After compromising credentials, use SMBClient to access file shares across the domain: smbclient //dc01/SYSVOL -U domain_user%password. SYSVOL contains Group Policy Objects with potential cached credentials. NETLOGON share may contain login scripts. ADMIN$ provides remote access for PsExec-style lateral movement with tools like Impacket's psexec.py.

What is the difference between SMBClient and smbmap?

SMBClient is an interactive FTP-like client for manual share browsing and file operations. smbmap is an automated share enumeration tool that recursively lists files, identifies readable/writable shares, and searches for sensitive files across multiple hosts simultaneously. Use smbmap for initial discovery, SMBClient for targeted file access.

How do I use SMBClient with Pass-the-Hash authentication?

SMBClient supports NTLM hash pass-the-hash: smbclient //server/share -U user --password=HASH. This authenticates using the NTLM hash directly without knowing the plaintext password. Impacket's psexec.py and wmiexec.py provide more reliable Pass-the-Hash execution for remote command execution through SMB.

How do I use SMBClient with a Kerberos ticket?

First obtain a ticket with kinit user@DOMAIN.COM, then connect with the -k flag: smbclient //dc01/share -k DOMAIN.COM. Kerberos authentication avoids sending passwords over the network and is required for many Active Directory environments. Ensure your system clock is synchronized (Kerberos fails if clocks drift more than 5 minutes).

Can SMBClient delete files on a share?

Yes, if you have write and delete permissions. Connect to the share, then use: del filename.txt. You can also remove directories with rmdir folder_name. If you receive NT_STATUS_ACCESS_DENIED, the share or file permissions prevent deletion. Not all shares grant delete rights even if they allow reading.

How do I speed up SMBClient file downloads?

Use tar archiving instead of individual get commands: smbclient //host/share -N -c 'tarmode archive compress; tar c backup.tar *'. The compress option reduces network transfer. For multiple files, enable recurse on then mget *. Avoid downloading one file at a time — batch operations are significantly faster.

What is the difference between SMBClient and rpcclient?

SMBClient provides FTP-like file access to SMB shares, while rpcclient interfaces with Windows RPC services for user enumeration, group discovery, and policy extraction. They serve different purposes: use SMBClient for file operations, rpcclient for information gathering. Both are part of the Samba suite.

How do I find hidden shares on a Windows server?

Administrative shares (ADMIN$, C$, IPC$, and drive letter shares like D$) are hidden by default and do not appear in anonymous listings. Use authenticated listing: smbclient -L //server -U admin%password to see all shares including hidden ones. The IPC$ share is always present and useful for null session testing.

Tags

#smb-client#smb-enumeration#file-sharing#samba#file-transfer#windows-networking#share-access#network-enumeration#reconnaissance#linux-tool#smb-cifs#null-session

Output Explanation

The list command (-L) outputs a table with three columns: Sharename (the UNC name you connect to), Type (Disk for file shares, IPC for named pipes, Print for printers), and Comment (an optional description set by the administrator). An anonymous listing may show fewer shares than an authenticated one because Windows restricts null session visibility by default. Once connected, the smb: \> prompt indicates an active session. Directory listings (ls) show filenames, sizes in bytes, timestamps, and DOS attributes (A = Archive, D = Directory, R = Read-only, H = Hidden, S = System). Error messages include NT_STATUS_ACCESS_DENIED (share exists but you lack permission), NT_STATUS_LOGON_FAILURE (bad username or password), NT_STATUS_BAD_NETWORK_NAME (share name does not exist), and connection refused (SMB service is down or blocked). Use the -d flag (e.g., -d 3) for verbose debug output that reveals protocol negotiation details, authentication exchanges, and connection state.

Ethical Usage Notice

This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.