04. SMB Samba Part 1
1. Detecting SMB and NetBIOS Services¶
Command:¶
Explanation:¶
- Scans ports 139 (NetBIOS) and 445 (SMB) to detect services running on them.
-sVenables version detection.
Example Output:¶
PORT STATE SERVICE VERSION
139/tcp open netbios-ssn Samba smbd 3.X
445/tcp open microsoft-ds Windows Server 2019
Real-World Use Case:¶
- Helps determine if SMB services are active and their versions for vulnerability assessment.
2. Scanning Top 25 UDP Ports¶
Command:¶
Explanation:¶
- Scans the top 25 commonly used UDP ports.
--opendisplays only open ports.
Real-World Use Case:¶
- Identifies critical UDP services running on the target.
3. UDP Service Version Detection¶
Command:¶
Explanation:¶
- Identifies versions of services running on the top 25 open UDP ports.
Real-World Use Case:¶
- Determines if outdated or vulnerable services are active.
4. Discovering SMB Operating System Details¶
Command:¶
Explanation:¶
- Identifies the operating system version and build number through SMB.
Example Output:¶
Real-World Use Case:¶
- Helps penetration testers determine the OS version for targeted exploits.
5. SMB Version Scanning Using Metasploit¶
Commands:¶
Explanation:¶
- Launches Metasploit and scans SMB services for version detection.
Real-World Use Case:¶
- Determines if the target is vulnerable to SMB-based exploits like EternalBlue.
6. NetBIOS Name Lookup Using NMBLookup¶
Command:¶
Explanation:¶
- Queries NetBIOS names of the target system.
Example Output:¶
Real-World Use Case:¶
- Identifies NetBIOS names for reconnaissance.
7. Listing SMB Shares Using SMBClient¶
Command:¶
Explanation:¶
- Lists available SMB shares without authentication.
-Nprevents password prompt.
Example Output:¶
Real-World Use Case:¶
- Identifies accessible SMB shares that might contain sensitive data.
Note: Anonymous SMB Access Behavior
Sometimes, Anonymous (null session) login is allowed on the target system, but enumeration and other actions are restricted and result in access denied.
8. Enumerating RPC Services Using RPCClient¶
Command:¶
Explanation:¶
- Connects to the target's RPC service anonymously.
-U ""specifies an empty username.-Navoids a password prompt.
Real-World Use Case:¶
- Helps identify exposed RPC services that may be exploited.
Summary¶
These Nmap, Metasploit, and SMB-related commands provide valuable insights into SMB security, misconfigurations, and potential attack vectors. Properly securing SMB services can help prevent unauthorized access, data leaks, and network intrusions.
Mitigation Strategies:¶
- Disable SMBv1 – Prevents exploitation via known vulnerabilities.
- Restrict Anonymous Access – Ensures only authenticated users can access SMB shares.
- Use Strong Credentials – Protects against brute-force attacks.
- Enable SMB Signing and Encryption – Prevents Man-in-the-Middle (MITM) attacks.
- Monitor SMB Logs – Detects suspicious activity in real time.
By applying these security measures, organizations can strengthen their SMB configurations and minimize risks.