utilities.ts•3.5 kB
/**
* Utility operation-related MCP tools
*/
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { CobaltStrikeClient } from '../api/client.js';
export function createUtilityTools(client: CobaltStrikeClient): Tool[] {
return [
{
name: 'get_artifacts',
description: 'List available artifacts (BOFs, etc.)',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'get_beacon_active_downloads',
description: 'Get active file downloads for a beacon',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
},
required: ['beaconId'],
},
},
{
name: 'clear_beacon_command_queue',
description: 'Clear the command queue for a beacon',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
},
required: ['beaconId'],
},
},
{
name: 'get_beacon_help',
description: 'Get help for beacon commands',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
},
required: ['beaconId'],
},
},
{
name: 'get_beacon_command_help',
description: 'Get help for a specific beacon command',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
command: {
type: 'string',
description: 'Command name to get help for',
},
},
required: ['beaconId', 'command'],
},
},
{
name: 'get_beacon_keystrokes',
description: 'Get keystrokes for a beacon',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
},
required: ['beaconId'],
},
},
];
}
export async function handleUtilityTool(
name: string,
args: any,
client: CobaltStrikeClient
): Promise<string> {
switch (name) {
case 'get_artifacts':
const artifacts = await client.getArtifacts();
return JSON.stringify(artifacts, null, 2);
case 'get_beacon_active_downloads':
const downloads = await client.getBeaconActiveDownloads(args.beaconId);
return JSON.stringify(downloads, null, 2);
case 'clear_beacon_command_queue':
const cleared = await client.clearBeaconCommandQueue(args.beaconId);
return JSON.stringify({ success: cleared, message: cleared ? 'Command queue cleared' : 'Failed to clear command queue' }, null, 2);
case 'get_beacon_help':
const help = await client.getBeaconHelp(args.beaconId);
return JSON.stringify(help, null, 2);
case 'get_beacon_command_help':
const commandHelp = await client.getBeaconCommandHelp(args.beaconId, args.command);
return JSON.stringify(commandHelp, null, 2);
case 'get_beacon_keystrokes':
const keystrokes = await client.getBeaconKeystrokes(args.beaconId);
return JSON.stringify(keystrokes, null, 2);
default:
throw new Error(`Unknown utility tool: ${name}`);
}
}