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
4 changes: 4 additions & 0 deletions SMBLibrary/Client/Authentication/NTLMAuthenticationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ protected virtual byte[] GetAuthenticateMessage(byte[] securityBlob)
challengeMessageBytes = securityBlob;
}

// When NegState is AcceptCompleted or Reject, the SPNEGO token may not contain a Response Token
if (challengeMessageBytes == null)
return null;

byte[] authenticateMessageBytes = NTLMAuthenticationHelper.GetAuthenticateMessage(m_negotiateMessageBytes, challengeMessageBytes, m_domainName, m_userName, m_password, m_spn, m_authenticationMethod, out m_sessionKey);
if (useGSSAPI && authenticateMessageBytes != null)
{
Expand Down
10 changes: 10 additions & 0 deletions SMBLibrary/Client/SMB2Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ public NTStatus Login(IAuthenticationClient authenticationClient)
if (m_isLoggedIn)
{
m_sessionID = response.Header.SessionID;
if (finalSessionSetupResponse.SecurityBuffer != null && finalSessionSetupResponse.SecurityBuffer.Length > 0)
{
// Some authentication mechanisms (e.g. Kerberos) embed acceptor-provider
// context data (such as an AP-REP subkey) in the final, successful
// SESSION_SETUP response. Give the authentication client a chance to
// process it before deriving the session key, since it may override
// the key negotiated so far.
authenticationClient.InitializeSecurityContext(finalSessionSetupResponse.SecurityBuffer);
}

m_sessionKey = authenticationClient.GetSessionKey();
m_authenticationClient = authenticationClient;
SessionFlags sessionFlags = finalSessionSetupResponse.SessionFlags;
Expand Down