AdSense

Sunday, October 15, 2017

SMB enumeration with NSE, nbtscan and enum4linux


SMB ENUMERATION WITH NSE, NBTSCAN AND ENUM4LINUX

- Layout for this exercise:





1 - Introduction

- Server Message Block (SMB), one version of which was also known as Common Internet File System (CIFS), operates as an application-layer network protocol mainly used for providing shared access to files, printers, and serial ports and miscellaneous communications between nodes on a network. 

- SMB also provides an authenticated inter-process communication mechanism. 

- Most usage of SMB involves computers running Microsoft Windows.

- SMB can run on top of the session network layers in two ways:

i) directly over TCP port 445
ii) via the NetBIOS API on TCP ports 137, 139.

- SMB works through a client-server approach, where a client makes specific requests and the server responds accordingly. 

- One section of the SMB protocol specifically deals with access to filesystems, such that clients may make requests to a file server; but some other sections of the SMB protocol specialize in inter-process communication (IPC). 

- The Inter-Process Communication (IPC) share, or ipc$, is a network share on computers running Microsoft Windows. 

- This virtual share is used to facilitate communication between processes and computers over SMB, often to exchange data between computers that have been authenticated.

https://en.wikipedia.org/wiki/Server_Message_Block

- NetBIOS is commonly known as the Windows "Network Neighborhood" protocol, and it provides a nameservice that listens on TCP port 139 and UDP port 137. 

- When it receives a query on this port, NetBIOS responds with a list of all services it offers.

- Port 139 was more popular with older machines and NetBIOS running under the SMB protocol for file sharing / printers etc..

- Nowadays we're more likely to see microsoft-ds running on port 445 in conjunction with port 139 and the netbios-ssn service.

- nbtscan is a program for scanning IP networks for NetBIOS name information. 

- nbtscan sends NetBIOS status query to each address in supplied range and lists received information in human readable form. 

- For each responded host nbtscab lists IP address, NetBIOS computer name, logged-in user name and MAC address such as Ethernet.


2 - Scanning the subnet for open SMB ports and the NetBIOS service

- As said before, the SMB runs on ports 139 and 445.

- Discovering hosts of the subnet where SMB is running can be performed with Nmap:




- nbtscan is a program for scanning IP networks for NetBIOS name information. 

- nbtscan sends NetBIOS status query to each address in supplied range and lists received information in human readable form.

- For each responded host nbtscab lists IP address, NetBIOS computer name, logged-in user name and MAC address such as Ethernet:





3 - NSE (Nmap Scripting Engine) for SMB enumeration

- There is a number of NSE (Nmap Scripting Engine) scripts that can be used for SMB enumeration purposes:




- Let's try some of them.

- smb-os-discovery tries to connect to the SMB service of a target in order to discover its operating system version:




- smb-vuln scripts try to discover specific vulnerabilities at the target. For instance, the script smb-vuln-ms08-67 refers to the CVE-2008-4250 vulnerability reported here:

https://nvd.nist.gov/vuln/detail/CVE-2008-4250





- smb-enum-users enumerates users at the target:





4 - enum4linux

- enum4linux is a wrapper written in Perl around tools like smbclient, rpcclient, net and nmblookup.

- The purpose of enum4linux is to enumerate information from Windows and Samba systems. 

- Let's run enum4linux over a Windows system: