Skip to main content

Utils for Attack&Defense CTFs

Little package containing useful classes for Attack&Defense CTFs.

Purpose

During my first A&D based CTFs, my workflow was:

  1. Building the exploit.py script.
  2. Copy-pasting an exploit.sh script, whose only job was to spin up multiple python exploit.py, each targetting a different vulnbox.
  3. Run a submit_flags.py to collect the points.

At first it was great, but then things got complicated, and the exploit.sh reached ~100-line length for something that in Python needs half.

Plus, I don't want multiple copies of the same files scattered across my filesystem. I just want to pip install <x> in my venv.

Here it comes adutils!

Installation

You can install it via:

pip install lents_adutils

Usage

When writing an exploit for an A&D CTF, you want to run the same exploit towards multiple vulnboxes at the same time. The Exploit class lets you do exactly that by extending it.

from adutils import Exploit

class MyExploit(Exploit):
# ...

Then you have to implement the run(self, ip: str) method, which gives you access to the IP address of one of the vulnbox you're targeting.

class MyExploit(Exploit):
    def run(self, ip: str):
        flag = exploit() # imagine you get the flag via exploit()
        self.flagout(flag) # you add the flag to a list of flags

At the end of each cycle, the submit_flags method will be run for you.

If you want to run the full exploit, you create an instance of MyExploit and then call the start method.

if __name__ == "__main__":
    port = 1234
    team_token = "deadbeef"
    my_exploit = MyExploit(team_token)

    my_exploit.start()

There are lots of options that allow you to fully customize the workflow. You can also override the existing methods to meet your needs.

# The Exploit initializer
def __init__(
    self,
    team_token: str,
    n_teams: int = 80,                                   # number of teams
    sleep_interval: int = 60,                            # time between cycles
    ignore: list[int] = [],                              # list of team ids to ignore
    verbose: bool = True,                                # additional logs
    submit_url: str = "http://10.10.0.1/flags",          # endpoint to submit flags
    submit_timeout: int = 5,
    flag_ids_url: str = "http://10.10.0.1:8081/flagIds", # endpoint that exposes info for challenges
    flag_regex: Pattern = compile(r"^[A-Z0-9]{31}=$")
    retry_unsuccessful: bool = False,                    # whether to re-run unsuccesful exploits
    retry_unsuccessful_sleep_interval: int = 60,         # seconds to wait before retrying unsuccessful exploits
):

Metadata

Release files for lents_adutils 0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lents_adutils 0.8
File Size Uploaded Provenance Actions
lents_adutils-0.8.tar.gz 11.8 kB Without provenance Details for lents_adutils-0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lents_adutils 0.8
File Interpreter ABI Platform Actions
lents_adutils-0.8-py3-none-any.whl Python 3 none any Details for lents_adutils-0.8-py3-none-any.whl

Total release size: 25.0 kB

Release files / lents_adutils-0.8.tar.gz

Download URL lents_adutils-0.8.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7fbd4fe69d907af4de1b069f236e7ede99514071e926011cbc6eb2a17aaaaed9
BLAKE2b-256 checksum
How to use checksums
5b2a6d50ae66403c9fb7e27d28bcc863364b9c59716a7332ca5c2020df2d6057
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.4 Darwin/25.6.0

Release files / lents_adutils-0.8-py3-none-any.whl

Download URL lents_adutils-0.8-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a6ef7350ae062976f7dec714d1c7ec54191707b942ce6c0c24620ff3bc1ce2c
BLAKE2b-256 checksum
How to use checksums
15d9647dbe9cacadb500766820489334011f8aa4df21c252cb3d968f68c0a194
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.4 Darwin/25.6.0

Security for lents_adutils 0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page