> For the complete documentation index, see [llms.txt](https://officerwasu.gitbook.io/officerwasu-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://officerwasu.gitbook.io/officerwasu-docs/untitled/protocols/ntlm.md).

# NTLM

NTLM stands for NT (New Technology) LM (Lan Manager)\
It is a suite of Microsoft security protocols intended to provide authentication, integrity, and confidentiality to users

It is the successor of LANMAN (Lan Manager)

The NTLM suite is implemented in **Security Support Provider Interface**

**Security Support Provider Interface** is a Windows API component which performs Security related tasks\
SSPI has multiple providers.

NTLM passwords are considered weak because they can be brute-forced very easily with modern hardware.

NTLM is a challenge–response authentication protocol which uses three messages to authenticate a client in a connection-oriented environment (connectionless is similar), and a fourth additional message if integrity is desired.

1. First, the client establishes a network path to the server and sends a NEGOTIATE\_MESSAGE advertising its capabilities
2. Next, the server responds with CHALLENGE\_MESSAGE which is used to establish the identity of the client
3. Finally, the client responds to the challenge with an AUTHENTICATE\_MESSAGE

#### **NTLMv1 vs. NTLMv2**

While both versions follow the challenge-response flow, they differ significantly in their cryptographic strength.

**NTLMv1**

NTLMv1 is considered legacy and highly insecure because it uses the weak **DES** (Data Encryption Standard) algorithm.

* **Vulnerability:** In an NTLMv1 environment, an attacker can capture authentication traffic and "replay" it to a server to gain access without ever knowing the password.

Let's imagine a user's password is haha1234 now Windows is gonna create a NT hash by encoding the password with UTF-16LE (This basically means every character gets a null byte added to it) after that the MD4 hashing Algorithm is used and it turns into the NT hash that is always 16 bytes it should look like "ae9c2add475dc93f90b9bac9ecdcda51", now NTLMv1 uses Data Encryption Standard and DES needs a 56bit key so what the developers did was they just added 5 null bytes to the end and made it exactly 21 bytes so they could use 3 DES operations now three keys were created this way from bytes 1-7, 8-14 and lastly 15-21(15, 16 and 5 null bytes) now the server sends a 8byte **nonce** (which is a random number) and that nonce is encrypted with all three keys  and they are sent back to the server as NTLMV1 response.

**NTLMv2**

NTLMv2 was introduced to mitigate these weaknesses by using **HMAC-MD5.**

Now as same as NTLMv1 the secret is still the NT hash but now it also takes a **Identity string** (that is the USERNAME and DOMAIN converted  into uppercase and then concatenated) and turns it into unicode(UTF-16LE) and after that it runs **HMAC-MD5** on the Identity string using the NT hash as the key and NTLMV2 is created now when we try to login the server will send a challenge which is a 8byte random code, now a proof blob is built that includes client nonce(your random code) + Timestamp(current time) + Target Info(Server name) now this proof blob and  the challenge sent by the server is encrypted to HMAC-MD5 using the NTLMv2 hash as the key.

**Mitigation:** NTLMv2 adds a **Client Nonce** and a **Timestamp**. This ensures the response is unique to that specific login attempt and expires quickly, making captured data useless for a simple replay.

#### **Security Considerations**

Despite these versions, NTLM passwords are considered weak because they can be brute-forced easily with modern hardware. Most modern environments are moving toward **Kerberos**, which offers superior security and mutual authentication.

### Sources

[Microsoft NTLM - Win32 apps | Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/secauthn/microsoft-ntlm)

<https://en.wikipedia.org/wiki/NTLM>
