From 9ff7adced48e42b2e39287989fa06cda57955a71 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Mon, 29 Jul 2024 21:56:57 +0300 Subject: [PATCH] SMB2Client: Correctly handle signing when authenticated as guest --- SMBLibrary/Client/SMB2Client.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SMBLibrary/Client/SMB2Client.cs b/SMBLibrary/Client/SMB2Client.cs index 1d34e2d..dd2f50b 100644 --- a/SMBLibrary/Client/SMB2Client.cs +++ b/SMBLibrary/Client/SMB2Client.cs @@ -272,7 +272,17 @@ namespace SMBLibrary.Client if (m_isLoggedIn) { SessionFlags sessionFlags = ((SessionSetupResponse)response).SessionFlags; - m_signingKey = SMB2Cryptography.GenerateSigningKey(m_sessionKey, m_dialect, null); + if ((sessionFlags & SessionFlags.IsGuest) > 0) + { + // [MS-SMB2] 3.2.5.3.1 If the SMB2_SESSION_FLAG_IS_GUEST bit is set in the SessionFlags field of the SMB2 + // SESSION_SETUP Response and if RequireMessageSigning is FALSE, Session.SigningRequired MUST be set to FALSE. + m_signingRequired = false; + } + else + { + m_signingKey = SMB2Cryptography.GenerateSigningKey(m_sessionKey, m_dialect, null); + } + if (m_dialect == SMB2Dialect.SMB300) { m_encryptSessionData = (sessionFlags & SessionFlags.EncryptData) > 0;