metasploit_search
Search Metasploit modules by service or platform to identify relevant exploits for penetration testing and security assessments.
Instructions
Search for Metasploit modules based on detected services
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| service | Yes | Service name or version | |
| platform | No | Target platform |
Implementation Reference
- src/tools/exploit.ts:32-72 (handler)Main handler function that executes Metasploit search via msfconsole, parses output, and returns ScanResult.async metasploitSearch(service: string, platform?: string): Promise<ScanResult> { try { let command = `msfconsole -q -x "search ${service}`; if (platform) { command += ` platform:${platform}`; } command += '; exit"'; console.error(`Executing: ${command}`); const { stdout, stderr } = await execAsync(command, { timeout: 60000 // 1 min timeout }); const modules = this.parseMetasploitSearch(stdout); return { target: service, timestamp: new Date().toISOString(), tool: 'metasploit_search', results: { modules, total_found: modules.length, search_query: service, platform_filter: platform }, status: 'success' }; } catch (error) { return { target: service, timestamp: new Date().toISOString(), tool: 'metasploit_search', results: {}, status: 'error', error: error instanceof Error ? error.message : String(error) }; } }
- src/index.ts:177-187 (schema)MCP tool schema defining input parameters: service (required), platform (optional).name: "metasploit_search", description: "Search for Metasploit modules based on detected services", inputSchema: { type: "object", properties: { service: { type: "string", description: "Service name or version" }, platform: { type: "string", description: "Target platform" } }, required: ["service"] } },
- src/index.ts:528-530 (registration)Tool dispatch registration in the main switch statement that routes calls to the exploitTools.metasploitSearch method.case "metasploit_search": return respond(await this.exploitTools.metasploitSearch(args.service, args.platform));
- src/tools/exploit.ts:153-176 (helper)Helper function to parse Metasploit console search output into structured MetasploitModule array.private parseMetasploitSearch(output: string): MetasploitModule[] { const modules: MetasploitModule[] = []; const lines = output.split('\n'); for (const line of lines) { // Parse metasploit module output if (line.includes('exploit/') || line.includes('auxiliary/')) { const parts = line.trim().split(/\s+/); if (parts.length >= 3) { modules.push({ name: parts[0], description: parts.slice(2).join(' '), platform: [], // Would need more detailed parsing targets: [], rank: parts[1] || 'Unknown', disclosed: '', references: [] }); } } } return modules; }
- src/tools/exploit.ts:20-28 (schema)TypeScript interface defining the structure of Metasploit modules returned by the tool.export interface MetasploitModule { name: string; description: string; platform: string[]; targets: string[]; rank: string; disclosed: string; references: string[]; }