ctfup

A CLI tool to deploy CTF challenges to a k8 cluster for csictf.

Showing:

Popularity

Downloads/wk

26

GitHub Stars

11

Maintenance

Last Commit

4mos ago

Contributors

6

Package

Dependencies

9

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

csivit

All Contributors

Issues


Logo

ctfup

A CLI tool to deploy CTF challenges to a k8 cluster for `csictf`.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

About The Project

ctfup is an npm package developed to streamline the deployment of CTF challenges to a kubernetes cluster.

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

This package is intended to be used in your CI script, or with the appropriate Google Cloud SDK.

  • npm
npm install npm@latest -g
  • A Google Cloud account with the Kubernetes Engine enabled.
  • A Google Cloud Service account.

Installation

  1. Clone the repo
git clone https://github.com/csivitu/ctfup.git
  1. Install NPM packages
npm install

Usage

  1. Assuming you have a repository for challenges, kindly structure it as follows:
├── pwn
│   ├── pwn-challenge-1
│   │   ├── *
│   │   ├──challenge.yml
│   │   ├──Dockerfile
│   │   └──.dockerignore
│   │
│   ├── pwn-challenge-2
│   │   ├── *
│   │   ├──challenge.yml
│   │   ├──Dockerfile
│   │   └──.dockerignore
│   │
│   └── pwn-challenge-3
│
├── crypto
├── forensics
├── linux
├── reversing
├── miscellaneous
├── osint
├── pwn
├── web
└── ctfup.yml

The directories pwn , crypto etc. each have sub directories with each sub directory having a challenge.yml, a Dockerfile and corresponding .dockerignore.

  1. The root directory of your repository must have a config file ctfup.yml as per the format.
categories:
  - "crypto"
  - "forensics"
  - "linux"
  - "reversing"
  - "miscellaneous"
  - "osint"
  - "pwn"
  - "web"
registry: "gcr.io/<project name>-<project id>"
  1. The format of challenge.yml is as follows:
# This file represents the base specification of your challenge. It is used by
# other tools to install and deploy your challenge.

# Required sections
name: "challenge name"
author: "author"

# Select a category from:
# - Pwn
# - Web
# - OSINT
# - Linux
# - Crypto
# - Forensics
# - Reversing
# - Miscellaneous
category: category

# This is the challenge description. Make sure you include the
# necessary URLs / netcat strings here.
description: This is a sample description

# This is the number of points awarded for the challenge.
value: 500
type: dynamic

# Number of solves it takes to reach the minimum value.
decay: 450

# Minimum value.
minimum: 100

# Flags specify answers that your challenge use. You should generally provide
# at least one.
# Can be removed if unused
# Accepts strings or dictionaries
flags:
  - csictf{this_is_a_sample_flag}
  - { type: "static", content: "csictf{another_flag}", data: "asdfasdfsdf" }

# Tags are used to classify your challenge with topics. You should provide at
# least one.
# Can be removed if unused
# Accepts strings
tags:
  - web
  - sandbox
  - js

# Provide paths to files from the same directory that this file is in
# Accepts strings
files:
  - dist/source.py

# Hints are used to give players a way to buy or have suggestions. They are not
# required but can be nice.
# Can be removed if unused
# Accepts dictionaries or strings
hints:
  - { content: "This hint costs points", cost: 10 }
  - This hint is free

# The state of the challenge.
# May be "visible" or "hidden".
# It is "visible" by default.
state: hidden

# Specifies what version of the challenge specification was used.
# Subject to change until ctfcli v1.0.0
version: "0.1"

# The ports to expose. The target port will be used to access the deployed container.
expose:
- containerPort: 9999
  targetPort: 30231
  1. The directory containing the challenge.yml file must also contain a Dockerfile which will be used by GKE.

  2. Setup your preferred CI for your project. In this case, we will use a Github Action.

- uses: actions/checkout@v2
- uses: actions/setup-node@v1
  with:
    node-version: "12"
- run: npm install -g ctfup
  1. Add the required secrets and in your yaml config file, set up the gcloud environment with
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
  with:
    version: '290.0.1'
    service_account_key: ${{ secrets.GKE_SA_KEY }}
    project_id: ${{ secrets.GKE_PROJECT }}

Note: use the latest version of the Github Action.

  1. Additional setup
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
    gcloud --quiet auth configure-docker
# Get the GKE credentials so we can deploy to the cluster
- run: |-
    gcloud container clusters get-credentials "${{ secrets.GKE_CLUSTER_NAME }}" --zone "${{ secrets.GKE_CLUSTER_ZONE }}"

8. Deploy
- name: Deploy
  run: ctfup -c ctfup.yml .

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'feat: Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

You are requested to follow the contribution guidelines specified in CONTRIBUTING.md while contributing to the project 😄.

License

Distributed under the MIT License. See LICENSE for more information.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Rishit Bansal

💻 🚇

Rohan Mukherjee

💻 🚇

theProgrammerDavid

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100