Minor code refactoring

This commit is contained in:
Tal Aloni 2017-09-01 18:56:38 +03:00
parent 0c49e6ec29
commit d17866f6f9
4 changed files with 6 additions and 7 deletions

View file

@ -31,11 +31,10 @@ namespace SMBLibrary.SMB1
private byte ChallengeLength; // MUST be set to 0 private byte ChallengeLength; // MUST be set to 0
// Data: // Data:
public Guid ServerGuid; public Guid ServerGuid;
public byte[] SecurityBlob; public byte[] SecurityBlob; // [MS-SMB] 3.3.5.2: The server can leave SecurityBlob empty if not configured to send GSS token.
public NegotiateResponseExtended() : base() public NegotiateResponseExtended() : base()
{ {
// [MS-SMB] 3.3.5.2: The server can leave SecurityBlob empty if not configured to send GSS token.
SecurityBlob = new byte[0]; SecurityBlob = new byte[0];
} }

View file

@ -58,7 +58,7 @@ namespace SMBLibrary.SMB1
{ {
// A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header. // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header.
// Note: SMBData starts at an odd offset. // Note: SMBData starts at an odd offset.
int padding = (OEMPasswordLength + UnicodePasswordLength + 1) % 2; int padding = (1 + OEMPasswordLength + UnicodePasswordLength) % 2;
dataOffset += padding; dataOffset += padding;
} }
AccountName = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); AccountName = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
@ -86,7 +86,7 @@ namespace SMBLibrary.SMB1
{ {
// A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header. // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header.
// Note: SMBData starts at an odd offset. // Note: SMBData starts at an odd offset.
padding = (OEMPasswordLength + UnicodePasswordLength + 1) % 2; padding = (1 + OEMPasswordLength + UnicodePasswordLength) % 2;
this.SMBData = new byte[OEMPassword.Length + UnicodePassword.Length + padding + (AccountName.Length + 1) * 2 + (PrimaryDomain.Length + 1) * 2 + (NativeOS.Length + 1) * 2 + (NativeLanMan.Length + 1) * 2]; this.SMBData = new byte[OEMPassword.Length + UnicodePassword.Length + padding + (AccountName.Length + 1) * 2 + (PrimaryDomain.Length + 1) * 2 + (NativeOS.Length + 1) * 2 + (NativeLanMan.Length + 1) * 2];
} }
else else

View file

@ -51,7 +51,7 @@ namespace SMBLibrary.SMB1
{ {
// A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header. // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header.
// Note: SMBData starts at an odd offset. // Note: SMBData starts at an odd offset.
int padding = (SecurityBlobLength + 1) % 2; int padding = (1 + SecurityBlobLength) % 2;
dataOffset += padding; dataOffset += padding;
} }
NativeOS = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); NativeOS = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);
@ -76,7 +76,7 @@ namespace SMBLibrary.SMB1
{ {
// A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header. // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header.
// Note: SMBData starts at an odd offset. // Note: SMBData starts at an odd offset.
padding = (SecurityBlobLength + 1) % 2; padding = (1 + SecurityBlobLength) % 2;
this.SMBData = new byte[SecurityBlob.Length + padding + (NativeOS.Length + 1) * 2 + (NativeLanMan.Length + 1) * 2]; this.SMBData = new byte[SecurityBlob.Length + padding + (NativeOS.Length + 1) * 2 + (NativeLanMan.Length + 1) * 2];
} }
else else

View file

@ -45,7 +45,7 @@ namespace SMBLibrary.SMB1
{ {
// A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header. // A Unicode string MUST be aligned to a 16-bit boundary with respect to the beginning of the SMB Header.
// Note: SMBData starts at an odd offset. // Note: SMBData starts at an odd offset.
int padding = (SecurityBlobLength + 1) % 2; int padding = (1 + SecurityBlobLength) % 2;
dataOffset += padding; dataOffset += padding;
} }
NativeOS = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode); NativeOS = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);