mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 10:47:48 +02:00
SMBServer: Hid internal methods and classes
This commit is contained in:
parent
cef7a6dc29
commit
174e43f792
11 changed files with 22 additions and 22 deletions
|
@ -13,9 +13,9 @@ using Utilities;
|
||||||
|
|
||||||
namespace SMBLibrary.Server
|
namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public delegate void LogDelegate(Severity severity, string message);
|
internal delegate void LogDelegate(Severity severity, string message);
|
||||||
|
|
||||||
public class ConnectionState
|
internal class ConnectionState
|
||||||
{
|
{
|
||||||
public Socket ClientSocket;
|
public Socket ClientSocket;
|
||||||
public IPEndPoint ClientEndPoint;
|
public IPEndPoint ClientEndPoint;
|
||||||
|
|
|
@ -11,7 +11,7 @@ using System.Text;
|
||||||
|
|
||||||
namespace SMBLibrary.Server
|
namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class OpenFileObject
|
internal class OpenFileObject
|
||||||
{
|
{
|
||||||
public string Path;
|
public string Path;
|
||||||
public object Handle;
|
public object Handle;
|
||||||
|
|
|
@ -10,7 +10,7 @@ using Utilities;
|
||||||
|
|
||||||
namespace SMBLibrary.Server
|
namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class OpenSearch
|
internal class OpenSearch
|
||||||
{
|
{
|
||||||
public List<QueryDirectoryFileInformation> Entries;
|
public List<QueryDirectoryFileInformation> Entries;
|
||||||
public int EnumerationLocation;
|
public int EnumerationLocation;
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Text;
|
||||||
|
|
||||||
namespace SMBLibrary.Server
|
namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class ProcessStateObject
|
internal class ProcessStateObject
|
||||||
{
|
{
|
||||||
public ushort SubcommandID;
|
public ushort SubcommandID;
|
||||||
public string Name; // The pathname of the [..] named pipe to which the transaction subcommand applies, or a client-supplied [..] name for the transaction.
|
public string Name; // The pathname of the [..] named pipe to which the transaction subcommand applies, or a client-supplied [..] name for the transaction.
|
||||||
|
|
|
@ -11,7 +11,7 @@ using Utilities;
|
||||||
|
|
||||||
namespace SMBLibrary.Server
|
namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class SMB1ConnectionState : ConnectionState
|
internal class SMB1ConnectionState : ConnectionState
|
||||||
{
|
{
|
||||||
public int MaxBufferSize;
|
public int MaxBufferSize;
|
||||||
public bool LargeRead;
|
public bool LargeRead;
|
||||||
|
|
|
@ -11,7 +11,7 @@ using Utilities;
|
||||||
|
|
||||||
namespace SMBLibrary.Server
|
namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class SMB1Session
|
internal class SMB1Session
|
||||||
{
|
{
|
||||||
private const int MaxSearches = 2048; // Windows servers initialize Server.MaxSearches to 2048.
|
private const int MaxSearches = 2048; // Windows servers initialize Server.MaxSearches to 2048.
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public delegate ulong? AllocatePersistentFileID();
|
public delegate ulong? AllocatePersistentFileID();
|
||||||
|
|
||||||
public class SMB2ConnectionState : ConnectionState
|
internal class SMB2ConnectionState : ConnectionState
|
||||||
{
|
{
|
||||||
// Key is SessionID
|
// Key is SessionID
|
||||||
private Dictionary<ulong, SMB2Session> m_sessions = new Dictionary<ulong, SMB2Session>();
|
private Dictionary<ulong, SMB2Session> m_sessions = new Dictionary<ulong, SMB2Session>();
|
||||||
|
|
|
@ -12,7 +12,7 @@ using Utilities;
|
||||||
|
|
||||||
namespace SMBLibrary.Server
|
namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public class SMB2Session
|
internal class SMB2Session
|
||||||
{
|
{
|
||||||
private SMB2ConnectionState m_connection;
|
private SMB2ConnectionState m_connection;
|
||||||
private ulong m_sessionID;
|
private ulong m_sessionID;
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace SMBLibrary.Server
|
||||||
{
|
{
|
||||||
public partial class SMBServer
|
public partial class SMBServer
|
||||||
{
|
{
|
||||||
public void ProcessSMB1Message(SMB1Message message, ref ConnectionState state)
|
private void ProcessSMB1Message(SMB1Message message, ref ConnectionState state)
|
||||||
{
|
{
|
||||||
SMB1Header header = new SMB1Header();
|
SMB1Header header = new SMB1Header();
|
||||||
PrepareResponseHeader(header, message.Header);
|
PrepareResponseHeader(header, message.Header);
|
||||||
|
@ -65,7 +65,7 @@ namespace SMBLibrary.Server
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// May return an empty list
|
/// May return an empty list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<SMB1Command> ProcessSMB1Command(SMB1Header header, SMB1Command command, ref ConnectionState state)
|
private List<SMB1Command> ProcessSMB1Command(SMB1Header header, SMB1Command command, ref ConnectionState state)
|
||||||
{
|
{
|
||||||
if (state.ServerDialect == SMBDialect.NotSet)
|
if (state.ServerDialect == SMBDialect.NotSet)
|
||||||
{
|
{
|
||||||
|
@ -301,7 +301,7 @@ namespace SMBLibrary.Server
|
||||||
return new ErrorResponse(command.CommandName);
|
return new ErrorResponse(command.CommandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TrySendMessage(ConnectionState state, SMB1Message response)
|
private static void TrySendMessage(ConnectionState state, SMB1Message response)
|
||||||
{
|
{
|
||||||
SessionMessagePacket packet = new SessionMessagePacket();
|
SessionMessagePacket packet = new SessionMessagePacket();
|
||||||
packet.Trailer = response.GetBytes();
|
packet.Trailer = response.GetBytes();
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace SMBLibrary.Server
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessSMB2RequestChain(List<SMB2Command> requestChain, ref ConnectionState state)
|
private void ProcessSMB2RequestChain(List<SMB2Command> requestChain, ref ConnectionState state)
|
||||||
{
|
{
|
||||||
List<SMB2Command> responseChain = new List<SMB2Command>();
|
List<SMB2Command> responseChain = new List<SMB2Command>();
|
||||||
FileID? fileID = null;
|
FileID? fileID = null;
|
||||||
|
@ -67,7 +67,7 @@ namespace SMBLibrary.Server
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// May return null
|
/// May return null
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SMB2Command ProcessSMB2Command(SMB2Command command, ref ConnectionState state)
|
private SMB2Command ProcessSMB2Command(SMB2Command command, ref ConnectionState state)
|
||||||
{
|
{
|
||||||
if (state.ServerDialect == SMBDialect.NotSet)
|
if (state.ServerDialect == SMBDialect.NotSet)
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SMB2Command ProcessSMB2Command(SMB2Command command, SMB2ConnectionState state)
|
private SMB2Command ProcessSMB2Command(SMB2Command command, SMB2ConnectionState state)
|
||||||
{
|
{
|
||||||
if (command is SessionSetupRequest)
|
if (command is SessionSetupRequest)
|
||||||
{
|
{
|
||||||
|
@ -222,7 +222,7 @@ namespace SMBLibrary.Server
|
||||||
return new ErrorResponse(command.CommandName, NTStatus.STATUS_NOT_SUPPORTED);
|
return new ErrorResponse(command.CommandName, NTStatus.STATUS_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TrySendResponse(ConnectionState state, SMB2Command response)
|
private static void TrySendResponse(ConnectionState state, SMB2Command response)
|
||||||
{
|
{
|
||||||
SessionMessagePacket packet = new SessionMessagePacket();
|
SessionMessagePacket packet = new SessionMessagePacket();
|
||||||
packet.Trailer = response.GetBytes();
|
packet.Trailer = response.GetBytes();
|
||||||
|
@ -230,7 +230,7 @@ namespace SMBLibrary.Server
|
||||||
state.LogToServer(Severity.Verbose, "SMB2 response sent: {0}, Packet length: {1}", response.CommandName.ToString(), packet.Length);
|
state.LogToServer(Severity.Verbose, "SMB2 response sent: {0}, Packet length: {1}", response.CommandName.ToString(), packet.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TrySendResponseChain(ConnectionState state, List<SMB2Command> responseChain)
|
private static void TrySendResponseChain(ConnectionState state, List<SMB2Command> responseChain)
|
||||||
{
|
{
|
||||||
byte[] sessionKey = null;
|
byte[] sessionKey = null;
|
||||||
if (state is SMB2ConnectionState)
|
if (state is SMB2ConnectionState)
|
||||||
|
|
|
@ -181,7 +181,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessConnectionBuffer(ref ConnectionState state)
|
private void ProcessConnectionBuffer(ref ConnectionState state)
|
||||||
{
|
{
|
||||||
Socket clientSocket = state.ClientSocket;
|
Socket clientSocket = state.ClientSocket;
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessPacket(SessionPacket packet, ref ConnectionState state)
|
private void ProcessPacket(SessionPacket packet, ref ConnectionState state)
|
||||||
{
|
{
|
||||||
if (packet is SessionRequestPacket && m_transport == SMBTransportType.NetBiosOverTCP)
|
if (packet is SessionRequestPacket && m_transport == SMBTransportType.NetBiosOverTCP)
|
||||||
{
|
{
|
||||||
|
@ -311,7 +311,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TrySendPacket(ConnectionState state, SessionPacket response)
|
private static void TrySendPacket(ConnectionState state, SessionPacket response)
|
||||||
{
|
{
|
||||||
Socket clientSocket = state.ClientSocket;
|
Socket clientSocket = state.ClientSocket;
|
||||||
try
|
try
|
||||||
|
@ -326,7 +326,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Log(Severity severity, string message)
|
private void Log(Severity severity, string message)
|
||||||
{
|
{
|
||||||
// To be thread-safe we must capture the delegate reference first
|
// To be thread-safe we must capture the delegate reference first
|
||||||
EventHandler<LogEntry> handler = OnLogEntry;
|
EventHandler<LogEntry> handler = OnLogEntry;
|
||||||
|
@ -336,7 +336,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Log(Severity severity, string message, params object[] args)
|
private void Log(Severity severity, string message, params object[] args)
|
||||||
{
|
{
|
||||||
Log(severity, String.Format(message, args));
|
Log(severity, String.Format(message, args));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue