Renamed SMBCommand to SMB1Command

This commit is contained in:
Tal Aloni 2017-01-10 11:02:20 +02:00
parent f340094946
commit 8b7d8b289b
60 changed files with 93 additions and 93 deletions

View file

@ -38,7 +38,7 @@ namespace SMBLibrary.Client
TrySendMessage(serverSocket, request); TrySendMessage(serverSocket, request);
} }
public static void TrySendMessage(Socket serverSocket, SMBCommand request) public static void TrySendMessage(Socket serverSocket, SMB1Command request)
{ {
SMBMessage message = new SMBMessage(); SMBMessage message = new SMBMessage();
message.Commands.Add(request); message.Commands.Add(request);

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_CHECK_DIRECTORY Request /// SMB_COM_CHECK_DIRECTORY Request
/// </summary> /// </summary>
public class CheckDirectoryRequest : SMBCommand public class CheckDirectoryRequest : SMB1Command
{ {
public const byte SupportedBufferFormat = 0x04; public const byte SupportedBufferFormat = 0x04;
// Data: // Data:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_CHECK_DIRECTORY Response /// SMB_COM_CHECK_DIRECTORY Response
/// </summary> /// </summary>
public class CheckDirectoryResponse : SMBCommand public class CheckDirectoryResponse : SMB1Command
{ {
public CheckDirectoryResponse() : base() public CheckDirectoryResponse() : base()
{ {

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_CLOSE Request /// SMB_COM_CLOSE Request
/// </summary> /// </summary>
public class CloseRequest : SMBCommand public class CloseRequest : SMB1Command
{ {
public const int ParametersLength = 6; public const int ParametersLength = 6;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_CLOSE Response /// SMB_COM_CLOSE Response
/// </summary> /// </summary>
public class CloseResponse : SMBCommand public class CloseResponse : SMB1Command
{ {
public CloseResponse() : base() public CloseResponse() : base()
{} {}

View file

@ -16,7 +16,7 @@ namespace SMBLibrary.SMB1
/// This command is obsolete. /// This command is obsolete.
/// This command is used by Windows NT4 SP6. /// This command is used by Windows NT4 SP6.
/// </summary> /// </summary>
public class CreateDirectoryRequest : SMBCommand public class CreateDirectoryRequest : SMB1Command
{ {
public const byte SupportedBufferFormat = 0x04; public const byte SupportedBufferFormat = 0x04;
// Data: // Data:

View file

@ -16,7 +16,7 @@ namespace SMBLibrary.SMB1
/// This command is obsolete. /// This command is obsolete.
/// This command is used by Windows NT4 SP6. /// This command is used by Windows NT4 SP6.
/// </summary> /// </summary>
public class CreateDirectoryResponse : SMBCommand public class CreateDirectoryResponse : SMB1Command
{ {
public CreateDirectoryResponse() : base() public CreateDirectoryResponse() : base()
{ {

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_DELETE_DIRECTORY Request /// SMB_COM_DELETE_DIRECTORY Request
/// </summary> /// </summary>
public class DeleteDirectoryRequest : SMBCommand public class DeleteDirectoryRequest : SMB1Command
{ {
public const int SupportedBufferFormat = 0x04; public const int SupportedBufferFormat = 0x04;
// Data: // Data:

View file

@ -13,7 +13,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_DELETE_DIRECTORY Response /// SMB_COM_DELETE_DIRECTORY Response
/// </summary> /// </summary>
public class DeleteDirectoryResponse : SMBCommand public class DeleteDirectoryResponse : SMB1Command
{ {
public DeleteDirectoryResponse() : base() public DeleteDirectoryResponse() : base()
{ {

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_DELETE Request /// SMB_COM_DELETE Request
/// </summary> /// </summary>
public class DeleteRequest : SMBCommand public class DeleteRequest : SMB1Command
{ {
public const int SupportedBufferFormat = 0x04; public const int SupportedBufferFormat = 0x04;
public const int ParametersLength = 2; public const int ParametersLength = 2;

View file

@ -13,7 +13,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_DELETE Response /// SMB_COM_DELETE Response
/// </summary> /// </summary>
public class DeleteResponse : SMBCommand public class DeleteResponse : SMB1Command
{ {
public DeleteResponse() : base() public DeleteResponse() : base()
{ {

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_ECHO /// SMB_COM_ECHO
/// </summary> /// </summary>
public class EchoRequest : SMBCommand public class EchoRequest : SMB1Command
{ {
public const int ParametersLength = 1; public const int ParametersLength = 1;
// Parameters // Parameters

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_ECHO /// SMB_COM_ECHO
/// </summary> /// </summary>
public class EchoResponse : SMBCommand public class EchoResponse : SMB1Command
{ {
public const int ParametersLength = 2; public const int ParametersLength = 2;
// Parameters // Parameters

View file

@ -15,7 +15,7 @@ namespace SMBLibrary.SMB1
/// The Command trailer of an error response message. /// The Command trailer of an error response message.
/// See [MS-CIFS]3.3.4.1.2 - Sending Any Error Response Message. /// See [MS-CIFS]3.3.4.1.2 - Sending Any Error Response Message.
/// </summary> /// </summary>
public class ErrorResponse : SMBCommand public class ErrorResponse : SMB1Command
{ {
private CommandName m_commandName; private CommandName m_commandName;

View file

@ -8,7 +8,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_FIND_CLOSE2 Request /// SMB_COM_FIND_CLOSE2 Request
/// </summary> /// </summary>
public class FindClose2Request : SMBCommand public class FindClose2Request : SMB1Command
{ {
public const int ParameterCount = 2; public const int ParameterCount = 2;
// Parameters: // Parameters:

View file

@ -8,7 +8,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_FIND_CLOSE2 Response /// SMB_COM_FIND_CLOSE2 Response
/// </summary> /// </summary>
public class FindClose2Response : SMBCommand public class FindClose2Response : SMB1Command
{ {
public FindClose2Response() : base() public FindClose2Response() : base()
{ {

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_FLUSH Request /// SMB_COM_FLUSH Request
/// </summary> /// </summary>
public class FlushRequest : SMBCommand public class FlushRequest : SMB1Command
{ {
public const int ParametersLength = 2; public const int ParametersLength = 2;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_FLUSH Response /// SMB_COM_FLUSH Response
/// </summary> /// </summary>
public class FlushResponse : SMBCommand public class FlushResponse : SMB1Command
{ {
public FlushResponse() : base() public FlushResponse() : base()
{ {

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_NT_TRANSACT Interim Response /// SMB_COM_NT_TRANSACT Interim Response
/// </summary> /// </summary>
public class NTTransactInterimResponse : SMBCommand public class NTTransactInterimResponse : SMB1Command
{ {
public const int ParametersLength = 0; public const int ParametersLength = 0;

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_NT_TRANSACT Request /// SMB_COM_NT_TRANSACT Request
/// </summary> /// </summary>
public class NTTransactRequest : SMBCommand public class NTTransactRequest : SMB1Command
{ {
public const int FixedSMBParametersLength = 38; public const int FixedSMBParametersLength = 38;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_NT_TRANSACT Response /// SMB_COM_NT_TRANSACT Response
/// </summary> /// </summary>
public class NTTransactResponse : SMBCommand public class NTTransactResponse : SMB1Command
{ {
public const int FixedSMBParametersLength = 36; public const int FixedSMBParametersLength = 36;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_NT_TRANSACT_SECONDARY Request /// SMB_COM_NT_TRANSACT_SECONDARY Request
/// </summary> /// </summary>
public class NTTransactSecondaryRequest : SMBCommand public class NTTransactSecondaryRequest : SMB1Command
{ {
public const int SMBParametersLength = 36; public const int SMBParametersLength = 36;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_NEGOTIATE Request /// SMB_COM_NEGOTIATE Request
/// </summary> /// </summary>
public class NegotiateRequest : SMBCommand public class NegotiateRequest : SMB1Command
{ {
public const int SupportedBufferFormat = 0x02; public const int SupportedBufferFormat = 0x02;
// Data: // Data:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_NEGOTIATE Response, NT LAN Manager dialect /// SMB_COM_NEGOTIATE Response, NT LAN Manager dialect
/// </summary> /// </summary>
public class NegotiateResponseNTLM : SMBCommand public class NegotiateResponseNTLM : SMB1Command
{ {
public const int ParametersLength = 34; public const int ParametersLength = 34;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_NEGOTIATE Response, NT LAN Manager dialect, Extended Security response /// SMB_COM_NEGOTIATE Response, NT LAN Manager dialect, Extended Security response
/// </summary> /// </summary>
public class NegotiateResponseNTLMExtended : SMBCommand public class NegotiateResponseNTLMExtended : SMB1Command
{ {
public const int ParametersLength = 34; public const int ParametersLength = 34;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_NEGOTIATE Response /// SMB_COM_NEGOTIATE Response
/// </summary> /// </summary>
public class NegotiateResponseNotSupported : SMBCommand public class NegotiateResponseNotSupported : SMB1Command
{ {
public const int ParametersLength = 2; public const int ParametersLength = 2;
public const ushort DialectsNotSupported = 0xFFFF; public const ushort DialectsNotSupported = 0xFFFF;

View file

@ -16,7 +16,7 @@ namespace SMBLibrary.SMB1
/// This command is deprecated. /// This command is deprecated.
/// This command is used by Windows NT4 SP6. /// This command is used by Windows NT4 SP6.
/// </summary> /// </summary>
public class QueryInformationRequest : SMBCommand public class QueryInformationRequest : SMB1Command
{ {
public const byte SupportedBufferFormat = 0x04; public const byte SupportedBufferFormat = 0x04;
// Data: // Data:

View file

@ -16,7 +16,7 @@ namespace SMBLibrary.SMB1
/// This command is deprecated. /// This command is deprecated.
/// This command is used by Windows NT4 SP6. /// This command is used by Windows NT4 SP6.
/// </summary> /// </summary>
public class QueryInformationResponse : SMBCommand public class QueryInformationResponse : SMB1Command
{ {
public const int ParameterLength = 20; public const int ParameterLength = 20;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_READ Request /// SMB_COM_READ Request
/// </summary> /// </summary>
public class ReadRequest : SMBCommand public class ReadRequest : SMB1Command
{ {
public const int ParametersLength = 10; public const int ParametersLength = 10;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_READ Response /// SMB_COM_READ Response
/// </summary> /// </summary>
public class ReadResponse : SMBCommand public class ReadResponse : SMB1Command
{ {
public const int ParametersLength = 10; public const int ParametersLength = 10;
public const int SupportedBufferFormat = 0x01; public const int SupportedBufferFormat = 0x01;

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_RENAME Request /// SMB_COM_RENAME Request
/// </summary> /// </summary>
public class RenameRequest : SMBCommand public class RenameRequest : SMB1Command
{ {
public const int SupportedBufferFormat = 0x04; public const int SupportedBufferFormat = 0x04;
public const int ParametersLength = 2; public const int ParametersLength = 2;

View file

@ -13,7 +13,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_RENAME Response /// SMB_COM_RENAME Response
/// </summary> /// </summary>
public class RenameResponse : SMBCommand public class RenameResponse : SMB1Command
{ {
public RenameResponse() : base() public RenameResponse() : base()
{ {

View file

@ -11,18 +11,18 @@ using Utilities;
namespace SMBLibrary.SMB1 namespace SMBLibrary.SMB1
{ {
public abstract class SMBCommand public abstract class SMB1Command
{ {
public byte[] SMBParameters; // SMB_Parameters public byte[] SMBParameters; // SMB_Parameters
public byte[] SMBData; // SMB_Data public byte[] SMBData; // SMB_Data
public SMBCommand() public SMB1Command()
{ {
SMBParameters = new byte[0]; SMBParameters = new byte[0];
SMBData = new byte[0]; SMBData = new byte[0];
} }
public SMBCommand(byte[] buffer, int offset, bool isUnicode) public SMB1Command(byte[] buffer, int offset, bool isUnicode)
{ {
byte wordCount = ByteReader.ReadByte(buffer, ref offset); byte wordCount = ByteReader.ReadByte(buffer, ref offset);
SMBParameters = ByteReader.ReadBytes(buffer, ref offset, wordCount * 2); SMBParameters = ByteReader.ReadBytes(buffer, ref offset, wordCount * 2);
@ -63,7 +63,7 @@ namespace SMBLibrary.SMB1
return buffer; return buffer;
} }
public static SMBCommand ReadCommand(byte[] buffer, int offset, CommandName commandName, SMBHeader header) public static SMB1Command ReadCommand(byte[] buffer, int offset, CommandName commandName, SMBHeader header)
{ {
if ((header.Flags & HeaderFlags.Reply) > 0) if ((header.Flags & HeaderFlags.Reply) > 0)
{ {
@ -75,7 +75,7 @@ namespace SMBLibrary.SMB1
} }
} }
public static SMBCommand ReadCommandRequest(byte[] buffer, int offset, CommandName commandName, bool isUnicode) public static SMB1Command ReadCommandRequest(byte[] buffer, int offset, CommandName commandName, bool isUnicode)
{ {
switch (commandName) switch (commandName)
{ {
@ -160,7 +160,7 @@ namespace SMBLibrary.SMB1
} }
} }
public static SMBCommand ReadCommandResponse(byte[] buffer, int offset, CommandName commandName, bool isUnicode) public static SMB1Command ReadCommandResponse(byte[] buffer, int offset, CommandName commandName, bool isUnicode)
{ {
byte wordCount = ByteReader.ReadByte(buffer, offset); byte wordCount = ByteReader.ReadByte(buffer, offset);
switch (commandName) switch (commandName)

View file

@ -11,7 +11,7 @@ using Utilities;
namespace SMBLibrary.SMB1 namespace SMBLibrary.SMB1
{ {
public abstract class SMBAndXCommand : SMBCommand public abstract class SMBAndXCommand : SMB1Command
{ {
public CommandName AndXCommand; public CommandName AndXCommand;
public byte AndXReserved; public byte AndXReserved;

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_SET_INFORMATION2 Request /// SMB_COM_SET_INFORMATION2 Request
/// </summary> /// </summary>
public class SetInformation2Request : SMBCommand public class SetInformation2Request : SMB1Command
{ {
public const int ParametersLength = 14; public const int ParametersLength = 14;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_SET_INFORMATION2 Response /// SMB_COM_SET_INFORMATION2 Response
/// </summary> /// </summary>
public class SetInformation2Response : SMBCommand public class SetInformation2Response : SMB1Command
{ {
public SetInformation2Response() : base() public SetInformation2Response() : base()
{ {

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_SET_INFORMATION Request /// SMB_COM_SET_INFORMATION Request
/// </summary> /// </summary>
public class SetInformationRequest : SMBCommand public class SetInformationRequest : SMB1Command
{ {
public const int ParametersLength = 16; public const int ParametersLength = 16;
public const int SupportedBufferFormat = 0x04; public const int SupportedBufferFormat = 0x04;

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_SET_INFORMATION Response /// SMB_COM_SET_INFORMATION Response
/// </summary> /// </summary>
public class SetInformationResponse : SMBCommand public class SetInformationResponse : SMB1Command
{ {
public SetInformationResponse() : base() public SetInformationResponse() : base()
{ {

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_TRANSACTION Request /// SMB_COM_TRANSACTION Request
/// </summary> /// </summary>
public class TransactionRequest : SMBCommand public class TransactionRequest : SMB1Command
{ {
public const int FixedSMBParametersLength = 28; public const int FixedSMBParametersLength = 28;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_TRANSACTION Response /// SMB_COM_TRANSACTION Response
/// </summary> /// </summary>
public class TransactionResponse : SMBCommand public class TransactionResponse : SMB1Command
{ {
public const int FixedSMBParametersLength = 20; public const int FixedSMBParametersLength = 20;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_TRANSACTION_SECONDARY Request /// SMB_COM_TRANSACTION_SECONDARY Request
/// </summary> /// </summary>
public class TransactionSecondaryRequest : SMBCommand public class TransactionSecondaryRequest : SMB1Command
{ {
public const int SMBParametersLength = 16; public const int SMBParametersLength = 16;
// Parameters: // Parameters:

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_TREE_DISCONNECT Request /// SMB_COM_TREE_DISCONNECT Request
/// </summary> /// </summary>
public class TreeDisconnectRequest : SMBCommand public class TreeDisconnectRequest : SMB1Command
{ {
public TreeDisconnectRequest() : base() public TreeDisconnectRequest() : base()
{ {

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_TREE_DISCONNECT Response /// SMB_COM_TREE_DISCONNECT Response
/// </summary> /// </summary>
public class TreeDisconnectResponse : SMBCommand public class TreeDisconnectResponse : SMB1Command
{ {
public TreeDisconnectResponse() : base() public TreeDisconnectResponse() : base()
{ {

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_WRITE_RAW Final Response /// SMB_COM_WRITE_RAW Final Response
/// </summary> /// </summary>
public class WriteRawFinalResponse : SMBCommand public class WriteRawFinalResponse : SMB1Command
{ {
public ushort ParametersLength = 2; public ushort ParametersLength = 2;
// Parameters; // Parameters;

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_WRITE_RAW Interim Response /// SMB_COM_WRITE_RAW Interim Response
/// </summary> /// </summary>
public class WriteRawInterimResponse : SMBCommand public class WriteRawInterimResponse : SMB1Command
{ {
public ushort ParametersLength = 2; public ushort ParametersLength = 2;
// Parameters; // Parameters;

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
/// <summary> /// <summary>
/// SMB_COM_WRITE_RAW Request /// SMB_COM_WRITE_RAW Request
/// </summary> /// </summary>
public class WriteRawRequest : SMBCommand public class WriteRawRequest : SMB1Command
{ {
public const int ParametersFixedLength = 24; // + 4 optional bytes public const int ParametersFixedLength = 24; // + 4 optional bytes
// Parameters: // Parameters:

View file

@ -16,7 +16,7 @@ namespace SMBLibrary.SMB1
/// This command is obsolete. /// This command is obsolete.
/// Windows NT4 SP6 will send this command with empty data for some reason. /// Windows NT4 SP6 will send this command with empty data for some reason.
/// </summary> /// </summary>
public class WriteRequest : SMBCommand public class WriteRequest : SMB1Command
{ {
public const int ParametersLength = 8; public const int ParametersLength = 8;
public const int SupportedBufferFormat = 0x01; public const int SupportedBufferFormat = 0x01;

View file

@ -10,7 +10,7 @@ namespace SMBLibrary.SMB1
/// This command is obsolete. /// This command is obsolete.
/// Windows NT4 SP6 will send this command with empty data for some reason. /// Windows NT4 SP6 will send this command with empty data for some reason.
/// </summary> /// </summary>
public class WriteResponse : SMBCommand public class WriteResponse : SMB1Command
{ {
public const int ParametersLength = 2; public const int ParametersLength = 2;
// Parameters: // Parameters:

View file

@ -19,7 +19,7 @@ namespace SMBLibrary.SMB1
public class SMBMessage public class SMBMessage
{ {
public SMBHeader Header; public SMBHeader Header;
public List<SMBCommand> Commands = new List<SMBCommand>(); public List<SMB1Command> Commands = new List<SMB1Command>();
public SMBMessage() public SMBMessage()
{ {
@ -29,7 +29,7 @@ namespace SMBLibrary.SMB1
public SMBMessage(byte[] buffer) public SMBMessage(byte[] buffer)
{ {
Header = new SMBHeader(buffer); Header = new SMBHeader(buffer);
SMBCommand command = SMBCommand.ReadCommand(buffer, SMBHeader.Length, Header.Command, Header); SMB1Command command = SMB1Command.ReadCommand(buffer, SMBHeader.Length, Header.Command, Header);
Commands.Add(command); Commands.Add(command);
while(command is SMBAndXCommand) while(command is SMBAndXCommand)
{ {
@ -38,7 +38,7 @@ namespace SMBLibrary.SMB1
{ {
break; break;
} }
command = SMBCommand.ReadCommand(buffer, andXCommand.AndXOffset, andXCommand.AndXCommand, Header); command = SMB1Command.ReadCommand(buffer, andXCommand.AndXOffset, andXCommand.AndXCommand, Header);
Commands.Add(command); Commands.Add(command);
} }
} }
@ -58,7 +58,7 @@ namespace SMBLibrary.SMB1
} }
} }
SMBCommand lastCommand = Commands[Commands.Count - 1]; SMB1Command lastCommand = Commands[Commands.Count - 1];
if (lastCommand is SMBAndXCommand) if (lastCommand is SMBAndXCommand)
{ {
((SMBAndXCommand)lastCommand).AndXCommand = CommandName.SMB_COM_NO_ANDX_COMMAND; ((SMBAndXCommand)lastCommand).AndXCommand = CommandName.SMB_COM_NO_ANDX_COMMAND;

View file

@ -217,8 +217,8 @@
<Compile Include="SMB1\Commands\SetInformation2Response.cs" /> <Compile Include="SMB1\Commands\SetInformation2Response.cs" />
<Compile Include="SMB1\Commands\SetInformationRequest.cs" /> <Compile Include="SMB1\Commands\SetInformationRequest.cs" />
<Compile Include="SMB1\Commands\SetInformationResponse.cs" /> <Compile Include="SMB1\Commands\SetInformationResponse.cs" />
<Compile Include="SMB1\Commands\SMB1Command.cs" />
<Compile Include="SMB1\Commands\SMBAndXCommand.cs" /> <Compile Include="SMB1\Commands\SMBAndXCommand.cs" />
<Compile Include="SMB1\Commands\SMBCommand.cs" />
<Compile Include="SMB1\Commands\Transaction2Request.cs" /> <Compile Include="SMB1\Commands\Transaction2Request.cs" />
<Compile Include="SMB1\Commands\Transaction2Response.cs" /> <Compile Include="SMB1\Commands\Transaction2Response.cs" />
<Compile Include="SMB1\Commands\Transaction2SecondaryRequest.cs" /> <Compile Include="SMB1\Commands\Transaction2SecondaryRequest.cs" />

View file

@ -15,7 +15,7 @@ namespace SMBLibrary.Server
{ {
public class FileSystemResponseHelper public class FileSystemResponseHelper
{ {
internal static SMBCommand GetCreateDirectoryResponse(SMBHeader header, CreateDirectoryRequest request, FileSystemShare share, StateObject state) internal static SMB1Command GetCreateDirectoryResponse(SMBHeader 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 SMBCommand GetDeleteDirectoryResponse(SMBHeader header, DeleteDirectoryRequest request, FileSystemShare share, StateObject state) internal static SMB1Command GetDeleteDirectoryResponse(SMBHeader 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 SMBCommand GetCheckDirectoryResponse(SMBHeader header, CheckDirectoryRequest request, FileSystemShare share) internal static SMB1Command GetCheckDirectoryResponse(SMBHeader 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 SMBCommand GetDeleteResponse(SMBHeader header, DeleteRequest request, FileSystemShare share, StateObject state) internal static SMB1Command GetDeleteResponse(SMBHeader 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 SMBCommand GetRenameResponse(SMBHeader header, RenameRequest request, FileSystemShare share, StateObject state) internal static SMB1Command GetRenameResponse(SMBHeader 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 SMBCommand GetQueryInformationResponse(SMBHeader header, QueryInformationRequest request, FileSystemShare share) internal static SMB1Command GetQueryInformationResponse(SMBHeader 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 SMBCommand GetSetInformationResponse(SMBHeader header, SetInformationRequest request, FileSystemShare share, StateObject state) internal static SMB1Command GetSetInformationResponse(SMBHeader 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 SMBCommand GetSetInformation2Response(SMBHeader header, SetInformation2Request request, FileSystemShare share, StateObject state) internal static SMB1Command GetSetInformation2Response(SMBHeader 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 SMBCommand GetNTCreateResponse(SMBHeader header, NTCreateAndXRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetNTCreateResponse(SMBHeader 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 SMBCommand GetNTTransactResponse(SMBHeader header, NTTransactRequest request, ISMBShare share, StateObject state, List<SMBCommand> sendQueue) internal static SMB1Command GetNTTransactResponse(SMBHeader 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 SMBCommand GetNTTransactResponse(SMBHeader header, NTTransactSecondaryRequest request, ISMBShare share, StateObject state, List<SMBCommand> sendQueue) internal static SMB1Command GetNTTransactResponse(SMBHeader 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 SMBCommand GetCompleteNTTransactResponse(SMBHeader header, NTTransactSubcommandName subcommandName, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List<SMBCommand> sendQueue) internal static SMB1Command GetCompleteNTTransactResponse(SMBHeader 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;
@ -140,7 +140,7 @@ namespace SMBLibrary.Server
} }
} }
private static void PrepareResponse(NTTransactResponse response, byte[] responseSetup, byte[] responseParameters, byte[] responseData, int maxBufferSize, List<SMBCommand> sendQueue) private static void PrepareResponse(NTTransactResponse response, byte[] responseSetup, byte[] responseParameters, byte[] responseData, int maxBufferSize, List<SMB1Command> sendQueue)
{ {
if (NTTransactResponse.CalculateMessageSize(responseSetup.Length, responseParameters.Length, responseData.Length) <= maxBufferSize) if (NTTransactResponse.CalculateMessageSize(responseSetup.Length, responseParameters.Length, responseData.Length) <= maxBufferSize)
{ {

View file

@ -68,7 +68,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static SMBCommand GetSessionSetupResponse(SMBHeader header, SessionSetupAndXRequest request, INTLMAuthenticationProvider users, StateObject state) internal static SMB1Command GetSessionSetupResponse(SMBHeader 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 SMBCommand GetSessionSetupResponseExtended(SMBHeader header, SessionSetupAndXRequestExtended request, INTLMAuthenticationProvider users, StateObject state) internal static SMB1Command GetSessionSetupResponseExtended(SMBHeader 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 SMBCommand GetOpenAndXResponse(SMBHeader header, OpenAndXRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetOpenAndXResponse(SMBHeader 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 SMBCommand GetReadResponse(SMBHeader header, ReadRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetReadResponse(SMBHeader 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 SMBCommand GetReadResponse(SMBHeader header, ReadAndXRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetReadResponse(SMBHeader 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)
@ -134,7 +134,7 @@ namespace SMBLibrary.Server
} }
} }
internal static SMBCommand GetWriteResponse(SMBHeader header, WriteRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetWriteResponse(SMBHeader 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 SMBCommand GetWriteResponse(SMBHeader header, WriteAndXRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetWriteResponse(SMBHeader 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)

View file

@ -15,7 +15,7 @@ namespace SMBLibrary.Server
{ {
public partial class ServerResponseHelper public partial class ServerResponseHelper
{ {
internal static SMBCommand GetCloseResponse(SMBHeader header, CloseRequest request, ISMBShare share, StateObject state) internal static SMB1Command GetCloseResponse(SMBHeader 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,13 +40,13 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static SMBCommand GetFindClose2Request(SMBHeader header, FindClose2Request request, StateObject state) internal static SMB1Command GetFindClose2Request(SMBHeader header, FindClose2Request request, StateObject state)
{ {
state.ReleaseSearchHandle(request.SearchHandle); state.ReleaseSearchHandle(request.SearchHandle);
return new FindClose2Response(); return new FindClose2Response();
} }
internal static EchoResponse GetEchoResponse(EchoRequest request, List<SMBCommand> sendQueue) internal static EchoResponse GetEchoResponse(EchoRequest request, List<SMB1Command> sendQueue)
{ {
EchoResponse response = new EchoResponse(); EchoResponse response = new EchoResponse();
response.SequenceNumber = 0; response.SequenceNumber = 0;

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 SMBCommand GetTransactionResponse(SMBHeader header, TransactionRequest request, ISMBShare share, StateObject state, List<SMBCommand> sendQueue) internal static SMB1Command GetTransactionResponse(SMBHeader 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 SMBCommand GetTransactionResponse(SMBHeader header, TransactionSecondaryRequest request, ISMBShare share, StateObject state, List<SMBCommand> sendQueue) internal static SMB1Command GetTransactionResponse(SMBHeader 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 SMBCommand GetCompleteTransactionResponse(SMBHeader header, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List<SMBCommand> sendQueue) internal static SMB1Command GetCompleteTransactionResponse(SMBHeader 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 SMBCommand GetCompleteTransaction2Response(SMBHeader header, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List<SMBCommand> sendQueue) internal static SMB1Command GetCompleteTransaction2Response(SMBHeader 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;
@ -229,7 +229,7 @@ namespace SMBLibrary.Server
return response; return response;
} }
internal static void PrepareResponse(TransactionResponse response, byte[] responseSetup, byte[] responseParameters, byte[] responseData, int maxBufferSize, List<SMBCommand> sendQueue) internal static void PrepareResponse(TransactionResponse response, byte[] responseSetup, byte[] responseParameters, byte[] responseData, int maxBufferSize, List<SMB1Command> sendQueue)
{ {
int responseSize = TransactionResponse.CalculateMessageSize(responseSetup.Length, responseParameters.Length, responseData.Length); int responseSize = TransactionResponse.CalculateMessageSize(responseSetup.Length, responseParameters.Length, responseData.Length);
if (responseSize <= maxBufferSize) if (responseSize <= maxBufferSize)

View file

@ -14,7 +14,7 @@ namespace SMBLibrary.Server
{ {
public class TreeConnectHelper public class TreeConnectHelper
{ {
internal static SMBCommand GetTreeConnectResponse(SMBHeader header, TreeConnectAndXRequest request, StateObject state, ShareCollection shares) internal static SMB1Command GetTreeConnectResponse(SMBHeader 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 SMBCommand GetTreeDisconnectResponse(SMBHeader header, TreeDisconnectRequest request, StateObject state) internal static SMB1Command GetTreeDisconnectResponse(SMBHeader header, TreeDisconnectRequest request, StateObject state)
{ {
if (!state.IsTreeConnected(header.TID)) if (!state.IsTreeConnected(header.TID))
{ {

View file

@ -229,11 +229,11 @@ namespace SMBLibrary.Server
{ {
SMBMessage reply = new SMBMessage(); SMBMessage reply = new SMBMessage();
PrepareResponseHeader(reply, message); PrepareResponseHeader(reply, message);
List<SMBCommand> sendQueue = new List<SMBCommand>(); List<SMB1Command> sendQueue = new List<SMB1Command>();
foreach (SMBCommand command in message.Commands) foreach (SMB1Command command in message.Commands)
{ {
SMBCommand response = ProcessCommand(reply.Header, command, state, sendQueue); SMB1Command response = ProcessCommand(reply.Header, command, state, sendQueue);
if (response != null) if (response != null)
{ {
reply.Commands.Add(response); reply.Commands.Add(response);
@ -248,7 +248,7 @@ namespace SMBLibrary.Server
{ {
TrySendMessage(state, reply); TrySendMessage(state, reply);
foreach (SMBCommand command in sendQueue) foreach (SMB1Command command in sendQueue)
{ {
SMBMessage secondaryReply = new SMBMessage(); SMBMessage secondaryReply = new SMBMessage();
secondaryReply.Header = reply.Header; secondaryReply.Header = reply.Header;
@ -261,7 +261,7 @@ namespace SMBLibrary.Server
/// <summary> /// <summary>
/// May return null /// May return null
/// </summary> /// </summary>
public SMBCommand ProcessCommand(SMBHeader header, SMBCommand command, StateObject state, List<SMBCommand> sendQueue) public SMB1Command ProcessCommand(SMBHeader header, SMB1Command command, StateObject state, List<SMB1Command> sendQueue)
{ {
if (command is NegotiateRequest) if (command is NegotiateRequest)
{ {