SMB
SMB Security & Exploitation Guide
Server Message Block (SMB) is a client server protocol that provides shared access to:
It enables communication between nodes in the same network, granting access to resources based on authentication and permissions.
Default Ports:
NetBIOS over TCP: 137, 138, 139
CrackMapExec (CME)
A powerful tool for SMB enumeration and exploitation.
Pass-the-Hash or Command Execution:
crackmapexec smb 192.0.2.10 -u Administrator -d . -H <NTLM_HASH> -x whoami
Null-session login and share enumeration:
crackmapexec smb 203.0.113.5 -u '' -p '' --shares
Userlist checking:
crackmapexec smb 198.51.100.20 -u users.txt -p '' -d . --continue-on-success
User=Password spray attack:
crackmapexec smb 198.51.100.20 -u users.txt -d . --no-bruteforce --continue-on-success
An open-source implementation of SMB/CIFS on Unix-based systems.
Configuration file: /etc/samba/smb.conf
Check active connections:
Inspect config (excluding comments):
A command-line tool to interact with SMB shares.
List available shares (null session):
Useful commands:
help → show available commands
get <file> → download a file
!<cmd> → run local system command
Automation tool for SMB enumeration and file operations.
Impacket provides Python scripts for SMB interaction and exploitation.
Remote code execution:
(Same applies for smbexec and atexec.)
RPC (Remote Procedure Call) allows process-to-process communication across systems.
RID Brute Force (users/groups enumeration):
Alternative: use samrdump.py, enum4linux, or enum4linux-ng:
Windows Net Command
3. Dangerous SMB Configuration Settings
browseable = yes → Shares are visible in network browsing.
read only = no → Users can create and modify files.
writable = yes → Full write permissions allowed.
guest ok = yes → Anonymous logins permitted.
enable privileges = yes → Honors user privileges (may be abused).
create mask = 0777 → New files created with world read/write permissions.
directory mask = 0777 → New directories created with world read/write permissions.
logon script = script.sh → Executes script at user login.
magic script = script.sh / magic output = script.out → Dangerous auto-execution functionality.
4. Creating a Share (Windows 10 Example)
Use Advanced Sharing to share the folder.
Configure both SMB share permissions and NTFS permissions.
SMB permissions control network access.
NTFS permissions control file system access.
Inherited permissions are marked grey (from parent directory).
5. Mounting SMB Shares (Linux)
Last updated