Giter VIP home page Giter VIP logo

scrap's Introduction

Scrap

A simple CTF platform in a single binary.

Scrap is designed to be as fast and lightweight as possible. It compiles into a single Rust binary and can handle many thousands of teams. Furthermore, Scrap's browser webpage is completely free of JavaScript. Due to various design decisions, there are a few constraints:

  • Only dynamic scoring is supported.
  • There is a maximum of 64 challenges.
  • Teams lack email verification.
  • Registration lacks captchas.

Registration can be rate limited through a reverse proxy if necessary.

Getting Started

Download the latest version from the releases page and run it:

./scrap --port 8000 --repo ./repository --static ./static --uri postgres://user:pass@host/db

Deployment

Repository

Scrap is centered around a central repository that specifies challenges and files. An example is available here.

repository
├── ctf.toml
├── first
│   └── challenge.toml
├── second
│   └── challenge.toml
└── third
│   └── challenge.toml
└── junk
    └── trash

Scrap requires a single ctf.toml, as well as a challenge.toml for each challenge. All other files and directories are ignored.

ctf.toml

ctf.toml must be in the base directory.

# HTML title element text
title = "MyCTF"

# Homepage Markdown/HTML
home = """
# Welcome to MyCTF!
Enjoy our many *challenges*."""

# CTF start time
# If removed, infinitely in the past
start = 2000-01-01T00:00:00Z

# CTF stop time
# If removed, infinitely in the future
stop = 2100-01-01T00:00:00Z

Challenges, scoreboard, and flag submission remain unavailable until the time specified by start. Flag submission becomes unavailable once the time specified by stop is reached.

challenge.toml

Each challenge.toml must be exactly two levels below the base directory. The name of the intermediate challenge directory is irrelevant.

# Unique identifier
slug = "caesar_cipher"

# Title text
title = "Caesar Cipher"

# Author text
author = "username"

# Description Markdown/HTML
description = """
I encrypted a [message](ciphertext.txt) \
with a [Caesar cipher](encrypt.py)!"""

# Tag text
tags = [ "crypto", "classical" ]

# Paths to files anywhere in the challenge directory
files = [ "path/to/ciphertext.txt", "encrypt.py" ]

# Challenge flag
flag = "flag{}"

# Challenge status
enabled = true

Scrap will either update or add a challenge depending on whether slug exists in the database.

Paths in files can traverse directories, but must have unique filenames. These files can be referred to by filename in description for links.

Challenges with enabled set to true are displayed, open to flag submission, and used in calculating score. Challenges with enabled set to false are not, but maintain state for future toggling.

Database

Scrap requires a PostgreSQL server with the pgcrypto extension enabled:

create extension pgcrypto;

Static Files

Scrap uses a static directory, which must be served separately at /static. This can be used for serving stylesheets and favicons. Scrap will also create a subdirectory named files to hold challenge files.

static
├── style.css
├── favicon.ico

Running

Scrap requires four arguments at runtime:

  • port Server port
  • repo Path to repository
  • static Path to static directory
  • uri PostgreSQL database URI
./scrap --port 8000 --repo ./repository --static ./static --uri postgres://user:pass@host/db

Signals

Scrap supports graceful reloading on SIGUSR1. Send the signal to reload the CTF and challenge configuration from the repository.

Customization

Compiling

At the moment, Scrap requires nightly Rust.

cargo +nightly build --release

Styling

Scrap assumes that you have included style.css and favicon.png within the static directory. An example SCSS file is available here to function as documentation for the classes.

Scoring

The dynamic scoring formula can be changed by modifying the value function in scrap.sql.

scrap's People

Contributors

defund avatar kmh11 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.