knowledge

Overview

SMB (Server Message Block) is a client-server protocol for sharing files, directories, printers, and other network resources. Originally Windows-native, it is available on Linux and Unix via Samba, enabling cross-platform file sharing. SMB access rights are defined by Access Control Lists (ACLs) set at the share level, not locally on the server. Null sessions (anonymous access) and weak Samba configurations are common attack vectors during network penetration tests.


Terminology

TermDefinition
SMBServer Message Block — network protocol for resource sharing over TCP
CIFSCommon Internet File System — dialect of SMB aligned with SMBv1; used by Samba
SambaOpen-source SMB/CIFS implementation for Linux/Unix — enables cross-platform file sharing
NetBIOSNetwork Basic Input/Output System — legacy naming/session API used with older SMB (TCP 137–139)
NBNSNetBIOS Name Server — hostname registration service (enhanced version: WINS)
WINSWindows Internet Name Service — Windows-extended version of NBNS
WorkgroupA group name identifying a collection of computers on an SMB network
Null SessionAnonymous SMB connection with no credentials — used to enumerate shares and users
ACLAccess Control List — defines share-level read/write permissions
RPCRemote Procedure Call — mechanism underlying SMB service queries; accessed via rpcclient
RIDRelative Identifier — unique ID for user/group objects within a domain; used in enumeration
DCDomain Controller — manages authentication for Windows domains; keeps user/password in NTDS.dit and SAM

Core Concepts

Protocol Overview

SMB operates over TCP with a three-way handshake before establishing a connection. It uses:

  • TCP 445 — direct SMB over TCP/IP (modern, no NetBIOS needed)
  • TCP 137–139 — SMB over NetBIOS (legacy Samba/older Windows)

The server shares portions of its local file system as shares. ACLs define access per user or group at the share level. A workgroup is a simple peer-to-peer grouping; a domain adds centralized authentication via a Domain Controller.


SMB Versions

VersionOSNotable Change
CIFSWindows NT 4.0Communication via NetBIOS interface
SMB 1.0Windows 2000Direct connection via TCP
SMB 2.0Windows Vista / Server 2008Performance improvements, improved message signing, caching
SMB 2.1Windows 7 / Server 2008 R2Locking mechanisms
SMB 3.0Windows 8 / Server 2012Multichannel connections, end-to-end encryption, remote storage
SMB 3.0.2Windows 8.1 / Server 2012 R2Stability improvements
SMB 3.1.1Windows 10 / Server 2016+Pre-auth integrity checking, AES-128 encryption
  • SMB 3.0+ — Samba can participate as a full Active Directory domain member
  • SMB 4.0+ — Samba can act as an AD domain controller

Samba uses two daemons: smbd (file sharing, resource access) and nmbd (NetBIOS name registration, browsing).


Samba Configuration

Config file: /etc/samba/smb.conf Restart: sudo systemctl restart smbd

Global settings (apply to all shares unless overridden):

SettingExampleDescription
workgroupWORKGROUPName of the Windows workgroup
server string%h server (Samba, Ubuntu)String shown when a connection is initiated
netbios nameubuntuNetBIOS hostname for the server
interfaces127.0.0.0/8 eth0Bind Samba to specific interfaces
bind interfaces onlyyesOnly listen on listed interfaces
log file/var/log/samba/log.%mPer-machine log file
max log size1000Max log size in KB
map to guestbad userMap unknown users to guest account
usershare allow guestsyesAllow guest access to user shares

Share-level settings (defined in [sharename] sections):

SettingExampleDescription
commentHome DirectoriesDescription of the share
path/home/user/sharePath to the shared directory
browseableyesShow share in network browse list
read onlynoAllow write access
guest oknoAllow unauthenticated access
valid users%SRestrict access to specific users
write list@staffUsers/groups with write access
create mask0700Permission mask for new files

Dangerous Settings

SettingRisk
browseable = yesShare is listed in browse list — attackers can enumerate available shares
guest ok = yesUnauthenticated access; null session access to files
read only = noWrite access enabled — can be abused for file placement
map to guest = bad userFailed auth maps to guest — enables anonymous access to shares
smb passwd file stored in writable locationCredential file can be replaced or read

Footprinting SMB

Scan ports 139 and 445 with Nmap (-sV -sC). Nmap alone provides limited info — manual interaction with dedicated tools reveals far more.

List and connect to shares via null session from Linux using smbclient (-N for no password, -L to list shares). Check server status locally (requires access) with smbstatus. Get a quick permissions overview across all shares with smbmap. Perform null session enumeration via NetExec.


RPC Enumeration

Remote Procedure Call (RPC) underlies SMB queries. rpcclient allows manual interaction with SMB servers to extract user, group, and domain information. See rpcclient for full connection syntax and query reference.


enum4linux-ng

Automated SMB/LDAP enumeration tool that wraps rpcclient, nmblookup, net, and smbclient queries. See enum4linux-ng for full usage.

Always use multiple tools — different tools expose different data. Never rely solely on automated enumeration.


  • Service Enumeration

References / Images

  • man smb.conf
  • man samba