Skip to main content
NTLM (NT LAN Manager) is a suite of Microsoft security protocols that provides authentication, integrity, and confidentiality to users. Impacket provides comprehensive support for NTLM authentication in both client and server scenarios.

NTLM Overview

NTLM authentication uses a challenge-response mechanism:
  1. Client requests authentication
  2. Server sends an 8-byte random challenge
  3. Client encrypts the challenge with the user’s password hash
  4. Server verifies the response

Computing NTLM Hashes

NT Hash Computation

The NT hash (also called NTLM hash) is an MD4 hash of the user’s password in UTF-16LE encoding:

LM Hash Computation

LM hashes are cryptographically weak and should not be used. They’re included only for legacy compatibility.

NTLMv1 vs NTLMv2

NTLMv1 (Legacy)

NTLMv1 is the original NTLM protocol. It’s vulnerable to various attacks:
NTLMv2 provides enhanced security with stronger cryptography:

NTLM Message Exchange

Type 1: Negotiate Message

Client initiates authentication:

Type 2: Challenge Message

Server responds with challenge:

Type 3: Authenticate Message

Client proves identity:

Pass-the-Hash with NTLM

Authenticate using only the NT hash (no plaintext password needed):

NTLM Relay Protection

When implementing NTLM authentication, be aware of relay attacks:

NTLM Flags and Options

Common NTLM negotiation flags:

Working with NTLM Session Keys

Session keys provide message integrity and confidentiality:

Practical Examples

Example 1: SMB Authentication with Hashes

Example 2: Extract NT Hash from User Input

Security Best Practices

NTLM Security Considerations:
  1. Prefer Kerberos: Use Kerberos authentication when possible, especially in Active Directory environments
  2. Use NTLMv2: Never downgrade to NTLMv1 unless absolutely necessary
  3. Enable Signing: Always request message signing to prevent relay attacks
  4. Channel Binding: Use Extended Protection for Authentication (EPA) when available
  5. Monitor Usage: Log and monitor NTLM authentication attempts
NTLM is considered a legacy protocol. Microsoft recommends disabling NTLM and using Kerberos for all modern Windows environments. However, NTLM remains useful for:
  • Workgroup (non-domain) environments
  • Legacy application compatibility
  • Security testing and research
  • Situations where Kerberos is unavailable

See Also

Pass-the-Hash

Learn techniques for reusing NTLM hashes

Kerberos Auth

Upgrade to Kerberos for better security