Skip to content

Commit cdf3e34

Browse files
committed
NTLM: check user case insensitively
1 parent ffd9d1c commit cdf3e34

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

scapy/layers/ntlm.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,15 @@ def __init__(
14161416
self.COMPUTER_NB_NAME.lower() + "." + self.DOMAIN_FQDN
14171417
)
14181418

1419-
self.IDENTITIES = IDENTITIES
1419+
if IDENTITIES:
1420+
self.IDENTITIES = {
1421+
# Windows usernames are case insensitive
1422+
user.upper(): hashnt
1423+
for user, hashnt in IDENTITIES.items()
1424+
}
1425+
else:
1426+
self.IDENTITIES = IDENTITIES
1427+
14201428
self.DO_NOT_CHECK_LOGIN = DO_NOT_CHECK_LOGIN
14211429
self.SERVER_CHALLENGE = SERVER_CHALLENGE
14221430
super(NTLMSSP, self).__init__(**kwargs)
@@ -1681,7 +1689,10 @@ def GSS_Init_sec_context(
16811689
+ [
16821690
AV_PAIR(
16831691
AvId="MsvAvSingleHost",
1684-
Value=Single_Host_Data(MachineID=os.urandom(32)),
1692+
Value=Single_Host_Data(
1693+
MachineID=os.urandom(32),
1694+
PermanentMachineID=os.urandom(32),
1695+
),
16851696
),
16861697
]
16871698
+ (
@@ -2048,7 +2059,8 @@ def _getSessionBaseKey(self, Context, auth_tok):
20482059
Function that returns the SessionBaseKey from the ntlm Authenticate.
20492060
"""
20502061
try:
2051-
username = auth_tok.UserName
2062+
# Windows usernames are case insensitive
2063+
username = auth_tok.UserName.upper()
20522064
except AttributeError:
20532065
username = None
20542066
try:
@@ -2076,9 +2088,9 @@ def _checkLogin(self, Context, auth_tok):
20762088
20772089
Overwrite and return True to bypass.
20782090
"""
2079-
# Create the NTLM AUTH
20802091
try:
2081-
username = auth_tok.UserName
2092+
# Windows usernames are case insensitive
2093+
username = auth_tok.UserName.upper()
20822094
except AttributeError:
20832095
username = None
20842096
try:

0 commit comments

Comments
 (0)