diff --git a/SMBLibrary/SMB1/Commands/NTTransactRequest.cs b/SMBLibrary/SMB1/Commands/NTTransactRequest.cs index d2b1f33..7d96164 100644 --- a/SMBLibrary/SMB1/Commands/NTTransactRequest.cs +++ b/SMBLibrary/SMB1/Commands/NTTransactRequest.cs @@ -69,7 +69,7 @@ namespace SMBLibrary.SMB1 uint dataCount = (ushort)TransData.Length; // 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; parameterOffset += (ushort)padding1; uint dataOffset = (ushort)(parameterOffset + parameterCount); diff --git a/SMBLibrary/SMB1/Commands/NTTransactResponse.cs b/SMBLibrary/SMB1/Commands/NTTransactResponse.cs index 7a35edd..62c3dbb 100644 --- a/SMBLibrary/SMB1/Commands/NTTransactResponse.cs +++ b/SMBLibrary/SMB1/Commands/NTTransactResponse.cs @@ -68,7 +68,7 @@ namespace SMBLibrary.SMB1 uint dataDisplacement = 0; // 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; parameterOffset += (ushort)padding1; uint dataOffset = (ushort)(parameterOffset + parameterCount); @@ -106,7 +106,7 @@ namespace SMBLibrary.SMB1 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; parameterOffset += padding1; int dataOffset = (parameterOffset + trans2ParametersLength); @@ -115,7 +115,7 @@ namespace SMBLibrary.SMB1 int messageParametersLength = FixedSMBParametersLength + setupLength; int messageDataLength = trans2ParametersLength + trans2DataLength + padding1 + padding2; // WordCount + ByteCount are additional 3 bytes - return SMBHeader.Length + messageParametersLength + messageDataLength + 3; + return SMB1Header.Length + messageParametersLength + messageDataLength + 3; } } } diff --git a/SMBLibrary/SMB1/Commands/NTTransactSecondaryRequest.cs b/SMBLibrary/SMB1/Commands/NTTransactSecondaryRequest.cs index b3fed92..1bdf25c 100644 --- a/SMBLibrary/SMB1/Commands/NTTransactSecondaryRequest.cs +++ b/SMBLibrary/SMB1/Commands/NTTransactSecondaryRequest.cs @@ -63,7 +63,7 @@ namespace SMBLibrary.SMB1 uint dataCount = (ushort)TransData.Length; // 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; parameterOffset += (ushort)padding1; uint dataOffset = (ushort)(parameterOffset + parameterCount); diff --git a/SMBLibrary/SMB1/Commands/ReadAndXResponse.cs b/SMBLibrary/SMB1/Commands/ReadAndXResponse.cs index 6930e35..186f7d3 100644 --- a/SMBLibrary/SMB1/Commands/ReadAndXResponse.cs +++ b/SMBLibrary/SMB1/Commands/ReadAndXResponse.cs @@ -56,7 +56,7 @@ namespace SMBLibrary.SMB1 { uint DataLength = (uint)Data.Length; // WordCount + ByteCount are additional 3 bytes - ushort DataOffset = SMBHeader.Length + 3 + ParametersLength; + ushort DataOffset = SMB1Header.Length + 3 + ParametersLength; if (isUnicode) { DataOffset++; diff --git a/SMBLibrary/SMB1/Commands/SMB1Command.cs b/SMBLibrary/SMB1/Commands/SMB1Command.cs index 52ec42b..ac8f899 100644 --- a/SMBLibrary/SMB1/Commands/SMB1Command.cs +++ b/SMBLibrary/SMB1/Commands/SMB1Command.cs @@ -63,7 +63,7 @@ namespace SMBLibrary.SMB1 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) { diff --git a/SMBLibrary/SMB1/Commands/Transaction2SecondaryRequest.cs b/SMBLibrary/SMB1/Commands/Transaction2SecondaryRequest.cs index caeb30a..2545db0 100644 --- a/SMBLibrary/SMB1/Commands/Transaction2SecondaryRequest.cs +++ b/SMBLibrary/SMB1/Commands/Transaction2SecondaryRequest.cs @@ -45,7 +45,7 @@ namespace SMBLibrary.SMB1 ParameterCount = (ushort)TransParameters.Length; DataCount = (ushort)TransData.Length; - ParameterOffset = (ushort)(SMBHeader.Length + SMBParametersLength); + ParameterOffset = (ushort)(SMB1Header.Length + SMBParametersLength); int padding1 = (4 - (ParameterOffset % 4)) % 4; ParameterOffset += (ushort)padding1; DataOffset = (ushort)(ParameterOffset + ParameterCount); diff --git a/SMBLibrary/SMB1/Commands/TransactionRequest.cs b/SMBLibrary/SMB1/Commands/TransactionRequest.cs index 45efac3..ad7528d 100644 --- a/SMBLibrary/SMB1/Commands/TransactionRequest.cs +++ b/SMBLibrary/SMB1/Commands/TransactionRequest.cs @@ -94,7 +94,7 @@ namespace SMBLibrary.SMB1 ushort DataCount = (ushort)TransData.Length; // 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) { ParameterOffset += 1; diff --git a/SMBLibrary/SMB1/Commands/TransactionResponse.cs b/SMBLibrary/SMB1/Commands/TransactionResponse.cs index e792368..0eb16df 100644 --- a/SMBLibrary/SMB1/Commands/TransactionResponse.cs +++ b/SMBLibrary/SMB1/Commands/TransactionResponse.cs @@ -73,7 +73,7 @@ namespace SMBLibrary.SMB1 ushort dataCount = (ushort)TransData.Length; // 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; parameterOffset += (ushort)padding1; ushort dataOffset = (ushort)(parameterOffset + parameterCount); @@ -111,7 +111,7 @@ namespace SMBLibrary.SMB1 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; parameterOffset += padding1; int dataOffset = (parameterOffset + trans2ParametersLength); @@ -120,7 +120,7 @@ namespace SMBLibrary.SMB1 int messageParametersLength = FixedSMBParametersLength + setupLength; int messageDataLength = trans2ParametersLength + trans2DataLength + padding1 + padding2; // WordCount + ByteCount are additional 3 bytes - return SMBHeader.Length + messageParametersLength + messageDataLength + 3; + return SMB1Header.Length + messageParametersLength + messageDataLength + 3; } } } diff --git a/SMBLibrary/SMB1/Commands/TransactionSecondaryRequest.cs b/SMBLibrary/SMB1/Commands/TransactionSecondaryRequest.cs index 71edee9..2c9a7b2 100644 --- a/SMBLibrary/SMB1/Commands/TransactionSecondaryRequest.cs +++ b/SMBLibrary/SMB1/Commands/TransactionSecondaryRequest.cs @@ -57,7 +57,7 @@ namespace SMBLibrary.SMB1 DataCount = (ushort)TransData.Length; // WordCount + ByteCount are additional 3 bytes - ParameterOffset = (ushort)(SMBHeader.Length + 3 + SMBParametersLength); + ParameterOffset = (ushort)(SMB1Header.Length + 3 + SMBParametersLength); int padding1 = (4 - (ParameterOffset % 4)) % 4; ParameterOffset += (ushort)padding1; DataOffset = (ushort)(ParameterOffset + ParameterCount); diff --git a/SMBLibrary/SMB1/Commands/WriteAndXRequest.cs b/SMBLibrary/SMB1/Commands/WriteAndXRequest.cs index 77d62ad..576d131 100644 --- a/SMBLibrary/SMB1/Commands/WriteAndXRequest.cs +++ b/SMBLibrary/SMB1/Commands/WriteAndXRequest.cs @@ -62,7 +62,7 @@ namespace SMBLibrary.SMB1 { uint DataLength = (uint)Data.Length; // WordCount + ByteCount are additional 3 bytes - ushort DataOffset = SMBHeader.Length + 3 + ParametersFixedLength; + ushort DataOffset = SMB1Header.Length + 3 + ParametersFixedLength; if (isUnicode) { DataOffset++; diff --git a/SMBLibrary/SMB1/SMBHeader.cs b/SMBLibrary/SMB1/SMB1Header.cs similarity index 94% rename from SMBLibrary/SMB1/SMBHeader.cs rename to SMBLibrary/SMB1/SMB1Header.cs index 361c537..9c36c9d 100644 --- a/SMBLibrary/SMB1/SMBHeader.cs +++ b/SMBLibrary/SMB1/SMB1Header.cs @@ -11,7 +11,7 @@ using Utilities; namespace SMBLibrary.SMB1 { - public class SMBHeader + public class SMB1Header { public const int Length = 32; public static readonly byte[] ProtocolSignature = new byte[] { 0xFF, 0x53, 0x4D, 0x42 }; @@ -31,12 +31,12 @@ namespace SMBLibrary.SMB1 public uint PID; // Process ID - public SMBHeader() + public SMB1Header() { Protocol = ProtocolSignature; } - public SMBHeader(byte[] buffer) + public SMB1Header(byte[] buffer) { Protocol = ByteReader.ReadBytes(buffer, 0, 4); Command = (CommandName)ByteReader.ReadByte(buffer, 4); diff --git a/SMBLibrary/SMB1/SMBMessage.cs b/SMBLibrary/SMB1/SMBMessage.cs index 5584b9e..b947e4a 100644 --- a/SMBLibrary/SMB1/SMBMessage.cs +++ b/SMBLibrary/SMB1/SMBMessage.cs @@ -18,18 +18,18 @@ namespace SMBLibrary.SMB1 /// public class SMBMessage { - public SMBHeader Header; + public SMB1Header Header; public List Commands = new List(); public SMBMessage() { - Header = new SMBHeader(); + Header = new SMB1Header(); } public SMBMessage(byte[] buffer) { - Header = new SMBHeader(buffer); - SMB1Command command = SMB1Command.ReadCommand(buffer, SMBHeader.Length, Header.Command, Header); + Header = new SMB1Header(buffer); + SMB1Command command = SMB1Command.ReadCommand(buffer, SMB1Header.Length, Header.Command, Header); Commands.Add(command); while(command is SMBAndXCommand) { @@ -65,7 +65,7 @@ namespace SMBLibrary.SMB1 } List sequence = new List(); - int length = SMBHeader.Length; + int length = SMB1Header.Length; byte[] commandBytes; for (int index = 0; index < Commands.Count - 1; index++) { @@ -86,7 +86,7 @@ namespace SMBLibrary.SMB1 byte[] buffer = new byte[length]; Header.WriteBytes(buffer, 0); - int offset = SMBHeader.Length; + int offset = SMB1Header.Length; foreach (byte[] bytes in sequence) { ByteWriter.WriteBytes(buffer, ref offset, bytes); @@ -97,10 +97,10 @@ namespace SMBLibrary.SMB1 public static bool IsValidSMBMessage(byte[] buffer) { - if (buffer[0] == SMBHeader.ProtocolSignature[0] && - buffer[1] == SMBHeader.ProtocolSignature[1] && - buffer[2] == SMBHeader.ProtocolSignature[2] && - buffer[3] == SMBHeader.ProtocolSignature[3]) + if (buffer[0] == SMB1Header.ProtocolSignature[0] && + buffer[1] == SMB1Header.ProtocolSignature[1] && + buffer[2] == SMB1Header.ProtocolSignature[2] && + buffer[3] == SMB1Header.ProtocolSignature[3]) { return true; } diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index 42a0613..d4600dd 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -274,7 +274,7 @@ - + diff --git a/SMBLibrary/Server/ResponseHelpers/FileSystemResponseHelper.cs b/SMBLibrary/Server/ResponseHelpers/FileSystemResponseHelper.cs index f2b93a1..12a09d5 100644 --- a/SMBLibrary/Server/ResponseHelpers/FileSystemResponseHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/FileSystemResponseHelper.cs @@ -15,7 +15,7 @@ namespace SMBLibrary.Server { 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); if (!share.HasWriteAccess(userName)) @@ -45,7 +45,7 @@ namespace SMBLibrary.Server 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); 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; FileSystemEntry entry = fileSystem.GetEntry(request.DirectoryName); @@ -100,7 +100,7 @@ namespace SMBLibrary.Server 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); 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); 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; FileSystemEntry entry = fileSystem.GetEntry(request.FileName); @@ -207,7 +207,7 @@ namespace SMBLibrary.Server 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); if (!share.HasWriteAccess(userName)) @@ -249,7 +249,7 @@ namespace SMBLibrary.Server 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); if (openedFilePath == null) diff --git a/SMBLibrary/Server/ResponseHelpers/NTCreateHelper.cs b/SMBLibrary/Server/ResponseHelpers/NTCreateHelper.cs index d070254..d7aff75 100644 --- a/SMBLibrary/Server/ResponseHelpers/NTCreateHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/NTCreateHelper.cs @@ -16,7 +16,7 @@ namespace SMBLibrary.Server { 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; string path = request.FileName; diff --git a/SMBLibrary/Server/ResponseHelpers/NTTransactHelper.cs b/SMBLibrary/Server/ResponseHelpers/NTTransactHelper.cs index 83a0cb5..b9acb08 100644 --- a/SMBLibrary/Server/ResponseHelpers/NTTransactHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/NTTransactHelper.cs @@ -17,7 +17,7 @@ namespace SMBLibrary.Server /// /// The client MUST send as many secondary requests as are needed to complete the transfer of the transaction request. /// - internal static SMB1Command GetNTTransactResponse(SMBHeader header, NTTransactRequest request, ISMBShare share, StateObject state, List sendQueue) + internal static SMB1Command GetNTTransactResponse(SMB1Header header, NTTransactRequest request, ISMBShare share, StateObject state, List sendQueue) { if (request.TransParameters.Length < request.TotalParameterCount || request.TransData.Length < request.TotalDataCount) @@ -45,7 +45,7 @@ namespace SMBLibrary.Server /// 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. /// - internal static SMB1Command GetNTTransactResponse(SMBHeader header, NTTransactSecondaryRequest request, ISMBShare share, StateObject state, List sendQueue) + internal static SMB1Command GetNTTransactResponse(SMB1Header header, NTTransactSecondaryRequest request, ISMBShare share, StateObject state, List sendQueue) { ProcessStateObject processState = state.GetProcessState(header.PID); 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 sendQueue) + internal static SMB1Command GetCompleteNTTransactResponse(SMB1Header header, NTTransactSubcommandName subcommandName, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List sendQueue) { NTTransactSubcommand subcommand = NTTransactSubcommand.GetSubcommandRequest(subcommandName, requestSetup, requestParameters, requestData, header.UnicodeFlag); NTTransactSubcommand subcommandResponse = null; @@ -112,7 +112,7 @@ namespace SMBLibrary.Server 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; diff --git a/SMBLibrary/Server/ResponseHelpers/NegotiateHelper.cs b/SMBLibrary/Server/ResponseHelpers/NegotiateHelper.cs index 322cebe..ca8d943 100644 --- a/SMBLibrary/Server/ResponseHelpers/NegotiateHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/NegotiateHelper.cs @@ -18,7 +18,7 @@ namespace SMBLibrary.Server /// 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(); @@ -68,7 +68,7 @@ namespace SMBLibrary.Server 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(); // 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; } - 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(); diff --git a/SMBLibrary/Server/ResponseHelpers/OpenAndXHelper.cs b/SMBLibrary/Server/ResponseHelpers/OpenAndXHelper.cs index b65e208..e7805fe 100644 --- a/SMBLibrary/Server/ResponseHelpers/OpenAndXHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/OpenAndXHelper.cs @@ -16,7 +16,7 @@ namespace SMBLibrary.Server { 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; string path = request.FileName; diff --git a/SMBLibrary/Server/ResponseHelpers/ReadWriteResponseHelper.cs b/SMBLibrary/Server/ResponseHelpers/ReadWriteResponseHelper.cs index 373099d..e32c64a 100644 --- a/SMBLibrary/Server/ResponseHelpers/ReadWriteResponseHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/ReadWriteResponseHelper.cs @@ -17,7 +17,7 @@ namespace SMBLibrary.Server { 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); if (header.Status != NTStatus.STATUS_SUCCESS) @@ -31,7 +31,7 @@ namespace SMBLibrary.Server 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; if ((share is FileSystemShare) && state.LargeRead) @@ -54,7 +54,7 @@ namespace SMBLibrary.Server 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) { @@ -63,7 +63,7 @@ namespace SMBLibrary.Server 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); 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); if (header.Status != NTStatus.STATUS_SUCCESS) @@ -147,7 +147,7 @@ namespace SMBLibrary.Server 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); if (header.Status != NTStatus.STATUS_SUCCESS) @@ -165,7 +165,7 @@ namespace SMBLibrary.Server 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); if (openedFile == null) diff --git a/SMBLibrary/Server/ResponseHelpers/ServerResponseHelper.cs b/SMBLibrary/Server/ResponseHelpers/ServerResponseHelper.cs index 2371265..9511585 100644 --- a/SMBLibrary/Server/ResponseHelpers/ServerResponseHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/ServerResponseHelper.cs @@ -15,7 +15,7 @@ namespace SMBLibrary.Server { 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); if (openedFile == null) @@ -40,7 +40,7 @@ namespace SMBLibrary.Server 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); return new FindClose2Response(); diff --git a/SMBLibrary/Server/ResponseHelpers/Transaction2SubcommandHelper.cs b/SMBLibrary/Server/ResponseHelpers/Transaction2SubcommandHelper.cs index 4a11b07..a50a74e 100644 --- a/SMBLibrary/Server/ResponseHelpers/Transaction2SubcommandHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/Transaction2SubcommandHelper.cs @@ -20,7 +20,7 @@ namespace SMBLibrary.Server public const bool IncludeCurrentDirectoryInResults = 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; string path = subcommand.FileName; @@ -193,7 +193,7 @@ namespace SMBLibrary.Server 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)) { @@ -227,7 +227,7 @@ namespace SMBLibrary.Server 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(); QueryFSInformation queryFSInformation = InfoHelper.GetFSInformation(subcommand.InformationLevel, share.FileSystem); @@ -235,7 +235,7 @@ namespace SMBLibrary.Server 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; string path = subcommand.FileName; @@ -255,7 +255,7 @@ namespace SMBLibrary.Server 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; string openedFilePath = state.GetOpenedFilePath(subcommand.FID); @@ -278,7 +278,7 @@ namespace SMBLibrary.Server 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); if (openedFilePath == null) diff --git a/SMBLibrary/Server/ResponseHelpers/TransactionHelper.cs b/SMBLibrary/Server/ResponseHelpers/TransactionHelper.cs index 8e6534b..5d99584 100644 --- a/SMBLibrary/Server/ResponseHelpers/TransactionHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/TransactionHelper.cs @@ -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 server MUST respond to the transaction request as a whole. /// - internal static SMB1Command GetTransactionResponse(SMBHeader header, TransactionRequest request, ISMBShare share, StateObject state, List sendQueue) + internal static SMB1Command GetTransactionResponse(SMB1Header header, TransactionRequest request, ISMBShare share, StateObject state, List sendQueue) { ProcessStateObject processState = state.ObtainProcessState(header.PID); 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 server MUST respond to the transaction request as a whole. /// - internal static SMB1Command GetTransactionResponse(SMBHeader header, TransactionSecondaryRequest request, ISMBShare share, StateObject state, List sendQueue) + internal static SMB1Command GetTransactionResponse(SMB1Header header, TransactionSecondaryRequest request, ISMBShare share, StateObject state, List sendQueue) { ProcessStateObject processState = state.GetProcessState(header.PID); 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 sendQueue) + internal static SMB1Command GetCompleteTransactionResponse(SMB1Header header, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List sendQueue) { TransactionSubcommand subcommand = TransactionSubcommand.GetSubcommandRequest(requestSetup, requestParameters, requestData, header.UnicodeFlag); TransactionSubcommand subcommandResponse = null; @@ -162,7 +162,7 @@ namespace SMBLibrary.Server return response; } - internal static SMB1Command GetCompleteTransaction2Response(SMBHeader header, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List sendQueue) + internal static SMB1Command GetCompleteTransaction2Response(SMB1Header header, byte[] requestSetup, byte[] requestParameters, byte[] requestData, ISMBShare share, StateObject state, List sendQueue) { Transaction2Subcommand subcommand = Transaction2Subcommand.GetSubcommandRequest(requestSetup, requestParameters, requestData, header.UnicodeFlag); Transaction2Subcommand subcommandResponse = null; diff --git a/SMBLibrary/Server/ResponseHelpers/TransactionSubcommandHelper.cs b/SMBLibrary/Server/ResponseHelpers/TransactionSubcommandHelper.cs index 53088f7..0a914c5 100644 --- a/SMBLibrary/Server/ResponseHelpers/TransactionSubcommandHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/TransactionSubcommandHelper.cs @@ -16,7 +16,7 @@ namespace SMBLibrary.Server { 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); if (openedFilePath == null) diff --git a/SMBLibrary/Server/ResponseHelpers/TreeConnectHelper.cs b/SMBLibrary/Server/ResponseHelpers/TreeConnectHelper.cs index a9dec6e..5f8ac35 100644 --- a/SMBLibrary/Server/ResponseHelpers/TreeConnectHelper.cs +++ b/SMBLibrary/Server/ResponseHelpers/TreeConnectHelper.cs @@ -14,7 +14,7 @@ namespace SMBLibrary.Server { 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; string relativePath = ServerPathUtils.GetRelativeServerPath(request.Path); @@ -89,7 +89,7 @@ namespace SMBLibrary.Server 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)) { diff --git a/SMBLibrary/Server/SMBServer.cs b/SMBLibrary/Server/SMBServer.cs index b643523..9b8e737 100644 --- a/SMBLibrary/Server/SMBServer.cs +++ b/SMBLibrary/Server/SMBServer.cs @@ -261,7 +261,7 @@ namespace SMBLibrary.Server /// /// May return null /// - public SMB1Command ProcessCommand(SMBHeader header, SMB1Command command, StateObject state, List sendQueue) + public SMB1Command ProcessCommand(SMB1Header header, SMB1Command command, StateObject state, List sendQueue) { if (command is NegotiateRequest) {