Skip to main content

🍪 CookieFarm - Exploiter Manager

Language Keywords License

Python decorator for automating exploit execution in CTF Attack & Defense competitions


📦 What is it?

This package provides a @exploit_manager decorator designed to automate the parallel execution of exploits in CTF (Attack & Defense) settings, specifically for use with the CookieFarm project.

It handles:

  • Authentication with the central server
  • Retrieving team configuration
  • Automatic flag parsing from stdout

⚠️ Note: This package is not standalone. It must be used together with the CookieFarm client. The client provides the required APIs and team configurations.


📦 Installation

To install the package:

pip install --upgrade cookiefarm requests

⚙️ How it works

The @exploit_manager decorator takes care of:

  • Calling your exploit(ip, port, name_service, flag_ids) function
  • Retrieving the CookieFarm server configuration
  • Fetching the full flag IDs JSON at every tick
  • Normalizing competition-specific flag IDs structures into a per-team list
  • Passing only the current team/service flag IDs to each exploit thread
  • Capturing your exploit's stdout
  • Parsing flags via regex
  • Logging the result in JSON format, including: team ID, port, service name, and the flag found

🚀 Example usage

from cookiefarm import exploit_manager
import requests

@exploit_manager
def exploit(ip, port, name_service, flag_ids):
    # flag_ids contains only the IDs for the current team and service
    for flag_id in flag_ids:
        response = requests.get(
            f"http://{ip}:{port}/",
            params={"id": flag_id},
        )

        # Just print the flag to stdout
        print(response.text)

# Run from the command line with arguments from CookieFarm
# python3 myexploit.py -s <server_address> -t <tick_time> -W <worker_number> -p <port> -n <name_service>

For execution, you have to pass the required arguments from the command line, which are provided by the CookieFarm client. The decorator will handle the rest.

python3 myexploit.py -s <server_address> -t <tick_time> -W <worker_number> -p <port> -n <name_service> -x [test mode]
Argument Description
-s or --server_address The address of the CookieFarm server
-t or --tick_time The time interval for the exploit execution
-W or --workers_number The number of workers (by default threads) to use for the exploit
-p or --port_service The port to target for the exploit
-n or --name_service The name of the service to exploit
-x or --test Run in test mode against the configured NOP team
-P or --process-mode The process mode to use for the exploit (default: thread)

🧩 Flag IDs normalization

Different Attack/Defense infrastructures may expose flag IDs with different JSON layouts. CookieFarm fetches the full flag IDs JSON at every tick and normalizes it locally according to the shared.flagids_format value configured on the server.

The exploit function always receives:

flag_ids: list

This list contains only the flag IDs for the current team and the current service.

Format syntax

The flagids_format path supports dynamic tokens:

  • [service] — the service name passed with -n / --name_service
  • [team] — the team key to iterate over
  • [id] — the terminal node containing the flag IDs

Literal keys can be written directly in the path.

CyberChallenge-style layout

Raw flag IDs:

{
  "Service1": {
    "team_1": {
      "1": ["id-a"],
      "2": ["id-b"]
    }
  }
}

Server configuration:

shared:
  url_flag_ids: "http://10.10.0.1/flagids"
  flagids_format: "[service].[team].[id]"

The exploit running against Service1 and team_1 receives:

["id-a", "id-b"]

Team-first layout

Raw flag IDs:

{
  "team_1": {
    "Service1": ["id-a", "id-b"]
  }
}

Server configuration:

shared:
  url_flag_ids: "http://172.168.1.0/flagids"
  flagids_format: "[team].[service].[id]"

The exploit running against Service1 and team_1 receives:

["id-a", "id-b"]

Nested layout with a literal key

Raw flag IDs:

{
  "teams": [123, 456, 789],
  "flag_ids": {
    "service1": {
      "123": ["abc123", "def456"],
      "789": ["xxx", "yyy"]
    }
  }
}

Server configuration:

shared:
  url_flag_ids: "http://example.local/flagids"
  flagids_format: "flag_ids.[service].[team].[id]"

The exploit running against service1 and team 123 receives:

["abc123", "def456"]

If flagids_format is omitted, CookieFarm uses:

flagids_format: "[service].[team].[id]"

🛠️ Requirements

  • Python ≥ 3.13
  • Working CookieFarm client installed

📝 License

Distributed under the MIT License. Feel free to use, modify, and contribute.


For any questions, suggestions, or issues, feel free to open a GitHub issue!

Created with ❤️ by ByteTheCookies (feat. @0xMatte)

Metadata

Release files for cookiefarm 1.3.2.4

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

Source distribution (sdist)

Source distribution for cookiefarm 1.3.2.4
File Size Uploaded
cookiefarm-1.3.2.4.tar.gz 28.3 MB Details

Built distribution (wheel)

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

Total release size: 56.5 MB

Release files / cookiefarm-1.3.2.4.tar.gz

Download URL cookiefarm-1.3.2.4.tar.gz
Size 28.3 MB
Tags Source
SHA-256 checksum
How to use checksums
e5ed1b8d1f963abc6c9f20ebef65e55c55e451dbee1f2cbc0592ce1b596965f9
BLAKE2b-256 checksum
How to use checksums
1b556b81adfcd1ab47863e6b08f071175a8f442f68af412b5c4221f769c47667
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cookiefarm-1.3.2.4-py3-none-any.whl

Download URL cookiefarm-1.3.2.4-py3-none-any.whl
Size 28.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
34acca3beae961c90c0dfc0d173bfd3373f382971dbce7f6ef8d77e30bda0e82
BLAKE2b-256 checksum
How to use checksums
0f6ad565d107ff3f562a2e69eb5f85713805ae618b94785732891721b783de41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

1.3.5

2 release files

This release

1.3.2.4 This release

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.9

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

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