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
// Data:
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()
{
// [MS-SMB] 3.3.5.2: The server can leave SecurityBlob empty if not configured to send GSS token.
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.
// Note: SMBData starts at an odd offset.
int padding = (OEMPasswordLength + UnicodePasswordLength + 1) % 2;
int padding = (1 + OEMPasswordLength + UnicodePasswordLength) % 2;
dataOffset += padding;
}
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.
// 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];
}
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.
// Note: SMBData starts at an odd offset.
int padding = (SecurityBlobLength + 1) % 2;
int padding = (1 + SecurityBlobLength) % 2;
dataOffset += padding;
}
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.
// 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];
}
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.
// Note: SMBData starts at an odd offset.
int padding = (SecurityBlobLength + 1) % 2;
int padding = (1 + SecurityBlobLength) % 2;
dataOffset += padding;
}
NativeOS = SMB1Helper.ReadSMBString(this.SMBData, ref dataOffset, isUnicode);