Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions scapy/layers/ntlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2150,6 +2150,13 @@ def _getSessionBaseKey(self, Context, auth_tok):
domain,
HashNt=self.IDENTITIES[username],
)
NTProofStr = auth_tok.NtChallengeResponse.computeNTProofStr(
ResponseKeyNT,
Context.chall_tok.ServerChallenge,
)
if NTProofStr != auth_tok.NtChallengeResponse.NTProofStr:
log_runtime.debug("NTLMSSP: Bad NTProofStr for %s" % username)
return None
return NTLMv2_ComputeSessionBaseKey(
ResponseKeyNT,
auth_tok.NtChallengeResponse.NTProofStr,
Expand Down
33 changes: 33 additions & 0 deletions test/scapy/layers/ntlm.uts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,39 @@ try:
except ValueError:
pass

= GSS_Accept_sec_context: reject a bad NTProofStr in NTLMSSP and NTLMSSP_DOMAIN

from scapy.layers.ntlm import NTLMSSP_DOMAIN

def ntlm_login(server, password):
# Login as User1 with an empty DomainName, which skips Netlogon in NTLMSSP_DOMAIN
client = NTLMSSP(UPN="User1", PASSWORD=password, USE_MIC=False)
clicontext, tok, _ = client.GSS_Init_sec_context(None)
srvcontext, chall, _ = server.GSS_Accept_sec_context(None, tok)
clicontext, tok, _ = client.GSS_Init_sec_context(clicontext, chall)
tok.DomainName = ""
tok.NtChallengeResponse.NTProofStr = tok.NtChallengeResponse.computeNTProofStr(
NTOWFv2(None, "User1", "", HashNt=MD4le(password)),
chall.ServerChallenge,
)
srvcontext, _, status = server.GSS_Accept_sec_context(
srvcontext, NTLM_AUTHENTICATE_V2(bytes(tok))
)
return status

IDENTITIES = {"User1": MD4le("Password1")}
with mock.patch("scapy.layers.ldap.dclocator") as dclocator:
dclocator.return_value.samlogon.DnsHostName = b"dc1.domain.local."
domain_server = NTLMSSP_DOMAIN(
UPN="SRV1$@domain.local",
HASHNT=b"\x11" * 16,
IDENTITIES=IDENTITIES,
)

for ntlm_server in [NTLMSSP(IDENTITIES=IDENTITIES), domain_server]:
assert ntlm_login(ntlm_server, "Password1") == GSS_S_COMPLETE
assert ntlm_login(ntlm_server, "WrongPassword") == GSS_S_DEFECTIVE_CREDENTIAL


+ GSSAPI - Verify real exchange

Expand Down
Loading