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:

  1. 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.

  2. 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.

  3. 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.

  4. Network Browsing: SMB enables network browsing, allowing users to discover available computers, shared folders, and resources on the network.

  5. 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.

  6. Version History: SMB has gone through several versions, including SMB1, SMB2, and SMB3. Each version introduced improvements in terms of security, performance, and functionality.

  7. 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.

  8. 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.

  9. 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:

  1. Shares: Enumerating the shared folders and resources on the target system, which can reveal information about directory structures, file names, and access permissions.

  2. Users and Groups: Extracting information about users and groups present on the system. This information can help identify potential user accounts for further exploitation.

  3. Services: Identifying active services, applications, and processes running on the target system, which could potentially lead to vulnerabilities or weaknesses.

  4. Session Information: Gathering details about active user sessions and connections to the target system.

  5. System Information: Extracting information about the target system's operating system, version, and other configuration details.

  6. Security Policies: Obtaining information about security policies, such as password policies, that could impact the strength of user credentials.

  7. 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 |

systeminfo

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

ifconfig

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.65

  • Enumeration 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.

  • Use the provided user and password to enumerate the same login sessions

📌 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$ (and D$) drive.

📌 Three users are present with some dangerous flags and misconfigurations.

  • Guest user - no password expiration, password not required, normal user account

  • Administrator, bob - no password expiration

  • Enumerate services on the target machine

  • Retrieve useful information from all the shared folders, running the ls command on all of them

SMB: SMBmap

Lab 2

🔬 Windows Recon: SMBMap

  • Target IP: 10.2.21.128

  • Use of smbmap to enumerate samba shares and permissions. Upload, download, delete files

  • SMB port 445 is open, list the SMB protocols

  • Enumerate the target machine with smbmap

  • Login with administrator and enumerate with smbmap

  • Run a command using the smbmap -x option

Remote Code Execution (RCE) can be achieved through SMB!

  • List all drives with -L option

  • List directory contents with -r option

  • Upload a sample file to the C:\ drive

  • Download a file, the flag file in this case

Reveal Flag: 🚩

25f492dbef8453cdca69a173a75790f0

SMB: Recon

Lab 3

🔬 Samba Recon: Basics 1

  • Target IP: 192.28.157.45

  • Linux SMB (smbd) enumeration

  • Target IP is 192.28.157.45

📌 Default smbd TCP used ports are 139, 445. Workgroup name of samba server is RECONLABS.

📌 Default nmbd UDP used ports are 137, 138

📌 Version of samba server is Samba 4.3.11-Ubuntu. NetBIOS computer name is SAMBA-RECON.

  • Use the Metasploit Framework and its msfconsole interface 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

Reveal Flag - The NetBIOS computer name is: 🚩

SAMBA-RECON

Lab 4

🔬 Samba Recon: Basics 2

  • Target IP: 192.230.128.82

  • Linux 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.

Reveal Flag - SID of user “admin” is: 🚩

S-1-5-21-4056189605-2085045094-1961111545-1005

Lab 5

🔬 Samba Recon: Basics 3

  • Target IP: 192.187.39.6

  • Linux 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 public share: secret and dev

Reveal Flag: 🚩

03ddb97933e716f5057a18632badb3b4


SMB: Dictionary Attack

Lab 6

🔬 Samba Recon: Dictionary Attack

  • Target IP: 192.174.58.6

  • Linux 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_login metasploit module to bruteforce jane's password

📌 Jane's password is abc123

🐉Hydra

hydra - tool to guess/crack valid login/password pairs

  • Use hydra tool to find admin user password

📌 admin's password is password1

  • Find smb shares using found credentials

📌 Read-only share is nancy

📌 jane's share is not browsable but it exists.

Reveal Flag: 🚩

2727069bc058053bd561ce372721c92e

  • 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_auditor metasploit 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