tsg-ut / tsgctf-checker

Health checker for TSG CTF 2023.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TSGCTF2023 Health Checker

Lint Test

πŸ’» Usage

Setup MySQL

sudo apt instlall mysql-server
sudo systemctl start mysql.service
sudo mysql -e "source ./scripts/mysql/init.sql"

Create Configuration File

Create configuration JSON file which defines the following variables:

Key Type Description
parallel int The number of concurrent test process.
challs_dir string The path to the directory where challenges are placed.
have_genre_dir bool If false, directories under challs_dir are treated as challenge dir. If true, directores under challs_dir are treated as genre dir and their sub directories are treated as challenge dir.
targets_file string The path to the file which lists host/port of challenges.
skip_non_exist string Skip challenges who don't have info.json.
slack_token string (optional) Slack Bot User OAuth Token.
slack_channel string (optional) Slack channel ID including #.

You can check the example configuration file.

Create Targets File

Create CSV file which lists host/port of challenges.

  • Each row of the file must have three fields:
    • Challenge ID (same as info.json's name field)
    • Host name
    • Port
  • The file must NOT have header row.

Specify the path to this file to targets_file field of the configuration file.

Setup Environment Variables

ENV Description
DBUSER Username of MySQL. (checker/badge)
DBPASS Password of user DBUSER. (checker/badge)
DBHOST Host name of MySQL. (checker/badge)
DBNAME Database name of MySQL. (checker/badge)
BADGE_PORT Port number of badge server. Default to 8080. (badge)

Run and records tests

make cmd
./bin/cmd/checker --config=<config path>

Run badge server

Badge is served as /badge/<challenge name>.

make cmd
./bin/cmd/badge
# or
./bin/cmd/badge --port=<port number>

πŸ“’ Slack Notification

If your run checker with --notify-slack option, failed tests would be notified to Slack.

πŸ‡―πŸ‡΅ Challenge Requirement

A directory specified by challs_dir looks like the following:

# When `have_genre_dir` is `false`
`challs_dir`
β”œβ”€β”€ chall1
β”‚   └── solver
β”‚       β”œβ”€β”€ Dockerfile
β”‚       └── info.json
└── chall2
    └── solver
        β”œβ”€β”€ Dockerfile
        └── info.json

# When `have_genre_dir` is `true`
`challs_dir`
β”œβ”€β”€ pwn
β”‚   β”œβ”€β”€ chall1
β”‚   β”‚   └── solver
β”‚   β”‚       β”œβ”€β”€ Dockerfile
β”‚   β”‚       └── info.json
β”‚   └── chall2
β”‚           β”œβ”€β”€ Dockerfile
β”‚           └── info.json
└── web
    └── chall3
            β”œβ”€β”€ Dockerfile
            └── info.json
  • Each challenge must have info.json file.
  • Each challenge must have Dockerfile.
  • Host and port of each challenge are passed to the solver container as 1st/2nd argument.

info.json must have the following keys:

Key Type Description
name string Unique name of the challenge. Numbers, alphabets, -, _, and space are allowed.
timeout int Timeout in seconds including the time to build a testing container.
assignee string Slack User ID of the challenge author. Mentioned to on test failure.

😈 Daemonization

TBD

🌳 Development

# Build binaries under `/bin/cmd` directory
make cmd

# Run tests
make test

# Run specific test
go test -v <package dir> -run <test name>

# Format
make fmt

Notes

  • If you want to run example challenge and solver on the same local machine, you can pass --network="host" option to /bin/cmd/checker to make container use host network.

About

Health checker for TSG CTF 2023.

License:MIT License


Languages

Language:Go 95.5%Language:Makefile 2.4%Language:Dockerfile 1.3%Language:Shell 0.7%