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:
# 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:
# 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:
# Outputs s.AAAAMg==.NDtqORW1uZlIgzszbdMGZA==
To chain challenge generation and checking:
kctf-pow ask <difficulty>
For example:
# 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 KctfPow;
Library Documentation
The documentation for the library is available on docs.rs.