bof.ts•3 kB
/**
* BOF (Beacon Object File) related MCP tools
*/
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { CobaltStrikeClient } from '../api/client.js';
export function createBOFTools(client: CobaltStrikeClient): Tool[] {
return [
{
name: 'execute_bof',
description: 'Execute a BOF (Beacon Object File) on a beacon. Common BOFs: @artifacts/BOFs/whoami.x64.o, @artifacts/BOFs/whoami.x86.o',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
bofPath: {
type: 'string',
description: 'Path to BOF file (e.g., @artifacts/BOFs/whoami.x64.o)',
},
arguments: {
type: 'string',
description: 'Optional arguments for the BOF',
},
},
required: ['beaconId', 'bofPath'],
},
},
{
name: 'execute_bof_pack',
description: 'Execute a BOF with packing',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
bofPath: {
type: 'string',
description: 'Path to BOF file',
},
arguments: {
type: 'string',
description: 'Optional arguments for the BOF',
},
},
required: ['beaconId', 'bofPath'],
},
},
{
name: 'execute_bof_packed',
description: 'Execute a packed BOF',
inputSchema: {
type: 'object',
properties: {
beaconId: {
type: 'string',
description: 'The ID of the beacon',
},
bofPath: {
type: 'string',
description: 'Path to packed BOF file',
},
arguments: {
type: 'string',
description: 'Optional arguments for the BOF',
},
},
required: ['beaconId', 'bofPath'],
},
},
];
}
export async function handleBOFTool(
name: string,
args: any,
client: CobaltStrikeClient
): Promise<string> {
switch (name) {
case 'execute_bof':
const taskId = await client.executeBOF(args.beaconId, args.bofPath, args.arguments);
return JSON.stringify({ taskId, message: 'BOF execution submitted. Use get_task to retrieve results.' }, null, 2);
case 'execute_bof_pack':
const packTaskId = await client.executeBOFPack(args.beaconId, args.bofPath, args.arguments);
return JSON.stringify({ taskId: packTaskId, message: 'BOF pack execution submitted' }, null, 2);
case 'execute_bof_packed':
const packedTaskId = await client.executeBOFPacked(args.beaconId, args.bofPath, args.arguments);
return JSON.stringify({ taskId: packedTaskId, message: 'BOF packed execution submitted' }, null, 2);
default:
throw new Error(`Unknown BOF tool: ${name}`);
}
}