search_exploits
Search the Metasploit database for exploits using keywords, CVE identifiers, or platform filters to identify vulnerabilities for authorized security testing.
Instructions
Search for exploits in Metasploit database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (e.g., 'windows smb', 'apache', 'CVE-2021-44228') | |
| platform | No | Optional: Filter by platform (windows, linux, etc.) |
Implementation Reference
- src/index.ts:248-286 (handler)Handler for the 'search_exploits' tool. Parses input arguments (query and optional platform), constructs Metasploit 'search' command, executes it via msfconsole, and returns results or error in JSON format.case "search_exploits": { const { query, platform } = args as { query: string; platform?: string }; const commands = platform ? [`search platform:${platform} ${query}`] : [`search ${query}`]; try { const results = await executeMsfCommand(commands); return { content: [ { type: "text", text: JSON.stringify( { success: true, query, platform: platform || null, results, }, null, 2 ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: error.message, }), }, ], }; } }
- src/index.ts:72-89 (registration)Registration of the 'search_exploits' tool in the MCP tools list, including name, description, and input schema definition.{ name: "search_exploits", description: "Search for exploits in Metasploit database", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query (e.g., 'windows smb', 'apache', 'CVE-2021-44228')", }, platform: { type: "string", description: "Optional: Filter by platform (windows, linux, etc.)", }, }, required: ["query"], }, },
- src/index.ts:75-88 (schema)Input schema for the 'search_exploits' tool defining the expected parameters: required 'query' string and optional 'platform' string.inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query (e.g., 'windows smb', 'apache', 'CVE-2021-44228')", }, platform: { type: "string", description: "Optional: Filter by platform (windows, linux, etc.)", }, }, required: ["query"], },
- src/index.ts:27-40 (helper)Shared helper function used by search_exploits (and other tools) to execute arbitrary msfconsole commands asynchronously.async function executeMsfCommand(commands: string[]): Promise<string> { const commandString = commands.join("; "); const fullCommand = `msfconsole -q -x "${commandString}; exit"`; try { const { stdout, stderr } = await execAsync(fullCommand, { timeout: 60000, // 60 second timeout maxBuffer: 10 * 1024 * 1024, // 10MB buffer }); return stdout || stderr; } catch (error: any) { throw new Error(error.message || "Command execution failed"); } }