FastAPI based library for building async python checkers for the EnoEngine A/D CTF Framework
Project description
enochecker3
A FastAPI based checker library for writing async checkers in python. It is called enochecker3 even though enochecker2 never existed, because it is intended to be the reference implementation for version 3 of the enochecker API specification which is yet to come.
Quick Start
Getting started is really easy. Simply install enochecker3
using
pip3 install enochecker3
Create an example.py
file with the following content:
import secrets
from typing import Optional
from httpx import AsyncClient
from enochecker3 import (
ChainDB,
Enochecker,
GetflagCheckerTaskMessage,
MumbleException,
PutflagCheckerTaskMessage,
)
from enochecker3.utils import FlagSearcher, assert_equals, assert_in
checker = Enochecker("ExampleService", 1337)
@checker.putflag(0)
async def putflag_test(
task: PutflagCheckerTaskMessage,
client: AsyncClient,
db: ChainDB,
) -> None:
token = secrets.token_hex(32)
r = await client.post("/note", json={"token": token, "flag": task.flag})
assert_equals(r.status_code, 200, "storing note with flag failed")
await db.set("token", token)
@checker.getflag(0)
async def getflag_test(
task: GetflagCheckerTaskMessage, client: AsyncClient, db: ChainDB
) -> None:
try:
token = await db.get("token")
except KeyError:
raise MumbleException("Missing database entry from putflag")
r = await client.get(f"/note/{token}")
assert_equals(r.status_code, 200, "getting note with flag failed")
assert_in(task.flag, r.text, "flag missing from note")
@checker.exploit(0)
async def exploit_test(searcher: FlagSearcher, client: AsyncClient) -> Optional[str]:
r = await client.get(
"/note/*",
)
assert not r.is_error
if flag := searcher.search_flag(r.text):
return flag
Start the checker using
uvicorn --reload example:checker.app
And browse to (http://localhost:8000/docs) to explore the web interface, which allows you to send requests to the checker.
Documentation
You can check out the full tutorial at (https://enowars.github.io/docs)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file enochecker3-0.9.1.tar.gz
.
File metadata
- Download URL: enochecker3-0.9.1.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d36bafbcee746132a9fa9a1f4b1230b4dc16ede6eeebb783f407ba28a0699c0 |
|
MD5 | 06f9488f65b158aca9622949a149740a |
|
BLAKE2b-256 | 3d1f0b6e8bb765809354608c3615979d96275c2fbef94fac79f408690be9c06d |
File details
Details for the file enochecker3-0.9.1-py3-none-any.whl
.
File metadata
- Download URL: enochecker3-0.9.1-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 914ea0d3e7d78bcc0a9ba0e98620735e34e40a4c8ff33fca39e53ae93d038e3a |
|
MD5 | f1ec3c2eb8c87af654cb57e5930fe39e |
|
BLAKE2b-256 | 554c1454dc8271adbf48a5cbefb15d6bfcb3dad5f2db8d3c0e97bede6b2f8f04 |