credentials.ts•3.15 kB
/**
* Credentials-related MCP tools
*/
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { CobaltStrikeClient } from '../api/client.js';
export function createCredentialsTools(client: CobaltStrikeClient): Tool[] {
return [
{
name: 'list_credentials',
description: 'List all stored credentials in the Cobalt Strike teamserver',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'get_credential',
description: 'Get detailed information about a specific credential by ID',
inputSchema: {
type: 'object',
properties: {
credentialId: {
type: 'string',
description: 'The ID of the credential to retrieve',
},
},
required: ['credentialId'],
},
},
{
name: 'create_credential',
description: 'Create a new credential entry',
inputSchema: {
type: 'object',
properties: {
user: {
type: 'string',
description: 'Username',
},
password: {
type: 'string',
description: 'Password',
},
realm: {
type: 'string',
description: 'Realm/domain',
},
host: {
type: 'string',
description: 'Host where credential was obtained',
},
note: {
type: 'string',
description: 'Optional note about the credential',
},
source: {
type: 'string',
description: 'Source of the credential (e.g., "hashdump", "mimikatz")',
},
},
required: ['user', 'password', 'realm'],
},
},
{
name: 'delete_credential',
description: 'Delete a credential from the teamserver',
inputSchema: {
type: 'object',
properties: {
credentialId: {
type: 'string',
description: 'The ID of the credential to delete',
},
},
required: ['credentialId'],
},
},
];
}
export async function handleCredentialsTool(
name: string,
args: any,
client: CobaltStrikeClient
): Promise<string> {
switch (name) {
case 'list_credentials':
const credentials = await client.listCredentials();
return JSON.stringify(credentials, null, 2);
case 'get_credential':
const credential = await client.getCredential(args.credentialId);
return JSON.stringify(credential, null, 2);
case 'create_credential':
const newCredential = await client.createCredential(
args.user,
args.password,
args.realm,
args.host,
args.note,
args.source
);
return JSON.stringify(newCredential, null, 2);
case 'delete_credential':
const deleted = await client.deleteCredential(args.credentialId);
return JSON.stringify({ success: deleted, message: deleted ? 'Credential deleted successfully' : 'Failed to delete credential' }, null, 2);
default:
throw new Error(`Unknown credentials tool: ${name}`);
}
}