SMB Enumeration
What does SMB stands for ?
==> Server Message Block
is a network protocol used to provide shared access to files, printers, and serial ports between nodes on a network.
==> SMB servers can be accessed through various command-line tools such as SMBClient
or through file browsing tools. This service runs on either port 139
or port 445
by default.
SMB Versions ?
==> SMB1
was the first implementation of SMB. It used 16-bit packet
and small data buffers, which greatly limited performance, it did not have any encryption for data in transit whatsoever, which is why it is so insecure. In addition to this, it is highly susceptible to MITM attacks.
==> SMB2
improved performance by increasing packets to 32-bit and 128-bit
for files, furthermore unnecessary data that was transmitted when performing operating via SMB was substantially reduced. Security was improved to prevent MITM attacks through packet signing although still no built-in encryption support.
==> SMB3
added more performance and security enhancements such as multichannel and end-to-end encryption using AES were introduced in, as well as functionality to enforce secure connections with newer clients.
A basic step in enumerating SMB
is to identify the version that the server is running on, as this will help in determining whether any publicly available exploit for that version can be abused to obtain remote code execution (RCE).
If suppose the above method fails, a connection can be started using Nmap or any tool which is capable for connecting to a SMB shares and we can capture the traffic via Wireshark
, which will reveal the hostname of the machine, the SMB version, the operating system version, and other useful information.
The SMB
version identifies by using the auxiliary/scanner/smb/smb_version
Metasploit module.
Searching Publicly Available Exploits ?
If not
found , the alternate plan is to search through the metasploit
framework.
==> Alternatively, if again nothing works don't hesitate to open sites which has related vulnerablity databases such as CVE, NVD and VULDB, Mostly they'll have vuln-related to patches documentation. Only ExploitDB contains the exploit code :)
Null Session Attack ?
A null session
allows users to remotely connect with SMB by using an empty username and empty password.
This usually only allows access to the hidden share called IPC$
( Inter-process communication).
Null sessions
could be used to gather more information about the host and its network, or to access data stored in shares.
Nmap Scripts ?
It is good to run smb-enum*
to collect all general information about the server and smb-vuln*
to collect more information about any known exploits
that might affect the server.
Common Credentials ?
A few common passwords
or usernames
such as admin, administrator, root, test, should be tried if null sessions are disabled on the remote SMB server.
This is safer than bruteforcing
and this is something that should strike us when we pentest any network based service :)
An SMB
authentication can also be performed using the auxilliary/scanner/smb/smb_login
Metasploit module.
Bruteforcing Credentials
=> A Bruteforce attack
consists of an attacker resulting in a number of passwords or usernames so that we attack it with the correct combination, results us by giving access to the machine.
=> Network cracking tools such as hydra
can be used to perform bruteforce attacks against online services such as FTP
, HTTP
, SMB
etc.
=> In some cases, it can be a dictionary attack, that means hydra will use a list of usernames and passwords to perform the attack.
Packet Sniffing
Packet sniffing
is the practice of collecting, and logging all the packets that pass through a computer network.
Because the data transmittion over older versions of SMB (version 1) on port 139,445 is unencrypted
.
An attacker could intercept
traffic on the network and grab all the credentials
being used by the victim during an authentication.
In newer versions of SMB (version 2), traffic could be intercepted to capture the password hash
but we'll still have to crack it using some cracking tools such as john, hashcat etc.
While pentesting a box or an application, we get to see ports 139
and 445
is open. The first thing that should strike us is :
Last updated