smbserver: add SMB 3.1.1 dialect support#2216
Open
n3rada wants to merge 3 commits into
Open
Conversation
3388a75 to
48d8ee7
Compare
… signing, and session encryption
48d8ee7 to
68b4c6b
Compare
Contributor
Author
|
This PR also fixes #1829.
SESSION_SETUP assigns a new if packet['Command'] == smb2.SMB2_SESSION_SETUP:
respPacket['SessionID'] = connData['Uid']
else:
respPacket['SessionID'] = packet['SessionID'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello maintainers 👋
Closes #1981.
Closes #1829.
smbserver.pyonly negotiated SMB 2.0.2 regardless of what the client offered. This PR adds real SMB 3.1.1 support on the server side.What this PR does:
Dialect selection: the server now picks the best common dialect from what the client offers (
0x0311 > 0x0210 > 0x0202). When an SMB1 negotiate arrives withSMB 2.???, the server responds with the wildcard dialect so the client sends a proper SMB2 negotiate, which can then land on 3.1.1.Negotiate contexts: for dialect 3.1.1 the server appends
SMB2_PREAUTH_INTEGRITY_CAPABILITIES(SHA-512, no salt) andSMB2_ENCRYPTION_CAPABILITIES(AES-128-GCM preferred, AES-128-CCM fallback) to the negotiate response.Pre-authentication integrity hash: the server maintains a connection-level pre-auth hash across the negotiate exchange and forks it into a session-level hash at session setup, updating it with each request/response pair.
Signing key derivation: once authentication succeeds the raw session key is replaced by the SP 800-108 counter-mode KBKDF output (
label="SMBSigningKey\x00",context=session pre-auth hash,L=128).AES-CMAC signing: a new
signSMBv3method signs outgoing packets with AES-CMAC instead of HMAC-SHA256, as required for the SMB 3.x dialect family.Session encryption: when the client offers encryption ciphers, the server derives
SessionEncryptionKeyandSessionDecryptionKeyvia KBKDF, setsSMB2_SESSION_FLAG_ENCRYPT_DATAin the session setup response, and wraps all subsequent traffic inSMB2_TRANSFORM_HEADER(AES-128-GCM or AES-128-CCM). Incoming encrypted packets are decrypted before processing.The
validateNegotiateInforesponse now echoes back the negotiated dialect instead of always returning0x0202.Best regards