CTF助手框架

CTFriend是一个基于MCP服务器的代理式AI框架,旨在通过LLM和领域知识库支持CTF参与者解决挑战,并提供人类-AI交互日志记录。

  • by ctfriend2026
  • Python
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 ctfriend2026/CTFriend

使用说明


CTFriend

Agentic AI framework that leverages MCP servers to aid CTF participants.

Table of Contents
  1. About CTFriend
  2. Getting Started
  3. Grafana Setup
  4. Start CTFriend
  5. Roadmap

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.

(back to top)

Built With

  • Python
  • FastMCP
  • Docker
  • Postgres
  • Grafana

(back to top)

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

  1. Clone the repo

    git clone git@github.com:ctfriend2026/CTFriend.git
    
  2. 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.

  1. Install Docker containers

    Insure docker is running

    docker-compose up --build
    

(back to top)

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-password or the password you 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.

(back to top)

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

(back to top)