mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 10:47:48 +02:00
SMB1: Transaction requests to the NamedPipeStore will not be blocked at the SMB layer
This commit is contained in:
parent
fbea16545f
commit
384efe97e7
2 changed files with 37 additions and 32 deletions
|
@ -15,7 +15,7 @@ namespace SMBLibrary.Server.SMB1
|
|||
{
|
||||
public class Transaction2SubcommandHelper
|
||||
{
|
||||
internal static Transaction2FindFirst2Response GetSubcommandResponse(SMB1Header header, Transaction2FindFirst2Request subcommand, FileSystemShare share, SMB1ConnectionState state)
|
||||
internal static Transaction2FindFirst2Response GetSubcommandResponse(SMB1Header header, Transaction2FindFirst2Request subcommand, ISMBShare share, SMB1ConnectionState state)
|
||||
{
|
||||
SMB1Session session = state.GetSession(header.UID);
|
||||
string fileNamePattern = subcommand.FileName;
|
||||
|
@ -79,7 +79,7 @@ namespace SMBLibrary.Server.SMB1
|
|||
return response;
|
||||
}
|
||||
|
||||
internal static Transaction2FindNext2Response GetSubcommandResponse(SMB1Header header, Transaction2FindNext2Request subcommand, FileSystemShare share, SMB1ConnectionState state)
|
||||
internal static Transaction2FindNext2Response GetSubcommandResponse(SMB1Header header, Transaction2FindNext2Request subcommand, ISMBShare share, SMB1ConnectionState state)
|
||||
{
|
||||
SMB1Session session = state.GetSession(header.UID);
|
||||
OpenSearch openSearch = session.GetOpenSearch(subcommand.SID);
|
||||
|
@ -115,14 +115,17 @@ namespace SMBLibrary.Server.SMB1
|
|||
return response;
|
||||
}
|
||||
|
||||
internal static Transaction2QueryFSInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryFSInformationRequest subcommand, FileSystemShare share, SMB1ConnectionState state)
|
||||
internal static Transaction2QueryFSInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryFSInformationRequest subcommand, ISMBShare share, SMB1ConnectionState state)
|
||||
{
|
||||
SMB1Session session = state.GetSession(header.UID);
|
||||
if (!share.HasReadAccess(session.UserName, @"\", state.ClientEndPoint))
|
||||
if (share is FileSystemShare)
|
||||
{
|
||||
if (!((FileSystemShare)share).HasReadAccess(session.UserName, @"\", state.ClientEndPoint))
|
||||
{
|
||||
header.Status = NTStatus.STATUS_ACCESS_DENIED;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Transaction2QueryFSInformationResponse response = new Transaction2QueryFSInformationResponse();
|
||||
QueryFSInformation queryFSInformation;
|
||||
|
@ -137,15 +140,19 @@ namespace SMBLibrary.Server.SMB1
|
|||
return response;
|
||||
}
|
||||
|
||||
internal static Transaction2QueryPathInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryPathInformationRequest subcommand, FileSystemShare share, SMB1ConnectionState state)
|
||||
internal static Transaction2QueryPathInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryPathInformationRequest subcommand, ISMBShare share, SMB1ConnectionState state)
|
||||
{
|
||||
SMB1Session session = state.GetSession(header.UID);
|
||||
string path = subcommand.FileName;
|
||||
if (!share.HasReadAccess(session.UserName, path, state.ClientEndPoint))
|
||||
if (share is FileSystemShare)
|
||||
{
|
||||
if (!((FileSystemShare)share).HasReadAccess(session.UserName, path, state.ClientEndPoint))
|
||||
{
|
||||
header.Status = NTStatus.STATUS_ACCESS_DENIED;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Transaction2QueryPathInformationResponse response = new Transaction2QueryPathInformationResponse();
|
||||
QueryInformation queryInformation;
|
||||
NTStatus queryStatus = SMB1FileStoreHelper.GetFileInformation(out queryInformation, share.FileStore, path, subcommand.InformationLevel);
|
||||
|
@ -159,7 +166,7 @@ namespace SMBLibrary.Server.SMB1
|
|||
return response;
|
||||
}
|
||||
|
||||
internal static Transaction2QueryFileInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryFileInformationRequest subcommand, FileSystemShare share, SMB1ConnectionState state)
|
||||
internal static Transaction2QueryFileInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2QueryFileInformationRequest subcommand, ISMBShare share, SMB1ConnectionState state)
|
||||
{
|
||||
SMB1Session session = state.GetSession(header.UID);
|
||||
OpenFileObject openFile = session.GetOpenFileObject(subcommand.FID);
|
||||
|
@ -169,11 +176,14 @@ namespace SMBLibrary.Server.SMB1
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!share.HasReadAccess(session.UserName, openFile.Path, state.ClientEndPoint))
|
||||
if (share is FileSystemShare)
|
||||
{
|
||||
if (!((FileSystemShare)share).HasReadAccess(session.UserName, openFile.Path, state.ClientEndPoint))
|
||||
{
|
||||
header.Status = NTStatus.STATUS_ACCESS_DENIED;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Transaction2QueryFileInformationResponse response = new Transaction2QueryFileInformationResponse();
|
||||
QueryInformation queryInformation;
|
||||
|
@ -188,7 +198,7 @@ namespace SMBLibrary.Server.SMB1
|
|||
return response;
|
||||
}
|
||||
|
||||
internal static Transaction2SetFileInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2SetFileInformationRequest subcommand, FileSystemShare share, SMB1ConnectionState state)
|
||||
internal static Transaction2SetFileInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2SetFileInformationRequest subcommand, ISMBShare share, SMB1ConnectionState state)
|
||||
{
|
||||
SMB1Session session = state.GetSession(header.UID);
|
||||
OpenFileObject openFile = session.GetOpenFileObject(subcommand.FID);
|
||||
|
@ -198,11 +208,14 @@ namespace SMBLibrary.Server.SMB1
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!share.HasWriteAccess(session.UserName, openFile.Path, state.ClientEndPoint))
|
||||
if (share is FileSystemShare)
|
||||
{
|
||||
if (!((FileSystemShare)share).HasWriteAccess(session.UserName, openFile.Path, state.ClientEndPoint))
|
||||
{
|
||||
header.Status = NTStatus.STATUS_ACCESS_DENIED;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
SetInformation information;
|
||||
try
|
||||
|
|
|
@ -195,29 +195,21 @@ namespace SMBLibrary.Server.SMB1
|
|||
}
|
||||
Transaction2Subcommand subcommandResponse = null;
|
||||
|
||||
if (!(share is FileSystemShare))
|
||||
{
|
||||
header.Status = NTStatus.STATUS_INVALID_PARAMETER;
|
||||
return new ErrorResponse(CommandName.SMB_COM_TRANSACTION2);
|
||||
}
|
||||
|
||||
FileSystemShare fileSystemShare = (FileSystemShare)share;
|
||||
|
||||
if (subcommand is Transaction2FindFirst2Request)
|
||||
{
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2FindFirst2Request)subcommand, fileSystemShare, state);
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2FindFirst2Request)subcommand, share, state);
|
||||
}
|
||||
else if (subcommand is Transaction2FindNext2Request)
|
||||
{
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2FindNext2Request)subcommand, fileSystemShare, state);
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2FindNext2Request)subcommand, share, state);
|
||||
}
|
||||
else if (subcommand is Transaction2QueryFSInformationRequest)
|
||||
{
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2QueryFSInformationRequest)subcommand, fileSystemShare, state);
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2QueryFSInformationRequest)subcommand, share, state);
|
||||
}
|
||||
else if (subcommand is Transaction2QueryPathInformationRequest)
|
||||
{
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2QueryPathInformationRequest)subcommand, fileSystemShare, state);
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2QueryPathInformationRequest)subcommand, share, state);
|
||||
}
|
||||
else if (subcommand is Transaction2SetPathInformationRequest)
|
||||
{
|
||||
|
@ -225,11 +217,11 @@ namespace SMBLibrary.Server.SMB1
|
|||
}
|
||||
else if (subcommand is Transaction2QueryFileInformationRequest)
|
||||
{
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2QueryFileInformationRequest)subcommand, fileSystemShare, state);
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2QueryFileInformationRequest)subcommand, share, state);
|
||||
}
|
||||
else if (subcommand is Transaction2SetFileInformationRequest)
|
||||
{
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2SetFileInformationRequest)subcommand, fileSystemShare, state);
|
||||
subcommandResponse = Transaction2SubcommandHelper.GetSubcommandResponse(header, (Transaction2SetFileInformationRequest)subcommand, share, state);
|
||||
}
|
||||
else if (subcommand is Transaction2CreateDirectoryRequest)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue