01. SMB Windows Discover & Mount
Introduction¶
Server Message Block (SMB) is a network protocol used for sharing files, printers, and other resources. It is commonly found in Windows environments and is often targeted by attackers. This document covers various commands to enumerate SMB services, users, shares, and security configurations.
Nmap for SMB Enumeration in Windows¶
-
Enumerate SMB Services and OS Information
-
Purpose: Scan the common SMB ports (
139and445), detect service versions, and fingerprint the OS. -
Example Output:
-
-
Check SMB Security and Configuration
-
Purpose: Check whether SMB message signing is enabled (critical for secure communication).
-
Example Output:
-
-
List SMB Shares
-
Purpose: List available SMB shares on the target system.
-
Example Output:
-
-
User Enumeration over SMB
-
Purpose: Enumerate user accounts on the target system via SMB.
-
Example Output:
-
Practical Windows SMB Usage Examples¶
-
Delete All Existing SMB Mappings
- Use Case: Ensure no previous network shares are lingering.
- Map a Network Drive to SMB Share
- Explanation: Maps the network share
SharedFolderto local driveZ:. - Access the Share via Command Line
- Use Case: List the contents of the mapped drive.
- Connect to the Default Admin Share
C$
- Security Note: Only administrators can access admin shares (
C$,D$, etc.). Use strong passwords. - Disconnect a Specific Share
- Use Case: Remove a specific SMB mapping.
SMB Security Best Practices¶
-
Disable SMBv1:
-
SMBv1 is outdated and vulnerable to attacks like WannaCry. Use this command to disable it:
-
-
Enable Message Signing:
-
Ensure message signing is enforced to prevent MITM attacks:
-
-
Restrict SMB Access:
-
Limit access to trusted subnets by configuring firewall rules:
-
-
Use Strong Authentication:
-
Always enforce strong passwords and disable guest access:
-
-
Regular Auditing:
- Monitor SMB access logs in Windows Event Viewer under Security Logs.
Example Workflow: Secure SMB Mapping and Enumeration¶
-
Start with an Nmap Scan:
-
Map the Secure Share:
-
Check the Share Contents:
-
Disconnect the Share: