Files
agentic-pentest-mcp/README.md
T

123 lines
4.3 KiB
Markdown
Raw Normal View History

2026-11-05 21:19:54 -07:00
# Agentic Penetration Testing MCP Server & Implant
An MCP (Model Context Protocol) server and implant pair for autonomous penetration testing. The AI agent calls pentest tools through the MCP server, which queues commands that implants pick up via outbound beaconing — no inbound ports needed on target networks.
## Architecture
```
┌─────────┐ ┌──────────────┐ ┌─────────────────┐ ┌──────────┐
│ Agent │────▶│ MCP Client │────▶│ MCP Server │◀────│ Implant │
│ (Bionic)│ │ (FastMCP) │ │ (command queue) │ │ (Kali) │
└─────────┘ └──────────────┘ └─────────────────┘ └──────────┘
▲ beacons out
│ periodically
```
**Beaconing Flow:**
1. Agent calls MCP tool (e.g., `nmap_scan`) → command queued on server
2. Implant periodically POSTs to `/check_in` endpoint
3. Server returns any pending commands for that implant
4. Implant executes commands locally, reports results via `/report_result`
5. Agent retrieves results using `get_result(request_id)`
This works through NAT/firewalls because the implant only makes outbound connections.
## Components
### MCP Server (`server.py`)
- Exposes pentest tools via FastMCP
- Maintains command queue per implant
- HTTP endpoint for implant check-ins (port 8001)
- MCP transport on port 8000
### Implant (`implant.py`)
- Runs on target network (Kali host)
- Beacons out every N seconds to check for commands
- Executes nmap scans, shell commands, etc. locally
- Reports results back to MCP server
## Setup
```bash
# Install dependencies
pip install -r requirements.txt
# Start MCP server
python server.py --http 8000
# Start implant (on target network)
export MCP_SERVER_URL="http://<mcp-server-ip>:8001"
python implant.py --id test-implant --interval 30
```
## Available Tools
| Tool | Description | Parameters |
|------|-------------|------------|
| `nmap_scan` | Queue nmap scan on implant | target, scan_type, ports, output_format |
| `list_network_interfaces` | List implant's network interfaces | implant_id (optional) |
| `run_command` | Execute shell command on implant | command, implant_id (optional) |
| `get_result` | Retrieve result of queued command | request_id |
| `list_implants` | Show all registered implants | none |
| `server_status` | Check MCP server status | none |
### nmap_scan Parameters
- **target**: IP address or hostname to scan (required)
- **scan_type**: Nmap flags (default: `-sT`). Options: `-sS`, `-sT`, `-sU`, `-sV`
- **ports**: Port spec like `"80,443"` or `"1-1024"`. Default: top 1000
- **output_format**: `normal`, `xml`, or `grepable`. Default: normal
## Proxmox LXC Deployment (MCP Server)
To host the MCP server 24/7 in a Proxmox LXC container:
### Create LXC Container
```bash
pct create <CTID> local:vztmpl/ubuntu-24.04-standard_24.04-1_amd64.tar.gz \
--password yourpassword \
--hostname mcp-pentest \
--net0 name=eth0,bridge=vmbr0,ip=<IP>/24,gw=<GATEWAY> \
--unprivileged 1
```
### Deploy Application
```bash
pct push <CTID> agentic-pentest-mcp/ /opt/agentic-pentest-mcp/
pct enter <CTID>
cd /opt/agentic-pentest-mcp
apt update && apt install -y python3 python3-venv nmap
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```
### Configure and Start
```bash
# Run server (listens on :8000 for MCP, :8001 for implant beacons)
python server.py --http 8000 &
```
### Auto-start on Boot
Create a systemd service or add to `/etc/rc.local`:
```bash
#!/bin/bash
cd /opt/agentic-pentest-mcp
source .venv/bin/activate
python server.py --http 8000 &
```
### Verify Deployment
```bash
# Check MCP server is running
curl http://localhost:8000/mcp
# From Bionic/LM Studio, connect to:
# http://<lxc-ip>:8000/mcp
```
## Security Considerations
- Currently no authentication between components — run on trusted networks
- `run_command` tool is powerful; consider restricting in production
- Use HTTPS transport for remote deployments
- Implant IDs are simple strings; use UUIDs for multi-implant environments