NTLM: NTLMAuthenticationClient: Store negotiate message as class variable

This commit is contained in:
Tal Aloni 2023-12-30 16:02:59 +02:00
parent 08748d3337
commit 7628bb6ba8

View file

@ -18,6 +18,7 @@ namespace SMBLibrary.Client.Authentication
private string m_spn; private string m_spn;
private byte[] m_sessionKey; private byte[] m_sessionKey;
private AuthenticationMethod m_authenticationMethod; private AuthenticationMethod m_authenticationMethod;
private byte[] m_negotiateMessageBytes;
private bool m_isNegotiationMessageAcquired = false; private bool m_isNegotiationMessageAcquired = false;
@ -64,18 +65,18 @@ namespace SMBLibrary.Client.Authentication
useGSSAPI = true; useGSSAPI = true;
} }
byte[] negotiateMessageBytes = NTLMAuthenticationHelper.GetNegotiateMessage(m_domainName, m_userName, m_password, m_authenticationMethod); m_negotiateMessageBytes = NTLMAuthenticationHelper.GetNegotiateMessage(m_domainName, m_userName, m_password, m_authenticationMethod);
if (useGSSAPI) if (useGSSAPI)
{ {
SimpleProtectedNegotiationTokenInit outputToken = new SimpleProtectedNegotiationTokenInit(); SimpleProtectedNegotiationTokenInit outputToken = new SimpleProtectedNegotiationTokenInit();
outputToken.MechanismTypeList = new List<byte[]>(); outputToken.MechanismTypeList = new List<byte[]>();
outputToken.MechanismTypeList.Add(GSSProvider.NTLMSSPIdentifier); outputToken.MechanismTypeList.Add(GSSProvider.NTLMSSPIdentifier);
outputToken.MechanismToken = negotiateMessageBytes; outputToken.MechanismToken = m_negotiateMessageBytes;
return outputToken.GetBytes(true); return outputToken.GetBytes(true);
} }
else else
{ {
return negotiateMessageBytes; return m_negotiateMessageBytes;
} }
} }