SMB Enum
What is SMB?
SMB stands for Server Message Block, and it's a network protocol used for sharing files, printers, and other resources between computers on a network. It enables devices to communicate and collaborate by providing a way to access shared folders, files, and other resources on remote systems. SMB is primarily used in Windows environments, but it's also supported by various other operating systems.
Here are some key features and uses of the SMB protocol:
File and Printer Sharing: SMB allows computers to share files and printers over a network. Users can access remote files as if they were on their local machine and send print jobs to remote printers.
Access Control: SMB supports access control and authentication mechanisms, allowing administrators to set permissions for who can access shared resources and what level of access they have.
Named Pipes and Interprocess Communication: SMB provides named pipes for interprocess communication between programs running on different computers. This facilitates communication and data exchange between applications.
Network Browsing: SMB enables network browsing, allowing users to discover available computers, shared folders, and resources on the network.
Remote Procedure Calls (RPCs): SMB can be used for remote procedure calls, which enable a program to execute code on a remote server as if it were local.
Version History: SMB has gone through several versions, including SMB1, SMB2, and SMB3. Each version introduced improvements in terms of security, performance, and functionality.
Encryption and Security: Recent versions of SMB (SMB3) incorporate advanced security features such as encryption, signing, and improved authentication mechanisms to enhance the protection of data in transit.
Cross-Platform Support: While SMB is closely associated with Windows, it is supported on various platforms through different implementations. For example, Samba is an open-source implementation of the SMB/CIFS protocol that allows Unix-like systems to share resources with Windows systems.
CIFS: Common Internet File System (CIFS) is a more advanced version of SMB that provides additional features and better compatibility with modern network environments.
SMB Enumeration
SMB enumeration refers to the process of extracting information and details from a target system that is running the Server Message Block (SMB) protocol. SMB is a network file sharing protocol that enables applications and systems to communicate and share resources such as files, printers, and other devices across a network. SMB is commonly used in Windows environments for sharing files and resources.
During SMB enumeration, a penetration tester or security analyst attempts to retrieve valuable information from the target system by querying the SMB services. This process involves querying various aspects of the system, including:
Shares: Enumerating the shared folders and resources on the target system, which can reveal information about directory structures, file names, and access permissions.
Users and Groups: Extracting information about users and groups present on the system. This information can help identify potential user accounts for further exploitation.
Services: Identifying active services, applications, and processes running on the target system, which could potentially lead to vulnerabilities or weaknesses.
Session Information: Gathering details about active user sessions and connections to the target system.
System Information: Extracting information about the target system's operating system, version, and other configuration details.
Security Policies: Obtaining information about security policies, such as password policies, that could impact the strength of user credentials.
Error Messages: Analyzing error messages or responses from the SMB service, which might provide insights into potential misconfigurations or vulnerabilities.
SMB Ports
TCP Port 445 - Microsoft-DS (Microsoft Directory Services): This is the main port used for SMB traffic on modern networks. It is commonly used for file and printer sharing, as well as other SMB-related operations.
UDP Port 137 - NetBIOS Name Service: This port is used for the NetBIOS Name Resolution service. NetBIOS (Network Basic Input/Output System) is a service that allows computers to communicate within a local network. This port is involved in resolving NetBIOS names to IP addresses.
UDP Port 138 - NetBIOS Datagram Service: This port is used for the NetBIOS Datagram Service. It is involved in the communication of datagrams between devices on the network.
TCP Port 139 - NetBIOS Session Service: In the past, this port was widely used for SMB traffic, but it has become less common in modern networks. It was used for file access operations and resource sharing.
SMB: Windows Discover & Mount
Task List
Windows machine (Server 2012) is provided to you.
Learn to use Nmap to scan the target machine and mount the SMB share of the target machine using the Windows File Explorer as well as using the command prompt.
Objective: Discover SMB share and mount it
The following username and password may be used to access the service:
| Username | Password | | administrator | smbserver_771 |

This is IP address of the machine with hostname "ATTACKER":

Run Nmap scan against the subnet to discover the target machine’s IP address.
The target subnet is “255.255.240.0” hence we have mentioned CIDR to 20.


We see that hosts with IP: 10.2.22.92 and 10.2.25.111 have SMB open ports (139, 445).
We have the credentials to access the target server, we can use GUI mode or terminal.
to delete sharing files we use this command:

SMB: Nmap Scripts
Numerous iterations of the SMB protocol exist, including SMBv1, CIFS, SMBv2, SMBv2.1, SMBv3, and others.
For instance, Windows employs SMB for mapping and sharing drives as letters.
Typically, SMB is detectable on ports 139 or 445; additional details about the operating system version can be unveiled through nmap service and script enumeration (-sV, -sC).
Once SMB is identified during port scanning, employ nmap to amass further insights.
Lab 1
🔬 Windows Recon: SMB Nmap Scripts
Target IP:
10.2.27.65Enumeration of SMB protocol dialects, security level information, active sessions, Windows users and shares, domains, services.
With SMB port 445 open, you can utilize a specialized nmap script to compile a list of the supported protocols and dialects by the SMB server.

Find SMB security level with another nmap script
Enumerate SMB logged in users
Use the provided user and password to enumerate the same login sessions
Enumerate SMB shares with a guest user
📌
IPC$(null session connection) - with this session, Windows lets guest anonymous users enumerate the names of domain accounts and network shares.
Enumerate SMB shares with an authenticated user (administrator account)
📌 The authenticated user, the administrator in this case, has Read & Write privileges to the entire
C$(andD$) drive.
Enumerate Windows users
📌 Three users are present with some dangerous flags and misconfigurations.
Guestuser - no password expiration, password not required, normal user account
Administrator,bob- no password expiration
Get some server statistics
Enumerate system domains and policies
Enumerate available groups
Enumerate services on the target machine
Retrieve useful information from all the shared folders, running the
lscommand on all of them
SMB: SMBmap
Lab 2
Target IP:
10.2.21.128Use of
smbmapto enumerate samba shares and permissions. Upload, download, delete files
SMB port
445is open, list the SMB protocols
Enumerate the target machine with
smbmap
Login with administrator and enumerate with
smbmap

Run a command using the smbmap
-xoption
❗ Remote Code Execution (
RCE) can be achieved through SMB!
List all drives with
-Loption
List directory contents with
-roption
Upload a sample file to the
C:\drive
Download a file, the flag file in this case
SMB: Recon
Lab 3
Target IP:
192.28.157.45Linux SMB (
smbd) enumeration
Target IP is
192.28.157.45
📌 Default
smbdTCP used ports are139,445. Workgroup name of samba server isRECONLABS.
📌 Default
nmbdUDP used ports are137,138
📌 Version of samba server is
Samba 4.3.11-Ubuntu. NetBIOS computer name isSAMBA-RECON.
Use the
Metasploit Frameworkand itsmsfconsoleinterface tool to enumerate samba version.
nmblookup
nmblookup- NetBIOS over TCP/IP client used to lookup NetBIOS names
smbclient- ftp-like client to access SMB/CIFS resources on servers
rpcclient- tool for executing client side MS-RPC functions
Lab 4
Target IP:
192.230.128.82Linux SMB enumeration
Target IP is
192.230.128.82
📌 OS Version of samba server is
6.1.
enum4linux- tool for enumerating data from Windows and Samba hosts
Find samba server description
📌 Samba server description is
samba.recon.lab
📌 NTLM 0.12 (SMBv1) dialects supported
📌 SMB2 is supported and has been online for 3700245 hours
List all Samba server users with various techniques/tools
📌 Users are:
john,elie,aisha,shawn,emma,admin
Find SID of user “admin” using rpcclient.
Lab 5
Target IP:
192.187.39.6Linux SMB detailed enumeration
Target IP is
192.230.128.6
List all Samba server shares with various techniques/tools
📌 Available shares on the samba server are
IPC$,aisha,emma,everyone,john,public.
Find domain groups on the samba server
📌 Available domain groups are
Maintainer,Reserved
Check if samba server is configured for printing
📌 No printers returned.
📌 There are 2 directories present inside
publicshare:secretanddev
SMB: Dictionary Attack
Lab 6
🔬 Samba Recon: Dictionary Attack
Target IP:
192.174.58.6Linux SMB detailed enumeration using
word lists
Word lists are lists of already known and used passwords, some of them leaked from breached websites or other services. Those passwords can be used as part of the attack via brute force tools.
In Kali Linux wordlists can be found inside /usr/share/wordlists directory.
Target IP is
192.174.58.6
Use
smb_loginmetasploit module to bruteforce jane's password
📌 Jane's password is
abc123
🐉Hydra
hydra- tool to guess/crack valid login/password pairs
Use
hydratool to find admin user password
📌 admin's password is
password1
Find
smb sharesusing found credentials
📌 Read-only share is
nancy
📌 jane's share is not browsable but it exists.
A named pipe is a logical connection between a client and server involved in a SMB connection, similar to an open TCP port.
Use
pipe_auditormetasploit module to enumerate the named pipes
📌 Named pipes available over SMB are
netlogon,lsarpc,samr,eventlog,InitShutdown,ntsvcs,srvsvc,wkssvc
List users' SID by performing RID cycling.
📌 shawn SID is
S-1-22-1-1000📌 jane SID is
S-1-22-1-1001📌 nancy SID is
S-1-22-1-1002📌 admin SID is
S-1-22-1-1003
Last updated