From af50099f225ff6d62a6d1aa5dfa7c29ced625835 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Sat, 20 May 2017 10:50:37 +0300 Subject: [PATCH] IndependentNTLMAuthenticationProvider: Workaround for NTLMv2 with LmChallengeResponse length of 0 bytes --- .../NTLM/IndependentNTLMAuthenticationProvider.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/SMBLibrary/Authentication/NTLM/IndependentNTLMAuthenticationProvider.cs b/SMBLibrary/Authentication/NTLM/IndependentNTLMAuthenticationProvider.cs index 62fd319..877b050 100644 --- a/SMBLibrary/Authentication/NTLM/IndependentNTLMAuthenticationProvider.cs +++ b/SMBLibrary/Authentication/NTLM/IndependentNTLMAuthenticationProvider.cs @@ -301,11 +301,15 @@ namespace SMBLibrary.Authentication.NTLM /// private bool AuthenticateV2(string domainName, string accountName, string password, byte[] serverChallenge, byte[] lmResponse, byte[] ntResponse) { - byte[] _LMv2ClientChallenge = ByteReader.ReadBytes(lmResponse, 16, 8); - byte[] expectedLMv2Response = NTLMCryptography.ComputeLMv2Response(serverChallenge, _LMv2ClientChallenge, password, accountName, domainName); - if (ByteUtils.AreByteArraysEqual(expectedLMv2Response, lmResponse)) + // Note: Linux CIFS VFS 3.10 will send LmChallengeResponse with length of 0 bytes + if (lmResponse.Length == 24) { - return true; + byte[] _LMv2ClientChallenge = ByteReader.ReadBytes(lmResponse, 16, 8); + byte[] expectedLMv2Response = NTLMCryptography.ComputeLMv2Response(serverChallenge, _LMv2ClientChallenge, password, accountName, domainName); + if (ByteUtils.AreByteArraysEqual(expectedLMv2Response, lmResponse)) + { + return true; + } } if (AuthenticationMessageUtils.IsNTLMv2NTResponse(ntResponse))