db_services
List all services discovered during penetration testing to analyze network exposure and identify potential attack vectors for security assessments.
Instructions
List all services in the current workspace
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | No | Optional: filter by host IP address |
Input Schema (JSON Schema)
{
"properties": {
"host": {
"description": "Optional: filter by host IP address",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/index.ts:508-545 (handler)Handler for the 'db_services' tool. Extracts optional 'host' parameter, constructs msfconsole 'services' command (filtered by host if provided), executes it, and returns JSON-formatted results or error.case "db_services": { const { host } = args as { host?: string }; const commands = host ? [`services -R ${host}`] : [`services`]; try { const services = await executeMsfCommand(commands); return { content: [ { type: "text", text: JSON.stringify( { success: true, host: host || "all", services, }, null, 2 ), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: error.message, }), }, ], }; } }
- src/index.ts:166-178 (registration)Registration of the 'db_services' tool in the tools array, including name, description, and input schema. This is returned by ListToolsRequestSchema handler.{ name: "db_services", description: "List all services in the current workspace", inputSchema: { type: "object", properties: { host: { type: "string", description: "Optional: filter by host IP address", }, }, }, },
- src/index.ts:169-177 (schema)Input schema definition for 'db_services' tool, defining optional 'host' string parameter.inputSchema: { type: "object", properties: { host: { type: "string", description: "Optional: filter by host IP address", }, }, },
- src/index.ts:27-40 (helper)Shared helper function used by 'db_services' handler to execute 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"); } }