SMB1: Minor implementation improvements

This commit is contained in:
Tal Aloni 2017-09-01 18:38:42 +03:00
parent 320a4cb969
commit b3445530ac
6 changed files with 27 additions and 12 deletions

View file

@ -27,8 +27,8 @@ namespace SMBLibrary.SMB1
public ServerCapabilities Capabilities;
// Data:
public byte[] SecurityBlob;
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 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 SessionSetupAndXRequestExtended(): base()
{

View file

@ -11,6 +11,9 @@ using Utilities;
namespace SMBLibrary.SMB1
{
/// <summary>
/// SMB_COM_SESSION_SETUP_ANDX Response
/// </summary>
public class SessionSetupAndXResponse : SMBAndXCommand
{
public const int ParametersLength = 6;
@ -20,9 +23,9 @@ namespace SMBLibrary.SMB1
//ushort AndXOffset;
public SessionSetupAction Action;
// Data:
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 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 SessionSetupAndXResponse() : base()
{
@ -62,7 +65,7 @@ namespace SMBLibrary.SMB1
{
this.SMBData = new byte[NativeOS.Length + NativeLanMan.Length + PrimaryDomain.Length + 3];
}
SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, NativeOS);
SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, NativeOS);
SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, NativeLanMan);
SMB1Helper.WriteSMBString(this.SMBData, ref offset, isUnicode, PrimaryDomain);

View file

@ -11,6 +11,9 @@ using Utilities;
namespace SMBLibrary.SMB1
{
/// <summary>
/// SMB_COM_SESSION_SETUP_ANDX Response, NT LAN Manager dialect, Extended Security response
/// </summary>
public class SessionSetupAndXResponseExtended : SMBAndXCommand
{
public const int ParametersLength = 8;
@ -22,14 +25,12 @@ namespace SMBLibrary.SMB1
private ushort SecurityBlobLength;
// Data:
public byte[] SecurityBlob;
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 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 SessionSetupAndXResponseExtended() : base()
{
SecurityBlob = new byte[0];
NativeOS = String.Empty;
NativeLanMan = String.Empty;
}
public SessionSetupAndXResponseExtended(byte[] buffer, int offset, bool isUnicode) : base(buffer, offset, isUnicode)

View file

@ -16,7 +16,7 @@ namespace SMBLibrary.SMB1
/// </summary>
public class WriteRawFinalResponse : SMB1Command
{
public ushort ParametersLength = 2;
public const ushort ParametersLength = 2;
// Parameters;
public ushort Count;

View file

@ -16,7 +16,7 @@ namespace SMBLibrary.SMB1
/// </summary>
public class WriteRawInterimResponse : SMB1Command
{
public ushort ParametersLength = 2;
public const ushort ParametersLength = 2;
// Parameters;
public ushort Available;

View file

@ -114,6 +114,17 @@ namespace SMBLibrary.SMB1
{
return (Flags2 & HeaderFlags2.Unicode) > 0;
}
set
{
if (value)
{
this.Flags2 |= HeaderFlags2.Unicode;
}
else
{
this.Flags2 &= ~HeaderFlags2.Unicode;
}
}
}
public static bool IsValidSMB1Header(byte[] buffer)