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

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

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

Clean up:

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:

Listen:

Transfer the SCF file to the writable directory:

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

NTLM Relay

Relay for gaining RCE with a Meterpreter listener:

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 file — C:\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.

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.

  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.

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

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

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

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.

Last updated

Was this helpful?