SMB (137,138,139,445)

OS Discovery using smb

nmap --script smb-os-discovery.nse -p445 10.10.10.40

Enumerate Hostnames

nmblookup -A $ip

List Shares

smbmap -H $ip
smbmap -H $ip -u alex -p lol123\!mD
smbclient -N -L \\\\$ip
nmap --script smb-enum-shares -p 139,445 $ip

Null Sessions

Using smbmap

smbmap -H $ip

Using rcpclient (port 139(?))

rpcclient -U "" -N $ip

Using smbclient

smbclient \\\\$ip\$sharename
smbclient \\\\$ip\$sharename -U username%password #authenticated

Using crackmapexec

Vuln Checking or use -sC for default scripts

Scanning

Without username/password

With username/password

Misconfigurations

Anonymous Authentication

Null session (refer above). Can use smbmap, smbclient, enum4linux, and rpcclient

Listing File Shares

Downloading and Uploading Files

RPC Client (enumerate users)


Protocol Specific Attacks

Password Bruteforce and Spray Attacks

--continue-on-success to continue even after successful attempt

--local-auth if targeting a non domain joined computer

Remote Code Execution

Impacket PsExec, SMBSexec, and atexec

CrackMapExec

-x for commands and -X for powershell commands

uses --exec-method atexec by default

Extract Hashes from SAM database

Enumerating Logged on Users

Pass the Hash

Forced Authentication Attacks (Responder)

Setup a fake SMB server to capture the NetNTLM v1/v2 hash

When a user or a system tries to perform a Name Resolution (NR), a series of procedures are conducted by a machine to retrieve a host's IP address by its hostname.

  • The hostname file share's IP address is required.

  • The local host file (C:\Windows\System32\Drivers\etc\hosts) will be checked for suitable records.

  • If no records are found, the machine switches to the local DNS cache, which keeps track of recently resolved names.

  • Is there no local DNS record? A query will be sent to the DNS server that has been configured.

  • If all else fails, the machine will issue a multicast query, requesting the IP address of the file share from other machines on the network.

Cracking the NTLM Hash

If can't crack the password, relay it impacket-ntlmrelayxarrow-up-right or MultiRelay.pyarrow-up-right

use -c to pass commands like a powershell reverse shell from https://www.revshells.com/arrow-up-right

For RPC

  • Change a user's password.

  • Create a new domain user.

  • Create a new shared folder.

Last updated