mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-29 18:27:48 +02:00
SMB1: Added support for paths without leading backslash
This commit is contained in:
parent
210f522b29
commit
ae8a3d77d3
4 changed files with 37 additions and 6 deletions
|
@ -110,17 +110,23 @@ namespace SMBLibrary.Server.SMB1
|
|||
internal static SMB1Command GetCheckDirectoryResponse(SMB1Header header, CheckDirectoryRequest request, ISMBShare share, SMB1ConnectionState state)
|
||||
{
|
||||
SMB1Session session = state.GetSession(header.UID);
|
||||
string path = request.DirectoryName;
|
||||
if (!path.StartsWith(@"\"))
|
||||
{
|
||||
path = @"\" + path;
|
||||
}
|
||||
|
||||
if (share is FileSystemShare)
|
||||
{
|
||||
if (!((FileSystemShare)share).HasReadAccess(session.SecurityContext, request.DirectoryName))
|
||||
if (!((FileSystemShare)share).HasReadAccess(session.SecurityContext, path))
|
||||
{
|
||||
state.LogToServer(Severity.Verbose, "Check Directory '{0}{1}' failed. User '{2}' was denied access.", share.Name, request.DirectoryName, session.UserName);
|
||||
state.LogToServer(Severity.Verbose, "Check Directory '{0}{1}' failed. User '{2}' was denied access.", share.Name, path, session.UserName);
|
||||
header.Status = NTStatus.STATUS_ACCESS_DENIED;
|
||||
return new ErrorResponse(request.CommandName);
|
||||
}
|
||||
}
|
||||
|
||||
header.Status = SMB1FileStoreHelper.CheckDirectory(share.FileStore, request.DirectoryName, session.SecurityContext);
|
||||
header.Status = SMB1FileStoreHelper.CheckDirectory(share.FileStore, path, session.SecurityContext);
|
||||
if (header.Status != NTStatus.STATUS_SUCCESS)
|
||||
{
|
||||
return new ErrorResponse(request.CommandName);
|
||||
|
@ -132,18 +138,24 @@ namespace SMBLibrary.Server.SMB1
|
|||
internal static SMB1Command GetQueryInformationResponse(SMB1Header header, QueryInformationRequest request, ISMBShare share, SMB1ConnectionState state)
|
||||
{
|
||||
SMB1Session session = state.GetSession(header.UID);
|
||||
string path = request.FileName;
|
||||
if (!path.StartsWith(@"\"))
|
||||
{
|
||||
path = @"\" + path;
|
||||
}
|
||||
|
||||
if (share is FileSystemShare)
|
||||
{
|
||||
if (!((FileSystemShare)share).HasReadAccess(session.SecurityContext, request.FileName))
|
||||
if (!((FileSystemShare)share).HasReadAccess(session.SecurityContext, path))
|
||||
{
|
||||
state.LogToServer(Severity.Verbose, "Query Information on '{0}{1}' failed. User '{2}' was denied access.", share.Name, request.FileName, session.UserName);
|
||||
state.LogToServer(Severity.Verbose, "Query Information on '{0}{1}' failed. User '{2}' was denied access.", share.Name, path, session.UserName);
|
||||
header.Status = NTStatus.STATUS_ACCESS_DENIED;
|
||||
return new ErrorResponse(request.CommandName);
|
||||
}
|
||||
}
|
||||
|
||||
FileNetworkOpenInformation fileInfo;
|
||||
header.Status = SMB1FileStoreHelper.QueryInformation(out fileInfo, share.FileStore, request.FileName, session.SecurityContext);
|
||||
header.Status = SMB1FileStoreHelper.QueryInformation(out fileInfo, share.FileStore, path, session.SecurityContext);
|
||||
if (header.Status != NTStatus.STATUS_SUCCESS)
|
||||
{
|
||||
return new ErrorResponse(request.CommandName);
|
||||
|
|
|
@ -21,6 +21,11 @@ namespace SMBLibrary.Server.SMB1
|
|||
SMB1Session session = state.GetSession(header.UID);
|
||||
bool isExtended = (request.Flags & NTCreateFlags.NT_CREATE_REQUEST_EXTENDED_RESPONSE) > 0;
|
||||
string path = request.FileName;
|
||||
if (!path.StartsWith(@"\"))
|
||||
{
|
||||
path = @"\" + path;
|
||||
}
|
||||
|
||||
FileAccess createAccess = NTFileStoreHelper.ToCreateFileAccess(request.DesiredAccess, request.CreateDisposition);
|
||||
if (share is FileSystemShare)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,11 @@ namespace SMBLibrary.Server.SMB1
|
|||
SMB1Session session = state.GetSession(header.UID);
|
||||
bool isExtended = (request.Flags & OpenFlags.SMB_OPEN_EXTENDED_RESPONSE) > 0;
|
||||
string path = request.FileName;
|
||||
if (!path.StartsWith(@"\"))
|
||||
{
|
||||
path = @"\" + path;
|
||||
}
|
||||
|
||||
AccessMask desiredAccess;
|
||||
ShareAccess shareAccess;
|
||||
CreateDisposition createDisposition;
|
||||
|
|
|
@ -19,6 +19,10 @@ namespace SMBLibrary.Server.SMB1
|
|||
{
|
||||
SMB1Session session = state.GetSession(header.UID);
|
||||
string fileNamePattern = subcommand.FileName;
|
||||
if (!fileNamePattern.StartsWith(@"\"))
|
||||
{
|
||||
fileNamePattern = @"\" + fileNamePattern;
|
||||
}
|
||||
|
||||
List<QueryDirectoryFileInformation> entries;
|
||||
FileInformationClass informationClass;
|
||||
|
@ -155,6 +159,11 @@ namespace SMBLibrary.Server.SMB1
|
|||
{
|
||||
SMB1Session session = state.GetSession(header.UID);
|
||||
string path = subcommand.FileName;
|
||||
if (!path.StartsWith(@"\"))
|
||||
{
|
||||
path = @"\" + path;
|
||||
}
|
||||
|
||||
if (share is FileSystemShare)
|
||||
{
|
||||
if (!((FileSystemShare)share).HasReadAccess(session.SecurityContext, path))
|
||||
|
|
Loading…
Add table
Reference in a new issue