Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

smbclient Cheatsheet

SMB/CIFS client for accessing Windows shares from Linux.


Basic Syntax

smbclient [options] //server/share

Connection Options

OptionDescriptionExample
-LList available sharessmbclient -L //10.10.10.10
-NNo password (null session)smbclient -N -L //10.10.10.10
-U USERSpecify usernamesmbclient -U admin //10.10.10.10/share
-W DOMAINSpecify domain/workgroupsmbclient -W MYDOMAIN -U admin //10.10.10.10/share
-p PORTSpecify portsmbclient -p 139 //10.10.10.10/share
-I IPSpecify destination IPsmbclient -I 10.10.10.10 //server/share

Authentication

OptionDescriptionExample
-U user%passUsername and passwordsmbclient -U admin%Password123 //10.10.10.10/share
-A authfileAuth file (user/pass/domain)smbclient -A creds.txt //10.10.10.10/share
--pw-nt-hashUse NT hash instead of passwordsmbclient -U admin --pw-nt-hash //10.10.10.10/share

Common Commands

List Shares (Null Session)

smbclient -N -L //10.10.10.10

Connect to Share

smbclient //10.10.10.10/sharename -U username

Connect with Domain Account

smbclient //10.10.10.10/sharename -U 'DOMAIN\username'

Interactive Commands

Once connected, use these commands:

CommandDescription
lsList files in current directory
cd DIRChange directory
pwdPrint current directory
get FILEDownload file
mget PATTERNDownload multiple files
put FILEUpload file
mput PATTERNUpload multiple files
mkdir DIRCreate directory
rmdir DIRRemove directory
rm FILEDelete file
recurseToggle recursive mode for mget/mput
promptToggle prompting for mget/mput
exitDisconnect

Useful Examples

Download All Files Recursively

smbclient //10.10.10.10/share -U user%pass -c 'recurse; prompt; mget *'

Execute Single Command

smbclient //10.10.10.10/share -U user%pass -c 'ls'

Download Specific File

smbclient //10.10.10.10/share -U user%pass -c 'get secrets.txt'

Upload File

smbclient //10.10.10.10/share -U user%pass -c 'put payload.exe'

Pass-the-Hash Authentication

smbclient //10.10.10.10/share -U admin --pw-nt-hash -W DOMAIN
# Then enter NT hash when prompted

Auth File Format

Create a file with credentials:

username = admin
password = Password123
domain = MYDOMAIN

Use with: smbclient -A authfile //server/share