Class: Msf::MCP::Tools::ModuleCheck
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- Msf::MCP::Tools::ModuleCheck
- Extended by:
- ToolHelper
- Defined in:
- lib/msf/core/mcp/tools/module_check.rb
Overview
MCP Tool: Run a Module’s Check Method
Invokes the Metasploit Framework ‘module.check` RPC endpoint. Returns the job_id and run UUID for polling via ModuleResults. When the module does not implement a check method, returns a structured `status: unsupported` response instead of an error.
Constant Summary collapse
- CHECK_SUPPORTED_TYPES =
Module types accepted by module.check.
%w[exploit auxiliary].freeze
- UNSUPPORTED_CHECK_MESSAGE =
Message the module.check RPC returns when a module has no check method.
'This module does not support check.'
Constants included from ToolHelper
ToolHelper::DANGEROUS_MODE_DISABLED_MESSAGE
Class Method Summary collapse
-
.call(type:, name:, options:, server_context:) ⇒ MCP::Tool::Response
Execute module check.
Methods included from ToolHelper
dangerous_mode_required!, tool_error_response, with_tool_context
Class Method Details
.call(type:, name:, options:, server_context:) ⇒ MCP::Tool::Response
Execute module check
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/msf/core/mcp/tools/module_check.rb', line 94 def call(type:, name:, options:, server_context:) with_tool_context(server_context, 'module_check', dangerous: true) do |msf_client| Msf::MCP::Security::InputValidator.validate_parameter!('Module type', type, CHECK_SUPPORTED_TYPES) Msf::MCP::Security::InputValidator.validate_module_name!(name) Msf::MCP::Security::InputValidator.() # MCP deep-symbolizes JSON input; the Metasploit datastore is keyed by Strings. = .transform_keys(&:to_s) api_error = nil raw_result, elapsed = Rex::Stopwatch.elapsed_time do msf_client.module_check(type, name, ) rescue Msf::MCP::Metasploit::APIError => e api_error = e end = { query_time: elapsed.round(3) } data = if api_error raise api_error unless api_error..include?(UNSUPPORTED_CHECK_MESSAGE) { status: 'unsupported', message: 'Module does not implement a check method' } else { job_id: raw_result['job_id'], uuid: raw_result['uuid'] } end ::MCP::Tool::Response.new( [{ type: 'text', text: JSON.generate(metadata: , data: data) }], structured_content: { metadata: , data: data } ) end end |