remoteexec.ts•2.17 kB
/**
* Remote execution operation-related MCP tools
*/
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { CobaltStrikeClient } from '../api/client.js';
export function createRemoteExecTools(client: CobaltStrikeClient): Tool[] {
return [
{
name: 'remoteExec_beacon',
description: 'Remotely execute a beacon on a target',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
target: {
type: 'string',
description: 'Target hostname or IP',
},
listener: {
type: 'string',
description: 'Listener name for the remote beacon',
},
},
required: ['beaconId', 'target', 'listener'],
},
},
{
name: 'remoteExec_command',
description: 'Remotely execute a command on a target',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
target: {
type: 'string',
description: 'Target hostname or IP',
},
command: {
type: 'string',
description: 'Command to execute',
},
},
required: ['beaconId', 'target', 'command'],
},
},
];
}
export async function handleRemoteExecTool(
name: string,
args: any,
client: CobaltStrikeClient
): Promise<string> {
switch (name) {
case 'remoteExec_beacon':
const remoteBeaconResult = await client.remoteExecBeacon(args.beaconId, args.target, args.listener);
return JSON.stringify({ taskId: remoteBeaconResult, message: 'Remote exec beacon command submitted' }, null, 2);
case 'remoteExec_command':
const remoteCommandResult = await client.remoteExecCommand(args.beaconId, args.target, args.command);
return JSON.stringify({ taskId: remoteCommandResult, message: 'Remote exec command submitted' }, null, 2);
default:
throw new Error(`Unknown remoteExec tool: ${name}`);
}
}