Renamed SMBHeader to SMB1Header

This commit is contained in:
Tal Aloni 2017-01-10 11:07:08 +02:00
parent 8b7d8b289b
commit 53de01c3d6
25 changed files with 68 additions and 68 deletions

View file

@ -69,7 +69,7 @@ namespace SMBLibrary.SMB1
uint dataCount = (ushort)TransData.Length; uint dataCount = (ushort)TransData.Length;
// WordCount + ByteCount are additional 3 bytes // WordCount + ByteCount are additional 3 bytes
uint parameterOffset = (ushort)(SMBHeader.Length + 3 + (FixedSMBParametersLength + Setup.Length)); uint parameterOffset = (ushort)(SMB1Header.Length + 3 + (FixedSMBParametersLength + Setup.Length));
int padding1 = (int)(4 - (parameterOffset % 4)) % 4; int padding1 = (int)(4 - (parameterOffset % 4)) % 4;
parameterOffset += (ushort)padding1; parameterOffset += (ushort)padding1;
uint dataOffset = (ushort)(parameterOffset + parameterCount); uint dataOffset = (ushort)(parameterOffset + parameterCount);

View file

@ -68,7 +68,7 @@ namespace SMBLibrary.SMB1
uint dataDisplacement = 0; uint dataDisplacement = 0;
// WordCount + ByteCount are additional 3 bytes // WordCount + ByteCount are additional 3 bytes
uint parameterOffset = (ushort)(SMBHeader.Length + 3 + (FixedSMBParametersLength + Setup.Length)); uint parameterOffset = (ushort)(SMB1Header.Length + 3 + (FixedSMBParametersLength + Setup.Length));
int padding1 = (int)(4 - (parameterOffset % 4)) % 4; int padding1 = (int)(4 - (parameterOffset % 4)) % 4;
parameterOffset += (ushort)padding1; parameterOffset += (ushort)padding1;
uint dataOffset = (ushort)(parameterOffset + parameterCount); uint dataOffset = (ushort)(parameterOffset + parameterCount);
@ -106,7 +106,7 @@ namespace SMBLibrary.SMB1
public static int CalculateMessageSize(int setupLength, int trans2ParametersLength, int trans2DataLength) public static int CalculateMessageSize(int setupLength, int trans2ParametersLength, int trans2DataLength)
{ {
int parameterOffset = SMBHeader.Length + 3 + (FixedSMBParametersLength + setupLength); int parameterOffset = SMB1Header.Length + 3 + (FixedSMBParametersLength + setupLength);
int padding1 = (4 - (parameterOffset % 4)) % 4; int padding1 = (4 - (parameterOffset % 4)) % 4;
parameterOffset += padding1; parameterOffset += padding1;
int dataOffset = (parameterOffset + trans2ParametersLength); int dataOffset = (parameterOffset + trans2ParametersLength);
@ -115,7 +115,7 @@ namespace SMBLibrary.SMB1
int messageParametersLength = FixedSMBParametersLength + setupLength; int messageParametersLength = FixedSMBParametersLength + setupLength;
int messageDataLength = trans2ParametersLength + trans2DataLength + padding1 + padding2; int messageDataLength = trans2ParametersLength + trans2DataLength + padding1 + padding2;
// WordCount + ByteCount are additional 3 bytes // WordCount + ByteCount are additional 3 bytes
return SMBHeader.Length + messageParametersLength + messageDataLength + 3; return SMB1Header.Length + messageParametersLength + messageDataLength + 3;
} }
} }
} }

View file

@ -63,7 +63,7 @@ namespace SMBLibrary.SMB1
uint dataCount = (ushort)TransData.Length; uint dataCount = (ushort)TransData.Length;
// WordCount + ByteCount are additional 3 bytes // WordCount + ByteCount are additional 3 bytes
uint parameterOffset = (ushort)(SMBHeader.Length + 3 + (SMBParametersLength)); uint parameterOffset = (ushort)(SMB1Header.Length + 3 + (SMBParametersLength));
int padding1 = (int)(4 - (parameterOffset % 4)) % 4; int padding1 = (int)(4 - (parameterOffset % 4)) % 4;
parameterOffset += (ushort)padding1; parameterOffset += (ushort)padding1;
uint dataOffset = (ushort)(parameterOffset + parameterCount); uint dataOffset = (ushort)(parameterOffset + parameterCount);

View file

@ -56,7 +56,7 @@ namespace SMBLibrary.SMB1
{ {
uint DataLength = (uint)Data.Length; uint DataLength = (uint)Data.Length;
// WordCount + ByteCount are additional 3 bytes // WordCount + ByteCount are additional 3 bytes
ushort DataOffset = SMBHeader.Length + 3 + ParametersLength; ushort DataOffset = SMB1Header.Length + 3 + ParametersLength;
if (isUnicode) if (isUnicode)
{ {
DataOffset++; DataOffset++;

View file

@ -63,7 +63,7 @@ namespace SMBLibrary.SMB1
return buffer; return buffer;
} }
public static SMB1Command ReadCommand(byte[] buffer, int offset, CommandName commandName, SMBHeader header) public static SMB1Command ReadCommand(byte[] buffer, int offset, CommandName commandName, SMB1Header header)
{ {
if ((header.Flags & HeaderFlags.Reply) > 0) if ((header.Flags & HeaderFlags.Reply) > 0)
{ {

View file

@ -45,7 +45,7 @@ namespace SMBLibrary.SMB1
ParameterCount = (ushort)TransParameters.Length; ParameterCount = (ushort)TransParameters.Length;
DataCount = (ushort)TransData.Length; DataCount = (ushort)TransData.Length;
ParameterOffset = (ushort)(SMBHeader.Length + SMBParametersLength); ParameterOffset = (ushort)(SMB1Header.Length + SMBParametersLength);
int padding1 = (4 - (ParameterOffset % 4)) % 4; int padding1 = (4 - (ParameterOffset % 4)) % 4;
ParameterOffset += (ushort)padding1; ParameterOffset += (ushort)padding1;
DataOffset = (ushort)(ParameterOffset + ParameterCount); DataOffset = (ushort)(ParameterOffset + ParameterCount);

View file

@ -94,7 +94,7 @@ namespace SMBLibrary.SMB1
ushort DataCount = (ushort)TransData.Length; ushort DataCount = (ushort)TransData.Length;
// WordCount + ByteCount are additional 3 bytes // WordCount + ByteCount are additional 3 bytes
ushort ParameterOffset = (ushort)(SMBHeader.Length + 3 + (FixedSMBParametersLength + Setup.Length)); ushort ParameterOffset = (ushort)(SMB1Header.Length + 3 + (FixedSMBParametersLength + Setup.Length));
if (this is Transaction2Request) if (this is Transaction2Request)
{ {
ParameterOffset += 1; ParameterOffset += 1;

View file

@ -73,7 +73,7 @@ namespace SMBLibrary.SMB1
ushort dataCount = (ushort)TransData.Length; ushort dataCount = (ushort)TransData.Length;
// WordCount + ByteCount are additional 3 bytes // WordCount + ByteCount are additional 3 bytes
ushort parameterOffset = (ushort)(SMBHeader.Length + 3 + (FixedSMBParametersLength + Setup.Length)); ushort parameterOffset = (ushort)(SMB1Header.Length + 3 + (FixedSMBParametersLength + Setup.Length));
int padding1 = (4 - (parameterOffset %4)) % 4; int padding1 = (4 - (parameterOffset %4)) % 4;
parameterOffset += (ushort)padding1; parameterOffset += (ushort)padding1;
ushort dataOffset = (ushort)(parameterOffset + parameterCount); ushort dataOffset = (ushort)(parameterOffset + parameterCount);
@ -111,7 +111,7 @@ namespace SMBLibrary.SMB1
public static int CalculateMessageSize(int setupLength, int trans2ParametersLength, int trans2DataLength) public static int CalculateMessageSize(int setupLength, int trans2ParametersLength, int trans2DataLength)
{ {
int parameterOffset = SMBHeader.Length + 3 + (FixedSMBParametersLength + setupLength); int parameterOffset = SMB1Header.Length + 3 + (FixedSMBParametersLength + setupLength);
int padding1 = (4 - (parameterOffset %4)) % 4; int padding1 = (4 - (parameterOffset %4)) % 4;
parameterOffset += padding1; parameterOffset += padding1;
int dataOffset = (parameterOffset + trans2ParametersLength); int dataOffset = (parameterOffset + trans2ParametersLength);
@ -120,7 +120,7 @@ namespace SMBLibrary.SMB1
int messageParametersLength = FixedSMBParametersLength + setupLength; int messageParametersLength = FixedSMBParametersLength + setupLength;
int messageDataLength = trans2ParametersLength + trans2DataLength + padding1 + padding2; int messageDataLength = trans2ParametersLength + trans2DataLength + padding1 + padding2;
// WordCount + ByteCount are additional 3 bytes // WordCount + ByteCount are additional 3 bytes
return SMBHeader.Length + messageParametersLength + messageDataLength + 3; return SMB1Header.Length + messageParametersLength + messageDataLength + 3;
} }
} }
} }

View file

@ -57,7 +57,7 @@ namespace SMBLibrary.SMB1
DataCount = (ushort)TransData.Length; DataCount = (ushort)TransData.Length;
// WordCount + ByteCount are additional 3 bytes // WordCount + ByteCount are additional 3 bytes
ParameterOffset = (ushort)(SMBHeader.Length + 3 + SMBParametersLength); ParameterOffset = (ushort)(SMB1Header.Length + 3 + SMBParametersLength);
int padding1 = (4 - (ParameterOffset % 4)) % 4; int padding1 = (4 - (ParameterOffset % 4)) % 4;
ParameterOffset += (ushort)padding1; ParameterOffset += (ushort)padding1;
DataOffset = (ushort)(ParameterOffset + ParameterCount); DataOffset = (ushort)(ParameterOffset + ParameterCount);

View file

@ -62,7 +62,7 @@ namespace SMBLibrary.SMB1
{ {
uint DataLength = (uint)Data.Length; uint DataLength = (uint)Data.Length;
// WordCount + ByteCount are additional 3 bytes // WordCount + ByteCount are additional 3 bytes
ushort DataOffset = SMBHeader.Length + 3 + ParametersFixedLength; ushort DataOffset = SMB1Header.Length + 3 + ParametersFixedLength;
if (isUnicode) if (isUnicode)
{ {
DataOffset++; DataOffset++;

View file

@ -11,7 +11,7 @@ using Utilities;
namespace SMBLibrary.SMB1 namespace SMBLibrary.SMB1
{ {
public class SMBHeader public class SMB1Header
{ {
public const int Length = 32; public const int Length = 32;
public static readonly byte[] ProtocolSignature = new byte[] { 0xFF, 0x53, 0x4D, 0x42 }; public static readonly byte[] ProtocolSignature = new byte[] { 0xFF, 0x53, 0x4D, 0x42 };
@ -31,12 +31,12 @@ namespace SMBLibrary.SMB1
public uint PID; // Process ID public uint PID; // Process ID
public SMBHeader() public SMB1Header()
{ {
Protocol = ProtocolSignature; Protocol = ProtocolSignature;
} }
public SMBHeader(byte[] buffer) public SMB1Header(byte[] buffer)
{ {
Protocol = ByteReader.ReadBytes(buffer, 0, 4); Protocol = ByteReader.ReadBytes(buffer, 0, 4);
Command = (CommandName)ByteReader.ReadByte(buffer, 4); Command = (CommandName)ByteReader.ReadByte(buffer, 4);

View file

@ -18,18 +18,18 @@ namespace SMBLibrary.SMB1
/// </summary> /// </summary>
public class SMBMessage public class SMBMessage
{ {
public SMBHeader Header; public SMB1Header Header;
public List<SMB1Command> Commands = new List<SMB1Command>(); public List<SMB1Command> Commands = new List<SMB1Command>();
public SMBMessage() public SMBMessage()
{ {
Header = new SMBHeader(); Header = new SMB1Header();
} }
public SMBMessage(byte[] buffer) public SMBMessage(byte[] buffer)
{ {
Header = new SMBHeader(buffer); Header = new SMB1Header(buffer);
SMB1Command command = SMB1Command.ReadCommand(buffer, SMBHeader.Length, Header.Command, Header); SMB1Command command = SMB1Command.ReadCommand(buffer, SMB1Header.Length, Header.Command, Header);
Commands.Add(command); Commands.Add(command);
while(command is SMBAndXCommand) while(command is SMBAndXCommand)
{ {
@ -65,7 +65,7 @@ namespace SMBLibrary.SMB1
} }
List<byte[]> sequence = new List<byte[]>(); List<byte[]> sequence = new List<byte[]>();
int length = SMBHeader.Length; int length = SMB1Header.Length;
byte[] commandBytes; byte[] commandBytes;
for (int index = 0; index < Commands.Count - 1; index++) for (int index = 0; index < Commands.Count - 1; index++)
{ {
@ -86,7 +86,7 @@ namespace SMBLibrary.SMB1
byte[] buffer = new byte[length]; byte[] buffer = new byte[length];
Header.WriteBytes(buffer, 0); Header.WriteBytes(buffer, 0);
int offset = SMBHeader.Length; int offset = SMB1Header.Length;
foreach (byte[] bytes in sequence) foreach (byte[] bytes in sequence)
{ {
ByteWriter.WriteBytes(buffer, ref offset, bytes); ByteWriter.WriteBytes(buffer, ref offset, bytes);
@ -97,10 +97,10 @@ namespace SMBLibrary.SMB1
public static bool IsValidSMBMessage(byte[] buffer) public static bool IsValidSMBMessage(byte[] buffer)
{ {
if (buffer[0] == SMBHeader.ProtocolSignature[0] && if (buffer[0] == SMB1Header.ProtocolSignature[0] &&
buffer[1] == SMBHeader.ProtocolSignature[1] && buffer[1] == SMB1Header.ProtocolSignature[1] &&
buffer[2] == SMBHeader.ProtocolSignature[2] && buffer[2] == SMB1Header.ProtocolSignature[2] &&
buffer[3] == SMBHeader.ProtocolSignature[3]) buffer[3] == SMB1Header.ProtocolSignature[3])
{ {
return true; return true;
} }

View file

@ -274,7 +274,7 @@
<Compile Include="SMB1\NTTransactSubcommands\NTTransactQuerySecurityDescriptorResponse.cs" /> <Compile Include="SMB1\NTTransactSubcommands\NTTransactQuerySecurityDescriptorResponse.cs" />
<Compile Include="SMB1\NTTransactSubcommands\NTTransactSetSecurityDescriptor.cs" /> <Compile Include="SMB1\NTTransactSubcommands\NTTransactSetSecurityDescriptor.cs" />
<Compile Include="SMB1\NTTransactSubcommands\NTTransactSubcommand.cs" /> <Compile Include="SMB1\NTTransactSubcommands\NTTransactSubcommand.cs" />
<Compile Include="SMB1\SMBHeader.cs" /> <Compile Include="SMB1\SMB1Header.cs" />
<Compile Include="SMB1\SMBHelper.cs" /> <Compile Include="SMB1\SMBHelper.cs" />
<Compile Include="SMB1\SMBMessage.cs" /> <Compile Include="SMB1\SMBMessage.cs" />
<Compile Include="SMB1\Transaction2Subcommands\Enums\ExtendedAttributeFlag.cs" /> <Compile Include="SMB1\Transaction2Subcommands\Enums\ExtendedAttributeFlag.cs" />

View file

@ -15,7 +15,7 @@ namespace SMBLibrary.Server
{ {
public class FileSystemResponseHelper public class FileSystemResponseHelper
{ {
internal static SMB1Command GetCreateDirectoryResponse(SMBHeader header, CreateDirectoryRequest request, FileSystemShare share, StateObject state) internal static SMB1Command GetCreateDirectoryResponse(SMB1Header header, CreateDirectoryRequest request, FileSystemShare share, StateObject state)
{ {
string userName = state.GetConnectedUserName(header.UID); string userName = state.GetConnectedUserName(header.UID);
if (!share.HasWriteAccess(userName)) if (!share.HasWriteAccess(userName))
@ -45,7 +45,7 @@ namespace SMBLibrary.Server
return new CreateDirectoryResponse(); return new CreateDirectoryResponse();
} }
internal static SMB1Command GetDeleteDirectoryResponse(SMBHeader header, DeleteDirectoryRequest request, FileSystemShare share, StateObject state) internal static SMB1Command GetDeleteDirectoryResponse(SMB1Header header, DeleteDirectoryRequest request, FileSystemShare share, StateObject state)
{ {
string userName = state.GetConnectedUserName(header.UID); string userName = state.GetConnectedUserName(header.UID);
if (!share.HasWriteAccess(userName)) if (!share.HasWriteAccess(userName))
@ -87,7 +87,7 @@ namespace SMBLibrary.Server
} }
} }
internal static SMB1Command GetCheckDirectoryResponse(SMBHeader header, CheckDirectoryRequest request, FileSystemShare share) internal static SMB1Command GetCheckDirectoryResponse(SMB1Header header, CheckDirectoryRequest request, FileSystemShare share)
{ {
IFileSystem fileSystem = share.FileSystem; IFileSystem fileSystem = share.FileSystem;
FileSystemEntry entry = fileSystem.GetEntry(request.DirectoryName); FileSystemEntry entry = fileSystem.GetEntry(request.DirectoryName);
@ -100,7 +100,7 @@ namespace SMBLibrary.Server
return new CheckDirectoryResponse(); return new CheckDirectoryResponse();
} }
internal static SMB1Command GetDeleteResponse(SMBHeader header, DeleteRequest request, FileSystemShare share, StateObject state) internal static SMB1Command GetDeleteResponse(SMB1Header header, DeleteRequest request, FileSystemShare share, StateObject state)
{ {
string userName = state.GetConnectedUserName(header.UID); string userName = state.GetConnectedUserName(header.UID);
if (!share.HasWriteAccess(userName)) if (!share.HasWriteAccess(userName))
@ -143,7 +143,7 @@ namespace SMBLibrary.Server
} }
} }
internal static SMB1Command GetRenameResponse(SMBHeader header, RenameRequest request, FileSystemShare share, StateObject state) internal static SMB1Command GetRenameResponse(SMB1Header header, RenameRequest request, FileSystemShare share, StateObject state)
{ {
string userName = state.GetConnectedUserName(header.UID); string userName = state.GetConnectedUserName(header.UID);
if (!share.HasWriteAccess(userName)) if (!share.HasWriteAccess(userName))
@ -189,7 +189,7 @@ namespace SMBLibrary.Server
} }
} }
internal static SMB1Command GetQueryInformationResponse(SMBHeader header, QueryInformationRequest request, FileSystemShare share) internal static SMB1Command GetQueryInformationResponse(SMB1Header header, QueryInformationRequest request, FileSystemShare share)
{ {
IFileSystem fileSystem = share.FileSystem; IFileSystem fileSystem = share.FileSystem;
FileSystemEntry entry = fileSystem.GetEntry(request.FileName); FileSystemEntry entry = fileSystem.GetEntry(request.FileName);
@ -207,7 +207,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static SMB1Command GetSetInformationResponse(SMBHeader header, SetInformationRequest request, FileSystemShare share, StateObject state) internal static SMB1Command GetSetInformationResponse(SMB1Header header, SetInformationRequest request, FileSystemShare share, StateObject state)
{ {
string userName = state.GetConnectedUserName(header.UID); string userName = state.GetConnectedUserName(header.UID);
if (!share.HasWriteAccess(userName)) if (!share.HasWriteAccess(userName))
@ -249,7 +249,7 @@ namespace SMBLibrary.Server
return new SetInformationResponse(); return new SetInformationResponse();
} }
internal static SMB1Command GetSetInformation2Response(SMBHeader header, SetInformation2Request request, FileSystemShare share, StateObject state) internal static SMB1Command GetSetInformation2Response(SMB1Header header, SetInformation2Request request, FileSystemShare share, StateObject state)
{ {
string openedFilePath = state.GetOpenedFilePath(request.FID); string openedFilePath = state.GetOpenedFilePath(request.FID);
if (openedFilePath == null) if (openedFilePath == null)

View file

@ -16,7 +16,7 @@ namespace SMBLibrary.Server
{ {
public class NTCreateHelper public class NTCreateHelper
{ {
internal static SMB1Command GetNTCreateResponse(SMBHeader header, NTCreateAndXRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetNTCreateResponse(SMB1Header header, NTCreateAndXRequest request, ISMBShare share, StateObject state)
{ {
bool isExtended = (request.Flags & NTCreateFlags.NT_CREATE_REQUEST_EXTENDED_RESPONSE) > 0; bool isExtended = (request.Flags & NTCreateFlags.NT_CREATE_REQUEST_EXTENDED_RESPONSE) > 0;
string path = request.FileName; string path = request.FileName;

View file

@ -17,7 +17,7 @@ namespace SMBLibrary.Server
/// <summary> /// <summary>
/// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request. /// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request.
/// </summary> /// </summary>
internal static SMB1Command GetNTTransactResponse(SMBHeader header, NTTransactRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue) internal static SMB1Command GetNTTransactResponse(SMB1Header header, NTTransactRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
{ {
if (request.TransParameters.Length < request.TotalParameterCount || if (request.TransParameters.Length < request.TotalParameterCount ||
request.TransData.Length < request.TotalDataCount) request.TransData.Length < request.TotalDataCount)
@ -45,7 +45,7 @@ namespace SMBLibrary.Server
/// There are no secondary response messages. /// There are no secondary response messages.
/// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request. /// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request.
/// </summary> /// </summary>
internal static SMB1Command GetNTTransactResponse(SMBHeader header, NTTransactSecondaryRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue) internal static SMB1Command GetNTTransactResponse(SMB1Header header, NTTransactSecondaryRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
{ {
ProcessStateObject processState = state.GetProcessState(header.PID); ProcessStateObject processState = state.GetProcessState(header.PID);
if (processState == null) if (processState == null)
@ -69,7 +69,7 @@ namespace SMBLibrary.Server
} }
} }
internal static SMB1Command GetCompleteNTTransactResponse(SMBHeader header, NTTransactSubcommandName subcommandName, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List<SMB1Command> sendQueue) internal static SMB1Command GetCompleteNTTransactResponse(SMB1Header header, NTTransactSubcommandName subcommandName, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
{ {
NTTransactSubcommand subcommand = NTTransactSubcommand.GetSubcommandRequest(subcommandName, requestSetup, requestParameters, requestData, header.UnicodeFlag); NTTransactSubcommand subcommand = NTTransactSubcommand.GetSubcommandRequest(subcommandName, requestSetup, requestParameters, requestData, header.UnicodeFlag);
NTTransactSubcommand subcommandResponse = null; NTTransactSubcommand subcommandResponse = null;
@ -112,7 +112,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
private static NTTransactIOCTLResponse GetSubcommandResponse(SMBHeader header, NTTransactIOCTLRequest subcommand) private static NTTransactIOCTLResponse GetSubcommandResponse(SMB1Header header, NTTransactIOCTLRequest subcommand)
{ {
const uint FSCTL_CREATE_OR_GET_OBJECT_ID = 0x900C0; const uint FSCTL_CREATE_OR_GET_OBJECT_ID = 0x900C0;

View file

@ -18,7 +18,7 @@ namespace SMBLibrary.Server
/// </summary> /// </summary>
public class NegotiateHelper public class NegotiateHelper
{ {
internal static NegotiateResponseNTLM GetNegotiateResponse(SMBHeader header, NegotiateRequest request, byte[] serverChallenge) internal static NegotiateResponseNTLM GetNegotiateResponse(SMB1Header header, NegotiateRequest request, byte[] serverChallenge)
{ {
NegotiateResponseNTLM response = new NegotiateResponseNTLM(); NegotiateResponseNTLM response = new NegotiateResponseNTLM();
@ -68,7 +68,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static SMB1Command GetSessionSetupResponse(SMBHeader header, SessionSetupAndXRequest request, INTLMAuthenticationProvider users, StateObject state) internal static SMB1Command GetSessionSetupResponse(SMB1Header header, SessionSetupAndXRequest request, INTLMAuthenticationProvider users, StateObject state)
{ {
SessionSetupAndXResponse response = new SessionSetupAndXResponse(); SessionSetupAndXResponse response = new SessionSetupAndXResponse();
// The PrimaryDomain field in the request is used to determine with domain controller should authenticate the user credentials, // The PrimaryDomain field in the request is used to determine with domain controller should authenticate the user credentials,
@ -115,7 +115,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static SMB1Command GetSessionSetupResponseExtended(SMBHeader header, SessionSetupAndXRequestExtended request, INTLMAuthenticationProvider users, StateObject state) internal static SMB1Command GetSessionSetupResponseExtended(SMB1Header header, SessionSetupAndXRequestExtended request, INTLMAuthenticationProvider users, StateObject state)
{ {
SessionSetupAndXResponseExtended response = new SessionSetupAndXResponseExtended(); SessionSetupAndXResponseExtended response = new SessionSetupAndXResponseExtended();

View file

@ -16,7 +16,7 @@ namespace SMBLibrary.Server
{ {
public class OpenAndXHelper public class OpenAndXHelper
{ {
internal static SMB1Command GetOpenAndXResponse(SMBHeader header, OpenAndXRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetOpenAndXResponse(SMB1Header header, OpenAndXRequest request, ISMBShare share, StateObject state)
{ {
bool isExtended = (request.Flags & OpenFlags.SMB_OPEN_EXTENDED_RESPONSE) > 0; bool isExtended = (request.Flags & OpenFlags.SMB_OPEN_EXTENDED_RESPONSE) > 0;
string path = request.FileName; string path = request.FileName;

View file

@ -17,7 +17,7 @@ namespace SMBLibrary.Server
{ {
public class ReadWriteResponseHelper public class ReadWriteResponseHelper
{ {
internal static SMB1Command GetReadResponse(SMBHeader header, ReadRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetReadResponse(SMB1Header header, ReadRequest request, ISMBShare share, StateObject state)
{ {
byte[] data = PerformRead(header, share, request.FID, request.ReadOffsetInBytes, request.CountOfBytesToRead, state); byte[] data = PerformRead(header, share, request.FID, request.ReadOffsetInBytes, request.CountOfBytesToRead, state);
if (header.Status != NTStatus.STATUS_SUCCESS) if (header.Status != NTStatus.STATUS_SUCCESS)
@ -31,7 +31,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static SMB1Command GetReadResponse(SMBHeader header, ReadAndXRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetReadResponse(SMB1Header header, ReadAndXRequest request, ISMBShare share, StateObject state)
{ {
uint maxCount = request.MaxCount; uint maxCount = request.MaxCount;
if ((share is FileSystemShare) && state.LargeRead) if ((share is FileSystemShare) && state.LargeRead)
@ -54,7 +54,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
public static byte[] PerformRead(SMBHeader header, ISMBShare share, ushort FID, ulong offset, uint maxCount, StateObject state) public static byte[] PerformRead(SMB1Header header, ISMBShare share, ushort FID, ulong offset, uint maxCount, StateObject state)
{ {
if (offset > Int64.MaxValue || maxCount > Int32.MaxValue) if (offset > Int64.MaxValue || maxCount > Int32.MaxValue)
{ {
@ -63,7 +63,7 @@ namespace SMBLibrary.Server
return PerformRead(header, share, FID, (long)offset, (int)maxCount, state); return PerformRead(header, share, FID, (long)offset, (int)maxCount, state);
} }
public static byte[] PerformRead(SMBHeader header, ISMBShare share, ushort FID, long offset, int maxCount, StateObject state) public static byte[] PerformRead(SMB1Header header, ISMBShare share, ushort FID, long offset, int maxCount, StateObject state)
{ {
OpenedFileObject openedFile = state.GetOpenedFileObject(FID); OpenedFileObject openedFile = state.GetOpenedFileObject(FID);
if (openedFile == null) if (openedFile == null)
@ -134,7 +134,7 @@ namespace SMBLibrary.Server
} }
} }
internal static SMB1Command GetWriteResponse(SMBHeader header, WriteRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetWriteResponse(SMB1Header header, WriteRequest request, ISMBShare share, StateObject state)
{ {
ushort bytesWritten = (ushort)PerformWrite(header, share, request.FID, request.WriteOffsetInBytes, request.Data, state); ushort bytesWritten = (ushort)PerformWrite(header, share, request.FID, request.WriteOffsetInBytes, request.Data, state);
if (header.Status != NTStatus.STATUS_SUCCESS) if (header.Status != NTStatus.STATUS_SUCCESS)
@ -147,7 +147,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static SMB1Command GetWriteResponse(SMBHeader header, WriteAndXRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetWriteResponse(SMB1Header header, WriteAndXRequest request, ISMBShare share, StateObject state)
{ {
uint bytesWritten = PerformWrite(header, share, request.FID, request.Offset, request.Data, state); uint bytesWritten = PerformWrite(header, share, request.FID, request.Offset, request.Data, state);
if (header.Status != NTStatus.STATUS_SUCCESS) if (header.Status != NTStatus.STATUS_SUCCESS)
@ -165,7 +165,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
public static uint PerformWrite(SMBHeader header, ISMBShare share, ushort FID, ulong offset, byte[] data, StateObject state) public static uint PerformWrite(SMB1Header header, ISMBShare share, ushort FID, ulong offset, byte[] data, StateObject state)
{ {
OpenedFileObject openedFile = state.GetOpenedFileObject(FID); OpenedFileObject openedFile = state.GetOpenedFileObject(FID);
if (openedFile == null) if (openedFile == null)

View file

@ -15,7 +15,7 @@ namespace SMBLibrary.Server
{ {
public partial class ServerResponseHelper public partial class ServerResponseHelper
{ {
internal static SMB1Command GetCloseResponse(SMBHeader header, CloseRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetCloseResponse(SMB1Header header, CloseRequest request, ISMBShare share, StateObject state)
{ {
OpenedFileObject openedFile = state.GetOpenedFileObject(request.FID); OpenedFileObject openedFile = state.GetOpenedFileObject(request.FID);
if (openedFile == null) if (openedFile == null)
@ -40,7 +40,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static SMB1Command GetFindClose2Request(SMBHeader header, FindClose2Request request, StateObject state) internal static SMB1Command GetFindClose2Request(SMB1Header header, FindClose2Request request, StateObject state)
{ {
state.ReleaseSearchHandle(request.SearchHandle); state.ReleaseSearchHandle(request.SearchHandle);
return new FindClose2Response(); return new FindClose2Response();

View file

@ -20,7 +20,7 @@ namespace SMBLibrary.Server
public const bool IncludeCurrentDirectoryInResults = true; public const bool IncludeCurrentDirectoryInResults = true;
public const bool IncludeParentDirectoryInResults = true; public const bool IncludeParentDirectoryInResults = true;
internal static Transaction2FindFirst2Response GetSubcommandResponse(SMBHeader header, Transaction2FindFirst2Request subcommand, FileSystemShare share, StateObject state) internal static Transaction2FindFirst2Response GetSubcommandResponse(SMB1Header header, Transaction2FindFirst2Request subcommand, FileSystemShare share, StateObject state)
{ {
IFileSystem fileSystem = share.FileSystem; IFileSystem fileSystem = share.FileSystem;
string path = subcommand.FileName; string path = subcommand.FileName;
@ -193,7 +193,7 @@ namespace SMBLibrary.Server
return result; return result;
} }
internal static Transaction2FindNext2Response GetSubcommandResponse(SMBHeader header, Transaction2FindNext2Request subcommand, FileSystemShare share, StateObject state) internal static Transaction2FindNext2Response GetSubcommandResponse(SMB1Header header, Transaction2FindNext2Request subcommand, FileSystemShare share, StateObject state)
{ {
if (!state.OpenSearches.ContainsKey(subcommand.SID)) if (!state.OpenSearches.ContainsKey(subcommand.SID))
{ {
@ -227,7 +227,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static Transaction2QueryFSInformationResponse GetSubcommandResponse(SMBHeader header, Transaction2QueryFSInformationRequest subcommand, FileSystemShare share) internal static Transaction2QueryFSInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryFSInformationRequest subcommand, FileSystemShare share)
{ {
Transaction2QueryFSInformationResponse response = new Transaction2QueryFSInformationResponse(); Transaction2QueryFSInformationResponse response = new Transaction2QueryFSInformationResponse();
QueryFSInformation queryFSInformation = InfoHelper.GetFSInformation(subcommand.InformationLevel, share.FileSystem); QueryFSInformation queryFSInformation = InfoHelper.GetFSInformation(subcommand.InformationLevel, share.FileSystem);
@ -235,7 +235,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static Transaction2QueryPathInformationResponse GetSubcommandResponse(SMBHeader header, Transaction2QueryPathInformationRequest subcommand, FileSystemShare share) internal static Transaction2QueryPathInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryPathInformationRequest subcommand, FileSystemShare share)
{ {
IFileSystem fileSystem = share.FileSystem; IFileSystem fileSystem = share.FileSystem;
string path = subcommand.FileName; string path = subcommand.FileName;
@ -255,7 +255,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static Transaction2QueryFileInformationResponse GetSubcommandResponse(SMBHeader header, Transaction2QueryFileInformationRequest subcommand, FileSystemShare share, StateObject state) internal static Transaction2QueryFileInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryFileInformationRequest subcommand, FileSystemShare share, StateObject state)
{ {
IFileSystem fileSystem = share.FileSystem; IFileSystem fileSystem = share.FileSystem;
string openedFilePath = state.GetOpenedFilePath(subcommand.FID); string openedFilePath = state.GetOpenedFilePath(subcommand.FID);
@ -278,7 +278,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static Transaction2SetFileInformationResponse GetSubcommandResponse(SMBHeader header, Transaction2SetFileInformationRequest subcommand, FileSystemShare share, StateObject state) internal static Transaction2SetFileInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2SetFileInformationRequest subcommand, FileSystemShare share, StateObject state)
{ {
string openedFilePath = state.GetOpenedFilePath(subcommand.FID); string openedFilePath = state.GetOpenedFilePath(subcommand.FID);
if (openedFilePath == null) if (openedFilePath == null)

View file

@ -21,7 +21,7 @@ namespace SMBLibrary.Server
/// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request. /// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request.
/// The server MUST respond to the transaction request as a whole. /// The server MUST respond to the transaction request as a whole.
/// </summary> /// </summary>
internal static SMB1Command GetTransactionResponse(SMBHeader header, TransactionRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue) internal static SMB1Command GetTransactionResponse(SMB1Header header, TransactionRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
{ {
ProcessStateObject processState = state.ObtainProcessState(header.PID); ProcessStateObject processState = state.ObtainProcessState(header.PID);
processState.MaxDataCount = request.MaxDataCount; processState.MaxDataCount = request.MaxDataCount;
@ -58,7 +58,7 @@ namespace SMBLibrary.Server
/// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request. /// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request.
/// The server MUST respond to the transaction request as a whole. /// The server MUST respond to the transaction request as a whole.
/// </summary> /// </summary>
internal static SMB1Command GetTransactionResponse(SMBHeader header, TransactionSecondaryRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue) internal static SMB1Command GetTransactionResponse(SMB1Header header, TransactionSecondaryRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
{ {
ProcessStateObject processState = state.GetProcessState(header.PID); ProcessStateObject processState = state.GetProcessState(header.PID);
if (processState == null) if (processState == null)
@ -89,7 +89,7 @@ namespace SMBLibrary.Server
} }
} }
internal static SMB1Command GetCompleteTransactionResponse(SMBHeader header, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List<SMB1Command> sendQueue) internal static SMB1Command GetCompleteTransactionResponse(SMB1Header header, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
{ {
TransactionSubcommand subcommand = TransactionSubcommand.GetSubcommandRequest(requestSetup, requestParameters, requestData, header.UnicodeFlag); TransactionSubcommand subcommand = TransactionSubcommand.GetSubcommandRequest(requestSetup, requestParameters, requestData, header.UnicodeFlag);
TransactionSubcommand subcommandResponse = null; TransactionSubcommand subcommandResponse = null;
@ -162,7 +162,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static SMB1Command GetCompleteTransaction2Response(SMBHeader header, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List<SMB1Command> sendQueue) internal static SMB1Command GetCompleteTransaction2Response(SMB1Header header, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
{ {
Transaction2Subcommand subcommand = Transaction2Subcommand.GetSubcommandRequest(requestSetup, requestParameters, requestData, header.UnicodeFlag); Transaction2Subcommand subcommand = Transaction2Subcommand.GetSubcommandRequest(requestSetup, requestParameters, requestData, header.UnicodeFlag);
Transaction2Subcommand subcommandResponse = null; Transaction2Subcommand subcommandResponse = null;

View file

@ -16,7 +16,7 @@ namespace SMBLibrary.Server
{ {
public class TransactionSubcommandHelper public class TransactionSubcommandHelper
{ {
internal static TransactionTransactNamedPipeResponse GetSubcommandResponse(SMBHeader header, TransactionTransactNamedPipeRequest subcommand, NamedPipeShare share, StateObject state) internal static TransactionTransactNamedPipeResponse GetSubcommandResponse(SMB1Header header, TransactionTransactNamedPipeRequest subcommand, NamedPipeShare share, StateObject state)
{ {
string openedFilePath = state.GetOpenedFilePath(subcommand.FID); string openedFilePath = state.GetOpenedFilePath(subcommand.FID);
if (openedFilePath == null) if (openedFilePath == null)

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.Server
{ {
public class TreeConnectHelper public class TreeConnectHelper
{ {
internal static SMB1Command GetTreeConnectResponse(SMBHeader header, TreeConnectAndXRequest request, StateObject state, ShareCollection shares) internal static SMB1Command GetTreeConnectResponse(SMB1Header header, TreeConnectAndXRequest request, StateObject state, ShareCollection shares)
{ {
bool isExtended = (request.Flags & TreeConnectFlags.ExtendedResponse) > 0; bool isExtended = (request.Flags & TreeConnectFlags.ExtendedResponse) > 0;
string relativePath = ServerPathUtils.GetRelativeServerPath(request.Path); string relativePath = ServerPathUtils.GetRelativeServerPath(request.Path);
@ -89,7 +89,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static SMB1Command GetTreeDisconnectResponse(SMBHeader header, TreeDisconnectRequest request, StateObject state) internal static SMB1Command GetTreeDisconnectResponse(SMB1Header header, TreeDisconnectRequest request, StateObject state)
{ {
if (!state.IsTreeConnected(header.TID)) if (!state.IsTreeConnected(header.TID))
{ {

View file

@ -261,7 +261,7 @@ namespace SMBLibrary.Server
/// <summary> /// <summary>
/// May return null /// May return null
/// </summary> /// </summary>
public SMB1Command ProcessCommand(SMBHeader header, SMB1Command command, StateObject state, List<SMB1Command> sendQueue) public SMB1Command ProcessCommand(SMB1Header header, SMB1Command command, StateObject state, List<SMB1Command> sendQueue)
{ {
if (command is NegotiateRequest) if (command is NegotiateRequest)
{ {