githubEdit

🔬SMB Enum

SMB (Server Message Block) - a network file and resource sharing protocol, based on a client-server model.

There are many variants of the SMB protocol like SMBv1, CIFS, SMBv2, SMBv2.1, SMBv3, and so on.

  • e.g. Windows mapping and sharing drives as letter, uses SMB

Usually SMB can be found on ports 139 or 445 and nmap service and scripts enumeration (-sV, -sC) can find more info about the O.S. version.

After finding SMB through port scanning, gather more information with nmap.

sudo nmap -p445 -sV -sC -O <TARGET_IP>

Lab 1

🔬 Windows Recon: SMB Nmap Scriptsarrow-up-right

  • Target IP: 10.2.24.25

  • Enumeration of SMB protocol dialects, security level information, active sessions, Windows users and shares, domains, services.

ping 10.2.24.25
nmap 10.2.24.25

    PORT      STATE SERVICE
    135/tcp   open  msrpc
    139/tcp   open  netbios-ssn
    445/tcp   open  microsoft-ds
    3389/tcp  open  ms-wbt-server
    49152/tcp open  unknown
    49153/tcp open  unknown
    49154/tcp open  unknown
    49155/tcp open  unknown
    49167/tcp open  unknown
smb-protocols
smb-security-mode
smb-enum-sessions
  • Use the provided user and password to enumerate the same login sessions

smb-enum-sessions with credentials

📌 IPC$ (null session connectionarrow-up-right) - with this session, Windows lets guest anonymous users enumerate the names of domain accounts and network shares.

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

smb-enum-shares with credentials

📌 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

smb-enum-users
smb-server-stats
smb-enum-domains
smb-enum-groups
smb-enum-services
smb-ls

Lab 2

🔬 Windows Recon: SMBMaparrow-up-right

  • Target IP: 10.2.21.233

  • Use of smbmaparrow-up-right 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

smbmap
  • Login with administrator and enumerate with smbmap

smbmap with credentials
  • Run a command using the smbmap -x option

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

smbmap -x 'command'
  • List all drives with -L option

smbmap -L
  • List directory contents with -r option

smbmap -r 'Drive$'
  • Upload a sample file to the C:\ drive

smbmap upload
smbmap file uploaded
  • Download a file, the flag file in this case

smbmap download
chevron-rightReveal Flag: 🚩hashtag

25f492dbef8453cdca69a173a75790f0

Lab 3

🔬 Samba Recon: Basics 1arrow-up-right

  • Target IP: 192.28.157.3

  • Linux SMB (smbd) enumeration

  • Target IP is 192.28.157.3

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

msfconsole
msfconsole smb_version exploit

nmblookup

nmblookup - NetBIOS over TCP/IP client used to lookup NetBIOS names

smbclient - ftp-like client to access SMB/CIFS resources on servers

smbclient

rpcclient - tool for executing client side MS-RPC functions

rpcclient
chevron-rightReveal Flag - The NetBIOS computer name is: 🚩hashtag

SAMBA-RECON

Lab 4

🔬 Samba Recon: Basics 2arrow-up-right

  • Target IP: 192.230.128.3

  • Linux SMB enumeration

  • Target IP is 192.230.128.3

📌 OS Version of samba server is 6.1.

enum4linux - tool for enumerating data from Windows and Samba hosts

enum4linux -o
  • Find samba server description

📌 Samba server description is samba.recon.lab

📌 NTLM 0.12 (SMBv1) dialects supported

📌 SMB2arrow-up-right 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.

chevron-rightReveal Flag - SID of user “admin” is: 🚩hashtag

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

Lab 5

🔬 Samba Recon: Basics 3arrow-up-right

  • Target IP: 192.187.39.3

  • Linux SMB detailed enumeration

  • Target IP is 192.230.128.3

  • List all Samba server shares with various techniques/tools

📌 Available shares on the samba server are IPC$, aisha, emma, everyone, john, public.

Metasploit - smb_enumshares
enum4linux -S
  • Find domain groups on the samba server

📌 Available domain groups are Maintainer, Reserved

  • Check if samba server is configured for printing

📌 No printers returned.

smbclient connection to "public" share

📌 There are 2 directories present inside public share: secret and dev

smb help
chevron-rightReveal Flag: 🚩hashtag

03ddb97933e716f5057a18632badb3b4


Lab 6

🔬 Samba Recon: Dictionary Attackarrow-up-right

  • Target IP: 192.174.58.3

  • 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 wordlistsarrow-up-right can be found inside /usr/share/wordlists directory.

  • Target IP is 192.174.58.3

Metasploit - smb_login

📌 Jane's password is abc123

hydraarrow-up-right - tool to guess/crack valid login/password pairs

  • Use hydra tool to find admin user password

hydra

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

chevron-rightReveal Flag: 🚩hashtag

2727069bc058053bd561ce372721c92e

Metasploit - pipe_auditor

📌 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