metasploit_search
Find Metasploit modules by searching for specific services or platforms to identify relevant exploits and auxiliary tools for security testing.
Instructions
Search for Metasploit modules based on detected services
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| platform | No | Target platform | |
| service | Yes | Service name or version |
Input Schema (JSON Schema)
{
"properties": {
"platform": {
"description": "Target platform",
"type": "string"
},
"service": {
"description": "Service name or version",
"type": "string"
}
},
"required": [
"service"
],
"type": "object"
}
Implementation Reference
- src/tools/exploit.ts:32-72 (handler)Main handler function that executes msfconsole search for the given service (optionally filtered by platform), parses the output using parseMetasploitSearch, and returns a structured 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/tools/exploit.ts:153-176 (helper)Helper function to parse the stdout output from msfconsole search command into an array of MetasploitModule objects.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/index.ts:177-187 (schema)Tool schema definition including input schema for service (required) and optional platform parameters.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-529 (registration)Tool dispatch/registration in the main switch statement that calls the exploitTools.metasploitSearch method.case "metasploit_search": return respond(await this.exploitTools.metasploitSearch(args.service, args.platform));
- src/tools/exploit.ts:20-28 (schema)Type definition/interface for Metasploit modules returned in the search results.export interface MetasploitModule { name: string; description: string; platform: string[]; targets: string[]; rank: string; disclosed: string; references: string[]; }