使用说明
CTFriend
Agentic AI framework that leverages MCP servers to aid CTF participants.
Table of Contents
About CTFriend
CTFriend is an agentic framework that leverages MCP servers to provide an external chat-based server to aid CTF participants. Importantly, CTFriend is not intended to operate as an automatic CTF solver, but rather as an AI assistant, supporting participants in challenge solving by providing access to LLMs and the domain knowledge base. Additionally, CTFriend provides logging to gain insights into human-AI interaction.
Built With
- Python
- FastMCP
- Docker
- Postgres
- Grafana
Getting Started
Setting up CTFriend, setup has been wrapped into Docker containers controlled with Docker Compose. While, bare-metal installation is possible, for networking ease of use. Deployment should be done with Docker.
Prerequisites
The only required prerequisite is Docker and Docker Compose. For installation of Docker Compose, follow this tutorial from Docker.
System Requirements
Minimum system requirements:
-
A system capable of running Docker compose (Windows/Linux/Mac).
-
At least 4 GB of Ram
-
At least 15GB of storage
Installation
-
Clone the repo
git clone git@github.com:ctfriend2026/CTFriend.git -
Setup environment variables
cd CTFriend cp .env.example .env # replace POSTGRES_PASSWORD, TOKEN_SECRET_KEY, and ANTHROPIC_API_KEY nano . env
NOTE: POSTGRES_PASSWORD and TOKEN_SECRET_KEY only need to be changed in live deployment. For testing, the defaults are fine.
-
Install Docker containers
Insure docker is running
docker-compose up --build
Generating User Tokens
CTFriend works on whitelisting tokens, where each user has their own individual token to ID them and their chats within the system. To create this token, use the following instructions.
Login into the ctfriend container. The image opens interactive shells in the app source directory:
create a new terminal window, and run:
docker exec -it ctfriend bash
Then run:
cd app
python3 token_manager.py whitelist [email]
NOTE: Any email here can do. It is not tied to anything. For testing purposes feel free to use (test@test.com)
Grafana Setup
Configure Grafana:
Open your web browser and go to http://localhost:3000.
Log in with the:
- username: admin
- password: admin.
Prometheus Setup
Add the Prometheus Data Source:
Go to "Connections" -> "Data Sources" -> "Add new data source".
Select "Prometheus".
For the "Prometheus server URL", enter http://prometheus:9090.
Click "Save & Test".
PostgreSQL Setup
Add the PostgreSQL Data Source:
Go to "Connections" -> "Data Sources" -> "Add new data source".
Select "PostgreSQL".
Use the following connection details:
-
Name: postgres_db
-
Host: db:5432
-
Database: metrics
-
User: postgres
-
Password:
change-me-to-a-secure-passwordor thepasswordyou set in Installation part -
TLS/SSL Mode: disable
-
Version: 15
-
Timescale DB: True
Click "Save & Test". You might need to give Grafana's data source a specific UID like postgres_db if you want it to automatically link with the chat data dashboard.
Setup Dashboards
Import the Dashboards:
Go to "Dashboards" -> "New" -> "Import".
Upload the system_monitoring_dashboard.json file. Select the "Prometheus" data source when prompted.
Repeat the process for the chat_data_dashboard.json file, selecting the "PostgreSQL" data source.
Start CTFriend
Go to http://localhost:8501/ctfriend.
Input your specific login token generated above.
Select Anthropic as provider and claude-opus-4-1-20250805 as model.
Now CTfriend is ready.
Roadmap
- [x] UI Framework setup
- [x] API Key support
- [x] Multi-LLM Support
- [x] Gemini
- [x] Claude
- [x] MCP Support
- [x] CyberChef
- [x] RAG Knowledge Base
Backups (Optional)
# view/manage cron jobs
crontab -l
# edit a cron job
crontab -e
# job for backing up CTFriend
*/5 * * * * "/home/ctfadmin/CTFriend/backup.sh" >> "/home/ctfadmin/CTFriend/crontab.out" 2>&1