From 7610056a0b36f032b78f6928dd4a0e22a1841a55 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 1 Sep 2017 23:00:44 +0300 Subject: [PATCH] SMB1: Minor implementation improvements --- SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs | 6 ++++++ .../SMB1/Commands/SessionSetupAndXRequestExtended.cs | 7 +++++-- SMBLibrary/SMB1/Commands/SessionSetupAndXResponse.cs | 9 ++++++--- .../SMB1/Commands/SessionSetupAndXResponseExtended.cs | 6 ++++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs b/SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs index 8503c3f..3ef324d 100644 --- a/SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs +++ b/SMBLibrary/SMB1/Commands/SessionSetupAndXRequest.cs @@ -37,6 +37,10 @@ namespace SMBLibrary.SMB1 public SessionSetupAndXRequest(): base() { + AccountName = String.Empty; + PrimaryDomain = String.Empty; + NativeOS = String.Empty; + NativeLanMan = String.Empty; } public SessionSetupAndXRequest(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode) @@ -69,6 +73,8 @@ namespace SMBLibrary.SMB1 public override byte[] GetBytes(bool isUnicode) { + Capabilities &= ~ServerCapabilities.ExtendedSecurity; + OEMPasswordLength = (ushort)OEMPassword.Length; UnicodePasswordLength = (ushort)UnicodePassword.Length; diff --git a/SMBLibrary/SMB1/Commands/SessionSetupAndXRequestExtended.cs b/SMBLibrary/SMB1/Commands/SessionSetupAndXRequestExtended.cs index 9c3f61f..47de5e7 100644 --- a/SMBLibrary/SMB1/Commands/SessionSetupAndXRequestExtended.cs +++ b/SMBLibrary/SMB1/Commands/SessionSetupAndXRequestExtended.cs @@ -27,11 +27,13 @@ namespace SMBLibrary.SMB1 public ServerCapabilities Capabilities; // Data: public byte[] SecurityBlob; - public string NativeOS = String.Empty; // SMB_STRING (If Unicode, this field MUST be aligned to start on a 2-byte boundary from the start of the SMB header) - public string NativeLanMan = String.Empty; // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header) + public string NativeOS; // SMB_STRING (If Unicode, this field MUST be aligned to start on a 2-byte boundary from the start of the SMB header) + public string NativeLanMan; // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header) public SessionSetupAndXRequestExtended(): base() { + NativeOS = String.Empty; + NativeLanMan = String.Empty; } public SessionSetupAndXRequestExtended(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode) @@ -60,6 +62,7 @@ namespace SMBLibrary.SMB1 public override byte[] GetBytes(bool isUnicode) { + Capabilities |= ServerCapabilities.ExtendedSecurity; SecurityBlobLength = (ushort)SecurityBlob.Length; this.SMBParameters = new byte[ParametersLength]; diff --git a/SMBLibrary/SMB1/Commands/SessionSetupAndXResponse.cs b/SMBLibrary/SMB1/Commands/SessionSetupAndXResponse.cs index 76d2e44..cc8358a 100644 --- a/SMBLibrary/SMB1/Commands/SessionSetupAndXResponse.cs +++ b/SMBLibrary/SMB1/Commands/SessionSetupAndXResponse.cs @@ -23,12 +23,15 @@ namespace SMBLibrary.SMB1 //ushort AndXOffset; public SessionSetupAction Action; // Data: - public string NativeOS = String.Empty; // SMB_STRING (If Unicode, this field MUST be aligned to start on a 2-byte boundary from the start of the SMB header) - public string NativeLanMan = String.Empty; // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header) - public string PrimaryDomain = String.Empty; // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header) + public string NativeOS; // SMB_STRING (If Unicode, this field MUST be aligned to start on a 2-byte boundary from the start of the SMB header) + public string NativeLanMan; // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header) + public string PrimaryDomain; // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header) public SessionSetupAndXResponse() : base() { + NativeOS = String.Empty; + NativeLanMan = String.Empty; + PrimaryDomain = String.Empty; } public SessionSetupAndXResponse(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode) diff --git a/SMBLibrary/SMB1/Commands/SessionSetupAndXResponseExtended.cs b/SMBLibrary/SMB1/Commands/SessionSetupAndXResponseExtended.cs index 62bc2e8..ae43dad 100644 --- a/SMBLibrary/SMB1/Commands/SessionSetupAndXResponseExtended.cs +++ b/SMBLibrary/SMB1/Commands/SessionSetupAndXResponseExtended.cs @@ -25,12 +25,14 @@ namespace SMBLibrary.SMB1 private ushort SecurityBlobLength; // Data: public byte[] SecurityBlob; - public string NativeOS = String.Empty; // SMB_STRING (If Unicode, this field MUST be aligned to start on a 2-byte boundary from the start of the SMB header) - public string NativeLanMan = String.Empty; // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header) + public string NativeOS; // SMB_STRING (If Unicode, this field MUST be aligned to start on a 2-byte boundary from the start of the SMB header) + public string NativeLanMan; // SMB_STRING (this field WILL be aligned to start on a 2-byte boundary from the start of the SMB header) public SessionSetupAndXResponseExtended() : base() { SecurityBlob = new byte[0]; + NativeOS = String.Empty; + NativeLanMan = String.Empty; } public SessionSetupAndXResponseExtended(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)