Files
2026-11-22 16:32:37 -07:00

92 lines
4.5 KiB
Markdown

# Agentic Pentest MCP
*For educational/testing purposes only.*
Pentest networks with a local agent!
This is an **MCP (Model Context Protocol) server** paired with a beaconing implant. The server queues commands from your AI agent, and the implant on the target network periodically checks in to pick up and execute them.
## Quick Setup
1. Start a fresh Debian 13 server
2. Clone this repo to the server: `git clone https://creinky.io/creinky/agentic-pentest-mcp`
3. On the server run `setup.sh` in the directory you cloned to
4. Connect your agent to the MCP at `http://<mcp-server-ip>:8000/mcp` and enter your API key if set
5. Copy `imlpant.py` and `install_implant_service.sh` to your implant
6. On the implant run `install_implant_service.sh`
> **Optional:** Set an API key for authentication. On the server, export `MCP_API_KEY="your-key"` before starting. When installing the implant service, enter the same key when prompted.
*Tested and working with both the server and implant running Debian 13*
Custom Debian 13 implant image coming.
---
This agentic C2 framework utilizes a local model, an MCP server, and an implant that beacons to the MCP. You should set system instructions for your agent so it knows what to do when you ask it to run commands. Here are the system instructions I use:
```
You have access to an MCP server (mcp-name) that relays commands to implants on target networks. The implant executes actual pentest tools and returns results via a beacon cycle (~30 second intervals).
Architecture:
You → MCP Server (port 8000) → Command Queue → Implant beacons in (port 8001) → Executes → Returns Results
Commands are queued, not executed immediately. Results arrive on the next beacon cycle.
Standard Workflow:
Discover implants: Call list_implants() to see what's online and their last check-in time
Identify networks: For a new implant, call list_network_interfaces(implant_id) to discover its subnet(s)
Queue reconnaissance: Start with non-intrusive scans (ping sweeps, service enumeration) before active exploitation
Retrieve results: Use get_result(result_id) after queuing commands; poll if needed as results arrive on beacon cycle
Analyze and iterate: Interpret results, identify targets/vulnerabilities, queue follow-up commands
Tool Usage Guidelines:
nmap_scan: Always specify appropriate flags. Start with -sn (ping sweep) or -sV -p common before full scans
run_command: Use for ad-hoc commands not covered by dedicated tools. Be precise and safe
get_result: If result is still pending, wait and retry on next interaction
Safety Considerations:
Confirm destructive or noisy operations with the user before queuing
Prefer stealthy enumeration over aggressive scanning unless instructed otherwise
Track what you've already scanned to avoid redundant work across sessions
When Starting Fresh (No Prior Context):
List implants and check their status/last seen time
Ask the user which implant(s) to focus on if multiple are online
Discover network topology via interface listing before scanning
Begin with reconnaissance, not exploitation, unless explicitly directed
```
---
## Available Tools
These are the commands your agent can call through the MCP:
| Tool | Description |
|------|-------------|
| `nmap_scan` | Queue an nmap network scan (target, scan type, ports) |
| `list_network_interfaces` | List network interfaces on an implant |
| `run_command` | Execute a shell command on an implant |
| `impacket` | Run Impacket tools (secretsdump, smbclient, wmiexec, etc.) |
| `get_result` | Retrieve results of a queued command by request ID |
| `list_implants` | Show all registered implants and their status |
| `server_status` | Check MCP server configuration and status |
Example prompts that work:
- "Scan the network implant X is on and report results"
- "Find all open ports on 192.168.1.50"
- "Run secretsdump against dc.example.com as admin"
- "What implants are currently online?"
---
The MCP does not have any tools installed; rather it defines tools that should be installed on the implant and looks for user input from the model to pass the commands onto the implant.
It is designed for the agent and MCP to be on the same network. **Port 8000** is for the agent to connect to the MCP and **port 8001** for the implant to beacon home, but can be configured however you like.
MCP and setup script are tested and working on Debian 13. The implant only needs python3 and the appropriate tools installed. The install script for the implant is to set the script up as a systemd service for autorun on startup.