Ports and connections
smbclient
Talks to an SMB/CIFS file server: lists its shares and reads or writes files, like a mounted network drive.
SMB (Server Message Block, also CIFS) is how Windows file sharing and network drives work, on TCP port
445. A server offers named shares (folders); smbclient lists them and opens one as //server/share,
then runs commands like ls, get and put inside it. Plain SMB is not encrypted, so a capture of a transfer
shows the file's contents in the clear.
smbclient command usage
smbclient -L //SERVER -U USER%PASSWORD smbclient //SERVER/SHARE -U USER%PASSWORD -c COMMAND
Options
-
-L //SERVER - list the shares the server offers
-
-U alice%s3cret - log in as this user with this password
-
-c "get file" - run one command in the share and exit
-
-t 5 - give up on an operation after 5 seconds
smbclient examples
-
smbclient -L //10.0.1.11 -U alice%s3cret - Lists the file server's shares, logged in as alice.
-
smbclient //10.0.1.11/finance -U alice%s3cret -c "ls" - Opens the finance share and lists its files.
-
smbclient //10.0.1.11/finance -U alice%s3cret -c "get q3-report.txt q3-report.txt" - Downloads one file from the finance share.
Reading the output
$ smbclient -L //10.0.1.11 -U alice%s3cret Sharename Type Comment --------- ---- ------- finance Disk dropbox Disk IPC$ IPC IPC Service (fileServer) SMB1 disabled -- no workgroup available
Sharename: the folders the server offers; open one as//server/finance.IPC$is the control channel, not a file share.SMB1 disabledmeans the server speaks only the safer SMB2/3.
Pitfalls
- Plain SMB sends file contents unencrypted: anyone capturing on the LAN can read them.