mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-08-15 03:33:47 +02:00
Renamed SMBMessage to SMB1Message
This commit is contained in:
parent
2342765afb
commit
6700166f5a
4 changed files with 16 additions and 16 deletions
|
@ -40,12 +40,12 @@ namespace SMBLibrary.Client
|
||||||
|
|
||||||
public static void TrySendMessage(Socket serverSocket, SMB1Command request)
|
public static void TrySendMessage(Socket serverSocket, SMB1Command request)
|
||||||
{
|
{
|
||||||
SMBMessage message = new SMBMessage();
|
SMB1Message message = new SMB1Message();
|
||||||
message.Commands.Add(request);
|
message.Commands.Add(request);
|
||||||
TrySendMessage(serverSocket, message);
|
TrySendMessage(serverSocket, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TrySendMessage(Socket serverSocket, SMBMessage message)
|
public static void TrySendMessage(Socket serverSocket, SMB1Message message)
|
||||||
{
|
{
|
||||||
SessionMessagePacket packet = new SessionMessagePacket();
|
SessionMessagePacket packet = new SessionMessagePacket();
|
||||||
packet.Trailer = message.GetBytes();
|
packet.Trailer = message.GetBytes();
|
||||||
|
|
|
@ -16,17 +16,17 @@ namespace SMBLibrary.SMB1
|
||||||
/// Each message has a single header and either a single command or multiple batched (AndX) commands.
|
/// Each message has a single header and either a single command or multiple batched (AndX) commands.
|
||||||
/// Multiple command requests or responses can be sent in a single message.
|
/// Multiple command requests or responses can be sent in a single message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SMBMessage
|
public class SMB1Message
|
||||||
{
|
{
|
||||||
public SMB1Header Header;
|
public SMB1Header Header;
|
||||||
public List<SMB1Command> Commands = new List<SMB1Command>();
|
public List<SMB1Command> Commands = new List<SMB1Command>();
|
||||||
|
|
||||||
public SMBMessage()
|
public SMB1Message()
|
||||||
{
|
{
|
||||||
Header = new SMB1Header();
|
Header = new SMB1Header();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SMBMessage(byte[] buffer)
|
public SMB1Message(byte[] buffer)
|
||||||
{
|
{
|
||||||
Header = new SMB1Header(buffer);
|
Header = new SMB1Header(buffer);
|
||||||
SMB1Command command = SMB1Command.ReadCommand(buffer, SMB1Header.Length, Header.Command, Header);
|
SMB1Command command = SMB1Command.ReadCommand(buffer, SMB1Header.Length, Header.Command, Header);
|
||||||
|
@ -110,13 +110,13 @@ namespace SMBLibrary.SMB1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SMBMessage GetSMBMessage(byte[] buffer)
|
public static SMB1Message GetSMBMessage(byte[] buffer)
|
||||||
{
|
{
|
||||||
if (!IsValidSMBMessage(buffer))
|
if (!IsValidSMBMessage(buffer))
|
||||||
{
|
{
|
||||||
throw new InvalidRequestException("Invalid SMB message signature");;
|
throw new InvalidRequestException("Invalid SMB message signature");;
|
||||||
}
|
}
|
||||||
return new SMBMessage(buffer);
|
return new SMB1Message(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -276,7 +276,7 @@
|
||||||
<Compile Include="SMB1\NTTransactSubcommands\NTTransactSubcommand.cs" />
|
<Compile Include="SMB1\NTTransactSubcommands\NTTransactSubcommand.cs" />
|
||||||
<Compile Include="SMB1\SMB1Header.cs" />
|
<Compile Include="SMB1\SMB1Header.cs" />
|
||||||
<Compile Include="SMB1\SMB1Helper.cs" />
|
<Compile Include="SMB1\SMB1Helper.cs" />
|
||||||
<Compile Include="SMB1\SMBMessage.cs" />
|
<Compile Include="SMB1\SMB1Message.cs" />
|
||||||
<Compile Include="SMB1\Transaction2Subcommands\Enums\ExtendedAttributeFlag.cs" />
|
<Compile Include="SMB1\Transaction2Subcommands\Enums\ExtendedAttributeFlag.cs" />
|
||||||
<Compile Include="SMB1\Transaction2Subcommands\Enums\FindFlags.cs" />
|
<Compile Include="SMB1\Transaction2Subcommands\Enums\FindFlags.cs" />
|
||||||
<Compile Include="SMB1\Transaction2Subcommands\Enums\FindInformationLevel.cs" />
|
<Compile Include="SMB1\Transaction2Subcommands\Enums\FindInformationLevel.cs" />
|
||||||
|
|
|
@ -200,14 +200,14 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
else if (packet is SessionMessagePacket)
|
else if (packet is SessionMessagePacket)
|
||||||
{
|
{
|
||||||
SMBMessage message = null;
|
SMB1Message message = null;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
message = SMBMessage.GetSMBMessage(packet.Trailer);
|
message = SMB1Message.GetSMBMessage(packet.Trailer);
|
||||||
System.Diagnostics.Debug.Print("[{0}] Message Received: {1} Commands, First Command: {2}, Packet length: {3}", DateTime.Now.ToString("HH:mm:ss:ffff"), message.Commands.Count, message.Commands[0].CommandName.ToString(), packet.Length);
|
System.Diagnostics.Debug.Print("[{0}] Message Received: {1} Commands, First Command: {2}, Packet length: {3}", DateTime.Now.ToString("HH:mm:ss:ffff"), message.Commands.Count, message.Commands[0].CommandName.ToString(), packet.Length);
|
||||||
#else
|
#else
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
message = SMBMessage.GetSMBMessage(packet.Trailer);
|
message = SMB1Message.GetSMBMessage(packet.Trailer);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
@ -225,9 +225,9 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessMessage(SMBMessage message, StateObject state)
|
public void ProcessMessage(SMB1Message message, StateObject state)
|
||||||
{
|
{
|
||||||
SMBMessage reply = new SMBMessage();
|
SMB1Message reply = new SMB1Message();
|
||||||
PrepareResponseHeader(reply, message);
|
PrepareResponseHeader(reply, message);
|
||||||
List<SMB1Command> sendQueue = new List<SMB1Command>();
|
List<SMB1Command> sendQueue = new List<SMB1Command>();
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ namespace SMBLibrary.Server
|
||||||
|
|
||||||
foreach (SMB1Command command in sendQueue)
|
foreach (SMB1Command command in sendQueue)
|
||||||
{
|
{
|
||||||
SMBMessage secondaryReply = new SMBMessage();
|
SMB1Message secondaryReply = new SMB1Message();
|
||||||
secondaryReply.Header = reply.Header;
|
secondaryReply.Header = reply.Header;
|
||||||
secondaryReply.Commands.Add(command);
|
secondaryReply.Commands.Add(command);
|
||||||
TrySendMessage(state, secondaryReply);
|
TrySendMessage(state, secondaryReply);
|
||||||
|
@ -524,7 +524,7 @@ namespace SMBLibrary.Server
|
||||||
return new ErrorResponse(command.CommandName);
|
return new ErrorResponse(command.CommandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TrySendMessage(StateObject state, SMBMessage reply)
|
public static void TrySendMessage(StateObject state, SMB1Message reply)
|
||||||
{
|
{
|
||||||
SessionMessagePacket packet = new SessionMessagePacket();
|
SessionMessagePacket packet = new SessionMessagePacket();
|
||||||
packet.Trailer = reply.GetBytes();
|
packet.Trailer = reply.GetBytes();
|
||||||
|
@ -547,7 +547,7 @@ namespace SMBLibrary.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PrepareResponseHeader(SMBMessage response, SMBMessage request)
|
private static void PrepareResponseHeader(SMB1Message response, SMB1Message request)
|
||||||
{
|
{
|
||||||
response.Header.Status = NTStatus.STATUS_SUCCESS;
|
response.Header.Status = NTStatus.STATUS_SUCCESS;
|
||||||
response.Header.Flags = HeaderFlags.CaseInsensitive | HeaderFlags.CanonicalizedPaths | HeaderFlags.Reply;
|
response.Header.Flags = HeaderFlags.CaseInsensitive | HeaderFlags.CanonicalizedPaths | HeaderFlags.Reply;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue