11# CTF Script
22
3- ## Usage
3+ Opinionated command line interface (CLI) tool to manage Capture The Flag (CTF) challenges.
4+ It uses:
5+ - YAML files to describe a challenge and forum posts
6+ - OpenTofu (terraform fork) to describe the infrastructure
7+ - Incus (LXD fork) to run the challenges in containers
8+ - Ansible to configure the challenges
49
5- Setup a ` CTF_ROOT_DIR ` environment variable to make the script execute in the right folder or execute the script from that folder.
10+ This tool is used by the NorthSec CTF team to manage their challenges since 2025.
11+ [ NorthSec] ( https://nsec.io/ ) is one of the largest on-site cybersecurity CTF in the world, held annually in Montreal, Canada,
12+ where 700+ participants compete in a 48-hour long CTF competition.
13+
14+ ## Features and Usage
15+
16+ - ` ctf init ` to initialize a new ctf repository
17+ - ` ctf new ` to create a new challenge. Supports templates for common challenge types.
18+ - ` ctf deploy ` deploys the challenges to a local (or remote) Incus server
19+ - ` ctf validate ` runs lots of static checks (including JSON Schemas) on the challenges to ensure quality
20+ - ` ctf stats ` provide lots of helpful statistics about the CTF
21+ - and many more. See ` ctf --help ` for the full list of commands.
22+
23+ To run ` ctf ` from any directory, set up the ` CTF_ROOT_DIR ` environment variable to make the script
24+ execute in the right directory or execute the script from that directory. If not set, ` ctf ` will go up the directory
25+ tree until it finds ` challenges/ ` and ` .deploy ` directories, which is the root of the CTF repository.
26+
27+ ## Structure of a CTF repository
28+
29+ ```
30+ my-ctf/
31+ ├── challenges/ # Directory containing all the tracks
32+ │ ├── track1/ # Directory for a specific track that contains N flags.
33+ │ │ ├── track.yaml # Main file that describes the track
34+ │ │ ├── files/ # Directory that contains all the files available for download in the track
35+ │ │ │ ├── somefile.zip
36+ │ │ ├── ansible/ # Directory containing Ansible playbooks to configure the track
37+ │ │ │ ├── deploy.yaml # Main playbook to deploy the track
38+ │ │ │ └── inventory # Inventory file for Ansible
39+ │ │ ├── terraform/ # Directory containing OpenTofu (terraform fork) files to describe the infrastructure
40+ │ │ │ └── main.tf # Main OpenTofu file to deploy the track
41+ │ │ ├── posts/ # Directory containing forum posts related to the track
42+ │ │ │ ├── track1.yaml # Initial post for the track
43+ │ │ │ └── track1_flag1.yaml # Inventory file for Ansible
44+
45+ ```
646
747## Installation
848
@@ -18,6 +58,12 @@ Install with pipx:
1858pipx install git+https://github.com/nsec/ctf-script.git
1959```
2060
61+ Install with pip:
62+
63+ ``` bash
64+ pip install git+https://github.com/nsec/ctf-script.git
65+ ```
66+
2167### Add Bash/Zsh autocompletion to .bashrc
2268
2369``` bash
0 commit comments