Giter Site home page Giter Site logo

kimusan / kctf-pow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aplet123/kctf-pow

0.0 0.0 0.0 17 KB

A library and CLI to solve, check, and generate proof-of-work challenges using kCTF's scheme.

License: BSD 3-Clause "New" or "Revised" License

Rust 100.00%

kctf-pow's Introduction

kctf-pow

A library and CLI to solve, check, and generate proof-of-work challenges using kCTF's scheme.

Installation

For use as a library, add the kctf-pow crate into your dependencies.

The CLI can be installed with cargo install kctf-pow, or by cloning the repository, building with cargo build --release, and manually copying the executable.

CLI Usage

To solve a challenge and print the solution to stdout:

kctf-pow solve <challenge>

For example:

kctf-pow solve s.AAAAMg==.NDtqORW1uZlIgzszbdMGZA==
# Outputs s.NUH3arymnKB+ysUGdv+67ypDamn4wOKCPORB2ivWE1Yhinam2v4S6q4nAoC5LP97LScdVoq+NuFVF++Win5mNRYZS6bJAs8fk0h8XgvfcC/7JfmFISqeCIo/CIUgIucVAM+eGDjqitRULGXqIOyviJoJjW8DMouMRuJM/3eg/z18kutQHkX0N3sqPeF7Nzkk8S3Bs6aiHUORM30syUKYug==

To check a solution for a challenge:

kctf-pow check <challenge>

The solution is read from stdin. If the solution is correct, the program will exit with status code 0 and correct will be outputted. If the solution is incorrect, the program will exit with status code 1 and incorrect will be outputted. If the solution is malformed, the program will exit with status code 1 and an error message will be printed to stderr.

For example:

kctf-pow check s.AAAAMg==.NDtqORW1uZlIgzszbdMGZA==
# Input s.NUH3arymnKB+ysUGdv+67ypDamn4wOKCPORB2ivWE1Yhinam2v4S6q4nAoC5LP97LScdVoq+NuFVF++Win5mNRYZS6bJAs8fk0h8XgvfcC/7JfmFISqeCIo/CIUgIucVAM+eGDjqitRULGXqIOyviJoJjW8DMouMRuJM/3eg/z18kutQHkX0N3sqPeF7Nzkk8S3Bs6aiHUORM30syUKYug==
# Outputs correct and exits with status code 0

To randomly generate a challenge:

kctf-pow gen <difficulty>

For example:

kctf-pow gen 50
# Outputs s.AAAAMg==.NDtqORW1uZlIgzszbdMGZA==

To chain challenge generation and checking:

kctf-pow ask <difficulty>

For example:

kctf-pow ask 50
# Outputs s.AAAAMg==.NDtqORW1uZlIgzszbdMGZA==
# Input s.NUH3arymnKB+ysUGdv+67ypDamn4wOKCPORB2ivWE1Yhinam2v4S6q4nAoC5LP97LScdVoq+NuFVF++Win5mNRYZS6bJAs8fk0h8XgvfcC/7JfmFISqeCIo/CIUgIucVAM+eGDjqitRULGXqIOyviJoJjW8DMouMRuJM/3eg/z18kutQHkX0N3sqPeF7Nzkk8S3Bs6aiHUORM30syUKYug==
# Outputs correct and exits with status code 0

Library Usage

use kctf_pow::KctfPow;

fn main() {
    let pow = KctfPow::new();
    // decoding then solving a challenge
    let chall = pow.decode_challenge("s.AAAAMg==.H+fPiuL32DPbfN97cpd0nA==").unwrap();
    println!("{}", chall.solve());
    // decoding then checking a challenge
    let chall = pow.decode_challenge("s.AAAAMg==.NDtqORW1uZlIgzszbdMGZA==").unwrap();
    let sol = "s.NUH3arymnKB+ysUGdv+67ypDamn4wOKCPORB2ivWE1Yhinam2v4S6q4nAoC5LP97LScdVoq+NuFVF++Win5mNRYZS6bJAs8fk0h8XgvfcC/7JfmFISqeCIo/CIUgIucVAM+eGDjqitRULGXqIOyviJoJjW8DMouMRuJM/3eg/z18kutQHkX0N3sqPeF7Nzkk8S3Bs6aiHUORM30syUKYug==";
    assert_eq!(chall.check(sol), Ok(true));
    assert_eq!(chall.check("s.asdf"), Ok(false));
    // generating a random challenge of difficulty 50
    let chall = pow.generate_challenge(50);
    println!("{}", chall);
}

Library Documentation

The documentation for the library is available on docs.rs.

kctf-pow's People

Contributors

aplet123 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.