Class: Msf::MCP::Tools::SessionWrite
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- Msf::MCP::Tools::SessionWrite
- Extended by:
- ToolHelper
- Defined in:
- lib/msf/core/mcp/tools/session_write.rb
Overview
MCP Tool: Send Input to an Interactive Session
Wraps the ‘session.interactive_write` RPC endpoint. The provided data is forwarded to the session for processing (meterpreter, database, SMB, LDAP, shell, powershell).
Constant Summary
Constants included from ToolHelper
ToolHelper::DANGEROUS_MODE_DISABLED_MESSAGE
Class Method Summary collapse
-
.call(session_id:, data:, server_context:) ⇒ MCP::Tool::Response
Write to an interactive session.
Methods included from ToolHelper
dangerous_mode_required!, tool_error_response, with_tool_context
Class Method Details
.call(session_id:, data:, server_context:) ⇒ MCP::Tool::Response
Write to an interactive session
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/msf/core/mcp/tools/session_write.rb', line 71 def call(session_id:, data:, server_context:) with_tool_context(server_context, 'session_write', dangerous: true) do |msf_client| Msf::MCP::Security::InputValidator.validate_session_id!(session_id) Msf::MCP::Security::InputValidator.validate_session_data!(data) raw_result, elapsed = Rex::Stopwatch.elapsed_time do msf_client.session_write(session_id, data) end response_data = { result: raw_result['result'] } = { query_time: elapsed.round(3) } ::MCP::Tool::Response.new( [{ type: 'text', text: JSON.generate(metadata: , data: response_data) }], structured_content: { metadata: , data: response_data } ) end end |