mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-03 16:23:19 +02:00
Renamed StateObject to SMB1ConnectionState
This commit is contained in:
parent
b45cffe099
commit
bc167316a2
14 changed files with 44 additions and 45 deletions
|
@ -102,6 +102,7 @@
|
||||||
<Compile Include="RPC\Structures\ResultElement.cs" />
|
<Compile Include="RPC\Structures\ResultElement.cs" />
|
||||||
<Compile Include="RPC\Structures\ResultList.cs" />
|
<Compile Include="RPC\Structures\ResultList.cs" />
|
||||||
<Compile Include="RPC\Structures\SyntaxID.cs" />
|
<Compile Include="RPC\Structures\SyntaxID.cs" />
|
||||||
|
<Compile Include="Server\ConnectionState\SMB1ConnectionState.cs" />
|
||||||
<Compile Include="Server\Exceptions\EmptyPasswordNotAllowedException.cs" />
|
<Compile Include="Server\Exceptions\EmptyPasswordNotAllowedException.cs" />
|
||||||
<Compile Include="Server\Exceptions\InvalidRequestException.cs" />
|
<Compile Include="Server\Exceptions\InvalidRequestException.cs" />
|
||||||
<Compile Include="Server\Exceptions\UnsupportedInformationLevelException.cs" />
|
<Compile Include="Server\Exceptions\UnsupportedInformationLevelException.cs" />
|
||||||
|
@ -130,7 +131,6 @@
|
||||||
<Compile Include="Server\Shares\ShareCollection.cs" />
|
<Compile Include="Server\Shares\ShareCollection.cs" />
|
||||||
<Compile Include="Server\SMBConnectionReceiveBuffer.cs" />
|
<Compile Include="Server\SMBConnectionReceiveBuffer.cs" />
|
||||||
<Compile Include="Server\SMBServer.cs" />
|
<Compile Include="Server\SMBServer.cs" />
|
||||||
<Compile Include="Server\StateObject.cs" />
|
|
||||||
<Compile Include="Server\User.cs" />
|
<Compile Include="Server\User.cs" />
|
||||||
<Compile Include="Server\UserCollection.cs" />
|
<Compile Include="Server\UserCollection.cs" />
|
||||||
<Compile Include="Services\Enums\PlatformName.cs" />
|
<Compile Include="Services\Enums\PlatformName.cs" />
|
||||||
|
|
|
@ -8,12 +8,11 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
|
||||||
using Utilities;
|
using Utilities;
|
||||||
|
|
||||||
namespace SMBLibrary.Server
|
namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class StateObject
|
public class SMB1ConnectionState
|
||||||
{
|
{
|
||||||
public Socket ClientSocket = null;
|
public Socket ClientSocket = null;
|
||||||
public const int ReceiveBufferSize = 131075; // Largest NBT Session Packet
|
public const int ReceiveBufferSize = 131075; // Largest NBT Session Packet
|
|
@ -15,7 +15,7 @@ namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class FileSystemResponseHelper
|
public class FileSystemResponseHelper
|
||||||
{
|
{
|
||||||
internal static SMB1Command GetCreateDirectoryResponse(SMB1Header header, CreateDirectoryRequest request, FileSystemShare share, StateObject state)
|
internal static SMB1Command GetCreateDirectoryResponse(SMB1Header header, CreateDirectoryRequest request, FileSystemShare share, SMB1ConnectionState 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(SMB1Header header, DeleteDirectoryRequest request, FileSystemShare share, StateObject state)
|
internal static SMB1Command GetDeleteDirectoryResponse(SMB1Header header, DeleteDirectoryRequest request, FileSystemShare share, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
string userName = state.GetConnectedUserName(header.UID);
|
string userName = state.GetConnectedUserName(header.UID);
|
||||||
if (!share.HasWriteAccess(userName))
|
if (!share.HasWriteAccess(userName))
|
||||||
|
@ -100,7 +100,7 @@ namespace SMBLibrary.Server
|
||||||
return new CheckDirectoryResponse();
|
return new CheckDirectoryResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static SMB1Command GetDeleteResponse(SMB1Header header, DeleteRequest request, FileSystemShare share, StateObject state)
|
internal static SMB1Command GetDeleteResponse(SMB1Header header, DeleteRequest request, FileSystemShare share, SMB1ConnectionState 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(SMB1Header header, RenameRequest request, FileSystemShare share, StateObject state)
|
internal static SMB1Command GetRenameResponse(SMB1Header header, RenameRequest request, FileSystemShare share, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
string userName = state.GetConnectedUserName(header.UID);
|
string userName = state.GetConnectedUserName(header.UID);
|
||||||
if (!share.HasWriteAccess(userName))
|
if (!share.HasWriteAccess(userName))
|
||||||
|
@ -207,7 +207,7 @@ namespace SMBLibrary.Server
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static SMB1Command GetSetInformationResponse(SMB1Header header, SetInformationRequest request, FileSystemShare share, StateObject state)
|
internal static SMB1Command GetSetInformationResponse(SMB1Header header, SetInformationRequest request, FileSystemShare share, SMB1ConnectionState 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(SMB1Header header, SetInformation2Request request, FileSystemShare share, StateObject state)
|
internal static SMB1Command GetSetInformation2Response(SMB1Header header, SetInformation2Request request, FileSystemShare share, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
string openedFilePath = state.GetOpenedFilePath(request.FID);
|
string openedFilePath = state.GetOpenedFilePath(request.FID);
|
||||||
if (openedFilePath == null)
|
if (openedFilePath == null)
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class NTCreateHelper
|
public class NTCreateHelper
|
||||||
{
|
{
|
||||||
internal static SMB1Command GetNTCreateResponse(SMB1Header header, NTCreateAndXRequest request, ISMBShare share, StateObject state)
|
internal static SMB1Command GetNTCreateResponse(SMB1Header header, NTCreateAndXRequest request, ISMBShare share, SMB1ConnectionState 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;
|
||||||
|
|
|
@ -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(SMB1Header header, NTTransactRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
|
internal static SMB1Command GetNTTransactResponse(SMB1Header header, NTTransactRequest request, ISMBShare share, SMB1ConnectionState 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(SMB1Header header, NTTransactSecondaryRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
|
internal static SMB1Command GetNTTransactResponse(SMB1Header header, NTTransactSecondaryRequest request, ISMBShare share, SMB1ConnectionState 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(SMB1Header 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, SMB1ConnectionState 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;
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace SMBLibrary.Server
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static SMB1Command GetSessionSetupResponse(SMB1Header header, SessionSetupAndXRequest request, INTLMAuthenticationProvider users, StateObject state)
|
internal static SMB1Command GetSessionSetupResponse(SMB1Header header, SessionSetupAndXRequest request, INTLMAuthenticationProvider users, SMB1ConnectionState 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(SMB1Header header, SessionSetupAndXRequestExtended request, INTLMAuthenticationProvider users, StateObject state)
|
internal static SMB1Command GetSessionSetupResponseExtended(SMB1Header header, SessionSetupAndXRequestExtended request, INTLMAuthenticationProvider users, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
SessionSetupAndXResponseExtended response = new SessionSetupAndXResponseExtended();
|
SessionSetupAndXResponseExtended response = new SessionSetupAndXResponseExtended();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class OpenAndXHelper
|
public class OpenAndXHelper
|
||||||
{
|
{
|
||||||
internal static SMB1Command GetOpenAndXResponse(SMB1Header header, OpenAndXRequest request, ISMBShare share, StateObject state)
|
internal static SMB1Command GetOpenAndXResponse(SMB1Header header, OpenAndXRequest request, ISMBShare share, SMB1ConnectionState 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;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class ReadWriteResponseHelper
|
public class ReadWriteResponseHelper
|
||||||
{
|
{
|
||||||
internal static SMB1Command GetReadResponse(SMB1Header header, ReadRequest request, ISMBShare share, StateObject state)
|
internal static SMB1Command GetReadResponse(SMB1Header header, ReadRequest request, ISMBShare share, SMB1ConnectionState 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(SMB1Header header, ReadAndXRequest request, ISMBShare share, StateObject state)
|
internal static SMB1Command GetReadResponse(SMB1Header header, ReadAndXRequest request, ISMBShare share, SMB1ConnectionState 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(SMB1Header 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, SMB1ConnectionState 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(SMB1Header 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, SMB1ConnectionState 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(SMB1Header header, WriteRequest request, ISMBShare share, StateObject state)
|
internal static SMB1Command GetWriteResponse(SMB1Header header, WriteRequest request, ISMBShare share, SMB1ConnectionState 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(SMB1Header header, WriteAndXRequest request, ISMBShare share, StateObject state)
|
internal static SMB1Command GetWriteResponse(SMB1Header header, WriteAndXRequest request, ISMBShare share, SMB1ConnectionState 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(SMB1Header 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, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
OpenedFileObject openedFile = state.GetOpenedFileObject(FID);
|
OpenedFileObject openedFile = state.GetOpenedFileObject(FID);
|
||||||
if (openedFile == null)
|
if (openedFile == null)
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public partial class ServerResponseHelper
|
public partial class ServerResponseHelper
|
||||||
{
|
{
|
||||||
internal static SMB1Command GetCloseResponse(SMB1Header header, CloseRequest request, ISMBShare share, StateObject state)
|
internal static SMB1Command GetCloseResponse(SMB1Header header, CloseRequest request, ISMBShare share, SMB1ConnectionState 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(SMB1Header header, FindClose2Request request, StateObject state)
|
internal static SMB1Command GetFindClose2Request(SMB1Header header, FindClose2Request request, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
state.ReleaseSearchHandle(request.SearchHandle);
|
state.ReleaseSearchHandle(request.SearchHandle);
|
||||||
return new FindClose2Response();
|
return new FindClose2Response();
|
||||||
|
|
|
@ -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(SMB1Header header, Transaction2FindFirst2Request subcommand, FileSystemShare share, StateObject state)
|
internal static Transaction2FindFirst2Response GetSubcommandResponse(SMB1Header header, Transaction2FindFirst2Request subcommand, FileSystemShare share, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
IFileSystem fileSystem = share.FileSystem;
|
IFileSystem fileSystem = share.FileSystem;
|
||||||
string path = subcommand.FileName;
|
string path = subcommand.FileName;
|
||||||
|
@ -40,7 +40,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
bool exactNameWithoutExtension = searchPattern.Contains("\"");
|
bool exactNameWithoutExtension = searchPattern.Contains("\"");
|
||||||
|
|
||||||
if (state.OpenSearches.Count > StateObject.MaxSearches)
|
if (state.OpenSearches.Count > SMB1ConnectionState.MaxSearches)
|
||||||
{
|
{
|
||||||
header.Status = NTStatus.STATUS_OS2_NO_MORE_SIDS;
|
header.Status = NTStatus.STATUS_OS2_NO_MORE_SIDS;
|
||||||
return null;
|
return null;
|
||||||
|
@ -193,7 +193,7 @@ namespace SMBLibrary.Server
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Transaction2FindNext2Response GetSubcommandResponse(SMB1Header header, Transaction2FindNext2Request subcommand, FileSystemShare share, StateObject state)
|
internal static Transaction2FindNext2Response GetSubcommandResponse(SMB1Header header, Transaction2FindNext2Request subcommand, FileSystemShare share, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
if (!state.OpenSearches.ContainsKey(subcommand.SID))
|
if (!state.OpenSearches.ContainsKey(subcommand.SID))
|
||||||
{
|
{
|
||||||
|
@ -255,7 +255,7 @@ namespace SMBLibrary.Server
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Transaction2QueryFileInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryFileInformationRequest subcommand, FileSystemShare share, StateObject state)
|
internal static Transaction2QueryFileInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryFileInformationRequest subcommand, FileSystemShare share, SMB1ConnectionState 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(SMB1Header header, Transaction2SetFileInformationRequest subcommand, FileSystemShare share, StateObject state)
|
internal static Transaction2SetFileInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2SetFileInformationRequest subcommand, FileSystemShare share, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
string openedFilePath = state.GetOpenedFilePath(subcommand.FID);
|
string openedFilePath = state.GetOpenedFilePath(subcommand.FID);
|
||||||
if (openedFilePath == null)
|
if (openedFilePath == null)
|
||||||
|
|
|
@ -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(SMB1Header header, TransactionRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
|
internal static SMB1Command GetTransactionResponse(SMB1Header header, TransactionRequest request, ISMBShare share, SMB1ConnectionState 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(SMB1Header header, TransactionSecondaryRequest request, ISMBShare share, StateObject state, List<SMB1Command> sendQueue)
|
internal static SMB1Command GetTransactionResponse(SMB1Header header, TransactionSecondaryRequest request, ISMBShare share, SMB1ConnectionState 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(SMB1Header 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, SMB1ConnectionState 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(SMB1Header 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, SMB1ConnectionState 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;
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class TransactionSubcommandHelper
|
public class TransactionSubcommandHelper
|
||||||
{
|
{
|
||||||
internal static TransactionTransactNamedPipeResponse GetSubcommandResponse(SMB1Header header, TransactionTransactNamedPipeRequest subcommand, NamedPipeShare share, StateObject state)
|
internal static TransactionTransactNamedPipeResponse GetSubcommandResponse(SMB1Header header, TransactionTransactNamedPipeRequest subcommand, NamedPipeShare share, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
string openedFilePath = state.GetOpenedFilePath(subcommand.FID);
|
string openedFilePath = state.GetOpenedFilePath(subcommand.FID);
|
||||||
if (openedFilePath == null)
|
if (openedFilePath == null)
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class TreeConnectHelper
|
public class TreeConnectHelper
|
||||||
{
|
{
|
||||||
internal static SMB1Command GetTreeConnectResponse(SMB1Header header, TreeConnectAndXRequest request, StateObject state, ShareCollection shares)
|
internal static SMB1Command GetTreeConnectResponse(SMB1Header header, TreeConnectAndXRequest request, SMB1ConnectionState 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(SMB1Header header, TreeDisconnectRequest request, StateObject state)
|
internal static SMB1Command GetTreeDisconnectResponse(SMB1Header header, TreeDisconnectRequest request, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
if (!state.IsTreeConnected(header.TID))
|
if (!state.IsTreeConnected(header.TID))
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace SMBLibrary.Server
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StateObject state = new StateObject();
|
SMB1ConnectionState state = new SMB1ConnectionState();
|
||||||
// Disable the Nagle Algorithm for this tcp socket:
|
// Disable the Nagle Algorithm for this tcp socket:
|
||||||
clientSocket.NoDelay = true;
|
clientSocket.NoDelay = true;
|
||||||
state.ClientSocket = clientSocket;
|
state.ClientSocket = clientSocket;
|
||||||
|
@ -113,7 +113,7 @@ namespace SMBLibrary.Server
|
||||||
|
|
||||||
private void ReceiveCallback(IAsyncResult result)
|
private void ReceiveCallback(IAsyncResult result)
|
||||||
{
|
{
|
||||||
StateObject state = (StateObject)result.AsyncState;
|
SMB1ConnectionState state = (SMB1ConnectionState)result.AsyncState;
|
||||||
Socket clientSocket = state.ClientSocket;
|
Socket clientSocket = state.ClientSocket;
|
||||||
|
|
||||||
if (!m_listening)
|
if (!m_listening)
|
||||||
|
@ -163,7 +163,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessConnectionBuffer(StateObject state)
|
public void ProcessConnectionBuffer(SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
Socket clientSocket = state.ClientSocket;
|
Socket clientSocket = state.ClientSocket;
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessPacket(SessionPacket packet, StateObject state)
|
public void ProcessPacket(SessionPacket packet, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
if (packet is SessionRequestPacket && m_transport == SMBTransportType.NetBiosOverTCP)
|
if (packet is SessionRequestPacket && m_transport == SMBTransportType.NetBiosOverTCP)
|
||||||
{
|
{
|
||||||
|
@ -225,7 +225,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessMessage(SMB1Message message, StateObject state)
|
public void ProcessMessage(SMB1Message message, SMB1ConnectionState state)
|
||||||
{
|
{
|
||||||
SMB1Message reply = new SMB1Message();
|
SMB1Message reply = new SMB1Message();
|
||||||
PrepareResponseHeader(reply, message);
|
PrepareResponseHeader(reply, message);
|
||||||
|
@ -261,7 +261,7 @@ namespace SMBLibrary.Server
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// May return null
|
/// May return null
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SMB1Command ProcessCommand(SMB1Header header, SMB1Command command, StateObject state, List<SMB1Command> sendQueue)
|
public SMB1Command ProcessCommand(SMB1Header header, SMB1Command command, SMB1ConnectionState state, List<SMB1Command> sendQueue)
|
||||||
{
|
{
|
||||||
if (command is NegotiateRequest)
|
if (command is NegotiateRequest)
|
||||||
{
|
{
|
||||||
|
@ -524,7 +524,7 @@ namespace SMBLibrary.Server
|
||||||
return new ErrorResponse(command.CommandName);
|
return new ErrorResponse(command.CommandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TrySendMessage(StateObject state, SMB1Message reply)
|
public static void TrySendMessage(SMB1ConnectionState state, SMB1Message reply)
|
||||||
{
|
{
|
||||||
SessionMessagePacket packet = new SessionMessagePacket();
|
SessionMessagePacket packet = new SessionMessagePacket();
|
||||||
packet.Trailer = reply.GetBytes();
|
packet.Trailer = reply.GetBytes();
|
||||||
|
@ -532,7 +532,7 @@ namespace SMBLibrary.Server
|
||||||
System.Diagnostics.Debug.Print("[{0}] Reply sent: {1} Commands, First Command: {2}, Packet length: {3}", DateTime.Now.ToString("HH:mm:ss:ffff"), reply.Commands.Count, reply.Commands[0].CommandName.ToString(), packet.Length);
|
System.Diagnostics.Debug.Print("[{0}] Reply sent: {1} Commands, First Command: {2}, Packet length: {3}", DateTime.Now.ToString("HH:mm:ss:ffff"), reply.Commands.Count, reply.Commands[0].CommandName.ToString(), packet.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TrySendPacket(StateObject state, SessionPacket response)
|
public static void TrySendPacket(SMB1ConnectionState state, SessionPacket response)
|
||||||
{
|
{
|
||||||
Socket clientSocket = state.ClientSocket;
|
Socket clientSocket = state.ClientSocket;
|
||||||
try
|
try
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue