private static void EnqueueResponseChain(ConnectionState state, List <SMB2Command> responseChain) { byte[] signingKey = null; if (state is SMB2ConnectionState) { // Note: multiple sessions MAY be multiplexed on the same connection, so theoretically // we could have compounding unrelated requests from different sessions. // In practice however this is not a real problem. ulong sessionID = responseChain[0].Header.SessionID; if (sessionID != 0) { SMB2Session session = ((SMB2ConnectionState)state).GetSession(sessionID); if (session != null) { signingKey = session.SigningKey; } } } SessionMessagePacket packet = new SessionMessagePacket(); SMB2Dialect smb2Dialect = (signingKey != null) ? ToSMB2Dialect(state.Dialect) : SMB2Dialect.SMB2xx; packet.Trailer = SMB2Command.GetCommandChainBytes(responseChain, signingKey, smb2Dialect); state.SendQueue.Enqueue(packet); state.LogToServer(Severity.Verbose, "SMB2 response chain queued: Response count: {0}, First response: {1}, Packet length: {2}", responseChain.Count, responseChain[0].CommandName.ToString(), packet.Length); }
public static void TrySendCommand(Socket socket, SMB2Command request) { SessionMessagePacket packet = new SessionMessagePacket(); packet.Trailer = request.GetBytes(); TrySendPacket(socket, packet); }
public static Task TrySendCommandAsync(Socket socket, SMB2Command request, CancellationToken cancellationToken = default) { SessionMessagePacket packet = new SessionMessagePacket(); packet.Trailer = request.GetBytes(); return(TrySendPacketAsync(socket, packet, cancellationToken)); }
public static void TrySendMessage(Socket socket, SMB1Message message) { SessionMessagePacket packet = new SessionMessagePacket(); packet.Trailer = message.GetBytes(); TrySendPacket(socket, packet); }
private static void EnqueueMessage(ConnectionState state, SMB1Message response) { SessionMessagePacket packet = new SessionMessagePacket(); packet.Trailer = response.GetBytes(); state.SendQueue.Enqueue(packet); state.LogToServer(Severity.Verbose, "SMB1 message queued: {0} responses, First response: {1}, Packet length: {2}", response.Commands.Count, response.Commands[0].CommandName.ToString(), packet.Length); }
private static void EnqueueResponse(ConnectionState state, SMB2Command response) { SessionMessagePacket packet = new SessionMessagePacket(); packet.Trailer = response.GetBytes(); state.SendQueue.Enqueue(packet); state.LogToServer(Severity.Verbose, "SMB2 response queued: {0}, Packet length: {1}", response.CommandName.ToString(), packet.Length); }
public static void TrySendMessage(StateObject state, SMBMessage reply) { SessionMessagePacket packet = new SessionMessagePacket(); packet.Trailer = reply.GetBytes(); TrySendPacket(state, packet); #if DEBUG Log("[{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); #endif }
public static ulong TrySendCommand(Socket socket, SMB2Command request) { ulong ret = 0; SessionMessagePacket packet = new SessionMessagePacket(); packet.Trailer = request.GetBytes(); if (TrySendPacket(socket, packet)) { ret = request.Header.MessageID; } return(ret); }
public static void TrySendCommand(Socket socket, SMB2Command request, byte[] encryptionKey) { SessionMessagePacket packet = new SessionMessagePacket(); if (encryptionKey != null) { byte[] requestBytes = request.GetBytes(); packet.Trailer = SMB2Cryptography.TransformMessage(encryptionKey, requestBytes, request.Header.SessionID); } else { packet.Trailer = request.GetBytes(); } TrySendPacket(socket, packet); }