Skip to content

teebow1e/go-ctf-quiz

Repository files navigation

go-ctf-quiz

A TCP server to facilitate the process of making checker for multi-question CTF challenge.

Watch go-ctf-quiz in action:

asciicast

Features

  • From JSON -> quiz server, ready to publish!
  • Authentication through CTFd access token
  • Log each quiz attempt into a single JSON file

Getting started

In order to get started, prepare a question file named question.json. The file should look like this:

{
    "title": "Sample Quiz",
    "created_at": 123,
    "author": "teebow1e",
    "flag": "FLAG{sample_flag}",
    "timeout_amount": 30,
    "questions": [
        {
            "id": 1,
            "question": "What is question A?",
            "answer": "Option A"
        },
        {
            "id": 2,
            "question": "What is question B?",
            "answer": "Option B"
        },
        {
            "id": 3,
            "question": "What is question C?",
            "answer": "Option C"
        }
    ]
}

After that, edit necessary information in the .env file, including CTFd link, listening host/port.

Sample docker-compose

services:
  part1:
    image: ghcr.io/teebow1e/tcpquiz:latest
    container_name: part1
    ports:
      - "127.0.0.1:7002:1337"
    volumes:
      - ./question.json:/app/question.json
      - ../logs:/app/log
    environment:
      - HOST=0.0.0.0
      - PORT=1337
      - CTFD_URL=https://example.com
      - MAX_CONNECTIONS=100
      # Only when you want CTFd authentication
      - STRICT_MODE=1 
    restart: unless-stopped

When everything is done, just docker compose up -d!

Logging

All quiz attempts are logged to ./log/quiz_attempts_<sanitized_title>.json. The log directory is automatically created by the application.

When using Docker Compose, the logs are persisted on the host machine through volume mounting:

volumes:
  - ./question.json:/app/question.json
  - ./log:/app/log

Each log entry contains detailed information about the attempt including timestamp, user token, answers, and whether they completed the quiz successfully.

About

A TCP server to facilitate the process of making checker for multi-question CTF challenge.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published