Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

enochecker3-0.10.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

enochecker3-0.10.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file enochecker3-0.10.0.tar.gz.

File metadata

  • Download URL: enochecker3-0.10.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for enochecker3-0.10.0.tar.gz
Algorithm Hash digest
SHA256 2cf9e6d6de0e7b7e3cadaa8be9d7852447e045127c65c68adc733f7edb1253aa
MD5 f783080bf2996558a50235d8bde6d301
BLAKE2b-256 d82f4de10d4ddaf4593e69d6ed636e551bd5887b0f15b9942a9a3874ade2fbdb

See more details on using hashes here.

File details

Details for the file enochecker3-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: enochecker3-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for enochecker3-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fe2db33113c44eff1933b9373e3f43a21c0a1875675c3aebbfe1d8ac846754a
MD5 aedf3abe84a25422a59c6440c227ec93
BLAKE2b-256 ecb997b6b308c25df54c2281419fd0f2383820b06e7d8596f742206f92d08fe7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page