Skip to main content

Tool for building CTFs

Project description

🚩 CTF Builder

A tool to build, test, and deploy CTFs.

Preview

📥 Installation

📦 Requirements

🐍 PIP

System-wide:

pip install ctf-builder

venv:

python -m venv .venv
source .venv/bin/activate
pip install ctf-builder

⚙️ Usage

All tools are available through the ctf executable. Documentation can found in the help menu.

ctf -h

Note: use the environment variable CTF=/path/to/ctf if the command is not being run inside a CTF package.

Have a look at the sample CTF for the structure of a CTF package.

📔 Documentation

ctf doc

Provides the JSON schema for challenge.json. This is automatically generated from schema.py.

🎨 Schema

ctf schema

Validates challenge.json. Provides what type is expected and a useful comment for fields.

🔨 Build

ctf build

Builds challenge static files. This is useful for challenges that requires compiling binaries, making assets, etc. Instead of uploading the artifacts part of the repository they can stay separate.

🧪 Test

ctf test

Checks that solve scripts produce the provided flag. This is useful to validate that the challenge logic.

🌱 Environment Variables

The automatic testing provides the following environment variables to solve scripts.

CHALLENGE_ID - the challenge offset inside 'challenges' array.
CHALLENGE_HOST - deploy only: the challenge host name.
CHALLENGE_PORT - deploy only: the challenge port.

FLAG - the value of the flag to test.
FLAG_TYPE - the type of flag to test (static, regex).

🐋 Docker

ctf docker start
ctf docker stop
ctf docker deploy

Deploys challenges to Docker. This is useful for containerizing challenges.

🔌 Ports

Exposed/public ports DO NOT match the host port. This is to prevent collisions between challenges. Each challenge is allocated 5 public ports. These ports are assigned to challenges alphabetically, so if a has 1-5 then b will 6-10 etc. Integrations will make sure handle this. Ports can also be determined through Docker.

docker container ls

🌐 Multi-deployment

Challenges can be deployed on multiple local virtual hosts. This can be used to provide every team their own infrastructure.

🖥️ Setup Hosts

Determine the IP range and interface for the network.

ip addr

Let's assume this is eth0 and 192.168.0.0/24. New IPs can be added for the number of infrastructures.

sudo ip addr add 192.168.0.2/24 dev eth0
sudo ip addr add 192.168.0.3/24 dev eth0
...

🚀 Deploy

The infrastructures can be deployed as follows.

ctf start --network team1 --ip 192.168.0.2 --network team2 --ip 192.168.0.3 ...

The shorthand version can also be used.

ctf start -n team1 -i 192.168.0.2 -n team2 -i 192.168.0.3 ...

⚓ Kubernetes

ctf k8s build

Deploys challenges to Kubernetes. This is the most robust way to deploy challenges.

🚩 CTFd

CTFd is supported out of the box. This allows to automate deploying challenges.

🔧 Dev

ctf ctfd dev

A simple development environment. Automatically spins up challenges without any hassle.

🔑 Credentials

The credentials for the default/admin user is the following.

Name: admin
Password: admin

🖥️ Interactive Console

By default, an interactive console is open when the environment spun up. This is an argparse, therefore acts like a CLI argument parser. Help for available commands can be accessed through -h.

🚀 Deploy

ctf ctfd init
ctf ctfd deploy teams
ctf ctfd deploy challenges

Easiest way to get started is to run the Docker container for CTFd.

docker run -p 8000:8000 -it ctfd/ctfd

The CTF can be initialized from the ctfd/setup.json.

ctf ctfd init -p ADMIN_PASSWORD

An access token is needed to make more changes. It should have the ctfd_... format.

http://localhost:8000/settings > Access Tokens > Generate

Teams can be added through ctfd/teams.json. A ctfd/teams.out.json will generated with the teams/users credentials.

ctf ctfd deploy teams -k ctfd_...

Challenges can be deploy as follows.

ctf ctfd deploy challenges -k ctfd_...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctf_builder-0.0.17.tar.gz (38.1 kB view details)

Uploaded Source

Built Distribution

ctf_builder-0.0.17-py3-none-any.whl (57.2 kB view details)

Uploaded Python 3

File details

Details for the file ctf_builder-0.0.17.tar.gz.

File metadata

  • Download URL: ctf_builder-0.0.17.tar.gz
  • Upload date:
  • Size: 38.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ctf_builder-0.0.17.tar.gz
Algorithm Hash digest
SHA256 3d1b1d414868dfd33c608edf761884041e4e9d8b5e56133be21ed6ef7e864c86
MD5 069ea1e9ee31644f0103ba6143671822
BLAKE2b-256 a3bb27a4d5de1d027c998140b06caa8d03d19c8e38b86b391d007c95d074eb1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ctf_builder-0.0.17.tar.gz:

Publisher: publish.yml on alexandre-lavoie/ctf-builder

Attestations:

File details

Details for the file ctf_builder-0.0.17-py3-none-any.whl.

File metadata

  • Download URL: ctf_builder-0.0.17-py3-none-any.whl
  • Upload date:
  • Size: 57.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ctf_builder-0.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 00048a6d5da1cf6965e96b1f4f0ba7f195b6edf3f72e7fdbc36703d48e112f83
MD5 4a58a6f8948de15c1cd232c89f2c50f9
BLAKE2b-256 181ddc9f1ae5a7c54eef873f43a8053600282ef5e492748fc6dc0d6960bed454

See more details on using hashes here.

Provenance

The following attestation bundles were made for ctf_builder-0.0.17-py3-none-any.whl:

Publisher: publish.yml on alexandre-lavoie/ctf-builder

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page