πŸ₯ΈPort 138-139-445 (SMB/netbios)

Version if nmap didn’t detect it

Sometimes nmap doesn’t show the version of Samba in the remote host, if this happens, a good way to know which version the remote host is running, is to capture traffic with wireshark against the remote host on 445/139 and in parallel run an smbclient -L, do a follow tcp stream and with this we might see which version the server is running.

OR

sudo ngrep -i -d <INTERFACE> 's.?a.?m.?b.?a.*[[:digit:]]' port 139
smbclient -L <IP>

Scan for vulnerability

nmap -p139,445 --script "smb-vuln-* and not(smb-vuln-regsvc-dos)" --script-args smb-vuln-cve-2017-7494.check-version,unsafe=1 <IP>

If :

Manual testing

smbmap -H <IP>
smbmap -u '' -p '' -H <IP>
smbmap -u 'guest' -p '' -H <IP>
smbmap -u '' -p '' -H <IP> -R

crackmapexec smb <IP>
crackmapexec smb <IP> -u '' -p ''
crackmapexec smb <IP> -u 'guest' -p ''
crackmapexec smb <IP> -u '' -p '' --shares

enum4linux -a <IP>

smbclient --no-pass -L //$IP
smbclient //<IP>/<SHARE>

# Download all files from a directory recursively
smbclient //<IP>/<SHARE> -U <USER> -c "prompt OFF;recurse ON;mget *"

Brute force

Mount a SMB share

Get a shell

EternalBlue (MS17-010)

Check if vulnerable

Prepare shellcodes and listeners

Exploit

If this doesn’t work, try this one

MS08-067

CVE-2017-7494

Create a new file named poc.c :

If you reiceve 3 pings on your listener then the exploit works. Now let’s get a shell :

nmap

nbtscan

enum4linux

smbmap

  • with credentials

  • enumerating

smbclient

mount

rpcclient

Mount shares

mount shares 2

nmblookup

nmblookup is used to query NetBIOS names and map them to IP addresses in a network using NetBIOS over TCP/IP queries

accesschk

shell when we have the credentials

shell 2 when i have credentials

If SMB is up locally but the port is closed externally, then try a remote port forward back to your attacking machine:

Last updated