Skip to main content

ExploitFarm Python Library and CLI

ExploitFarm is an advanced tool designed to manage exploits and flag submissions in Attack-Defense CTF competitions. It combines a Python library with a command-line interface (CLI), providing flexibility and efficiency for managing CTF tasks. This documentation provides a comprehensive overview of its features, installation, and usage.


Key Features

  • Multi-Threaded Execution: Utilize a pool of worker threads for efficient exploit execution.

  • Exploit Management: Initialize, push, pull, and version control exploit source code.

  • Attack Groups: Collaborate and manage group-based attacks.

  • Integrated Status Monitoring: View real-time server and current execution statuses.


Installation

Install ExploitFarm via pip:

pip3 install -U xfarm && xfarm --install-completion

For Windows, use:

python -m xfarm

Prerequisites:

  • Python 3.8+
  • Compatible with Linux, macOS, and Windows.
  • Ensure you have pip installed.

Getting Started

ExploitFarm provides both programmatic and CLI access to its features.

Programmatic API

The Python library allows developers to integrate ExploitFarm functionality into their scripts:

import random
from exploitfarm import *

host = get_host()  # Retrieves the server host (from environment variables or configuration)
print(f"Connected to {host}")

flags = [random_str(32) + "=" for _ in range(10)]
print(f"Submitting flags: {flags}")
submit_flags(flags)

Store Class

The Store class provides a key-value storage system for exploits, allowing you to save and retrieve centralized data during execution. The key value store is different for each exploit id. You can use it to store some data you need to save and change for every exploit execution.

from exploitfarm import Store

store = Store()

# Set a value
store.set("example_key", {"example": "data"})

# Get a value (if not exists returns None)
data = store.get("example_key")
print(data)

# Delete a key
store.delete("example_key")

# List all keys
keys = store.keys()
print(keys)

Methods:

  • get(key: str, timeout: int = HTTP_TIMEOUT) -> bytes: Retrieve a value by key.
  • set(key: str, value: bytes, timeout: int = HTTP_TIMEOUT): Store a value by key.
  • delete(key: str, timeout: int = HTTP_TIMEOUT): Delete a key.
  • keys(timeout: int = HTTP_TIMEOUT) -> list[str]: List all stored keys.

Environment Variables Required:

  • XFARM_REMOTE_URL: Base URL for the exploit storage API.
  • XFARM_EXPLOIT_ID: Unique identifier for the exploit.
  • XFARM_LOGIN_TOKEN: Authentication token for secure access.

Command-Line Interface (CLI)

The CLI is the primary way to interact with ExploitFarm for exploit and attack management.

CLI Syntax

xfarm [COMMAND] [OPTIONS]

Use --help to view available commands and options:

xfarm --help

Detailed CLI Documentation

Global Options

These options are applicable to all commands:

  • -h, --help: Display help information for a command.
  • -I, --no-interactive: Disable interactive configuration mode (default: interactive).
  • -v, --version: Show the version of the ExploitFarm client.

Primary Commands

Start Exploit

Run an exploit from the specified path:

xfarm start [OPTIONS] PATH

Options:

  • PATH: The directory containing the exploit (default: current directory).
  • --pool-size, -p: Fixed size for the thread pool (default: 10 * CPU cores).
  • --submit-pool-timeout: Timeout (in seconds) for the submission pool (default: 3).
  • --test, -t: Test the exploit without submission.
  • --test-timeout: Timeout for exploit testing (default: 30 seconds).
  • --no-auto-push, -n: Prevent automatic source push.
  • --push-message, -m: Custom message for the source push.

Example:

xfarm start ./my_exploit --pool-size 20 --test

Configuration Commands

Edit Configuration

Edit client settings:

xfarm config edit [OPTIONS]

Options:

  • --address: Server address.
  • --port: Server port.
  • --nickname: Client nickname.
  • --https: Use HTTPS (default: False).

Example (no interactive mode):

xfarm -I config edit --address example.com --port 443 --https --nickname

Reset Configuration

Reset all client settings to their default values:

xfarm config reset

Login

Authenticate with the server:

xfarm config login [OPTIONS]

Options:

  • --password: Provide the password directly.
  • --stdin: Read the password from stdin.

Logout

Logout from the server:

xfarm config logout

Exploit Management Commands

Initialize Exploit

Set up a new exploit project:

xfarm exploit init [OPTIONS]

Options:

  • --edit, -e: Edit the configuration interactively.
  • --name: Exploit name.
  • --service: Associated service UUID.
  • --language: Programming language.

Push Exploit

Upload the exploit source code to the server:

xfarm exploit push [OPTIONS]

Options:

  • --message, -m: Commit message.
  • --force, -f: Force push even with an old commit has the same source.

Retrieve Exploit Information

Get details about the exploit source:

xfarm exploit info [OPTIONS]

Options:

  • --raw, -r: Display raw JSON response.

Update Exploit

Update to the latest commit:

xfarm exploit update [OPTIONS]

Options:

  • --force, -f: Force update.

Download Exploit

Download the exploit source:

xfarm exploit download [OPTIONS]

Options:

  • --folder, -f: Specify target folder.
  • --commit-uuid: Commit ID (default: latest).

Attack Group Commands

Create Attack Group

Create a new group for collaborative attacks (and also join in it if in interactive mode):

xfarm group create [OPTIONS]

Options:

  • --name: Group name.

Join Attack Group

Join an existing attack group:

xfarm group join [OPTIONS]

Options:

  • --group: Group ID.
  • --queue: Queue number for the group.
  • --submit-pool-timeout: Timeout for submission pooling.
  • --demonized or -d: Join the group in a demonized process.
  • --kill: Kill a running worker of the indicated group.
  • --log-file: Path to the log file

List Attack Group

List all available attack groups:

xfarm group list

Shows a table with all existing groups, their IDs, and if there is a worker running for that group.


Environment Variables

Environment variables can simplify configuration:

  • XFARM_HOST: Server address.
  • XFARM_PORT: Server port.
  • XFARM_INTERACTIVE: Enable or disable interactive mode.
  • XFARM_REMOTE_URL: API Base URL for remote exploit storage.
  • XFARM_EXPLOIT_ID: Unique identifier for the exploit.
  • XFARM_LOGIN_TOKEN: Authentication token for secure access.

Best Practices

  1. Use --test to verify exploits before running them in production.
  2. Regularly push changes to the server for version control (they are auto-pushed on attack start anyway).
  3. Collaborate using attack groups for efficient resource utilization if the attack is heavy to execute.

Download files

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

Source Distribution

exploitfarm-1.6.3.tar.gz (52.2 kB view details)

Uploaded Source

Built Distribution

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

exploitfarm-1.6.3-py3-none-any.whl (61.6 kB view details)

Uploaded Python 3

File details

Details for the file exploitfarm-1.6.3.tar.gz.

File metadata

  • Download URL: exploitfarm-1.6.3.tar.gz
  • Upload date:
  • Size: 52.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for exploitfarm-1.6.3.tar.gz
Algorithm Hash digest
SHA256 9e47188e04ab7d16677116298af84898697c160da7b31b6c4c83f7e212d02cda
MD5 f0d6d34f18381bb8da6418f0177938e0
BLAKE2b-256 b6fba288de9fd8131a9f0f6563ce6d789d5d9fd7728cb84c07a97a2bd2b3f5d0

See more details on using hashes here.

File details

Details for the file exploitfarm-1.6.3-py3-none-any.whl.

File metadata

  • Download URL: exploitfarm-1.6.3-py3-none-any.whl
  • Upload date:
  • Size: 61.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for exploitfarm-1.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 97734e0104d9319951923f4c3f148936de8faef5e9bce3913604c7dbd919ee66
MD5 9e3b30f32ab49bae58e308149d090aab
BLAKE2b-256 999f91a84fbdafc3cef344eef9bd9691a3890a8aa78e22a33b1b907a4881f9b4

See more details on using hashes here.

Release history Release notifications | RSS feed

2.2.2

2 files

2.2.1

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.0

2 files

1.7.9

2 files

1.7.8

2 files

1.7.7

2 files

1.7.6

2 files

1.7.5

2 files

1.7.4

2 files

1.7.3

2 files

1.7.2

2 files

1.7.1

2 files

1.6.9

2 files

1.6.8

2 files

1.6.7

2 files

1.6.6

2 files

1.6.5

2 files

1.6.4

2 files

This release

1.6.3 This release

2 files

1.6.2

2 files

1.6.1

2 files

1.6.0

2 files

1.5.1

2 files

1.5.0

2 files

1.4.0

2 files

1.3.1

2 files

1.3.0

2 files

1.2.12

2 files

1.2.11

2 files

1.2.10

2 files

1.2.9

2 files

1.2.8

2 files

1.2.7

2 files

1.2.6

2 files

1.2.5

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.7

2 files

1.1.6

2 files

1.1.5

2 files

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.27

2 files

0.2.26

2 files

0.2.25

2 files

0.2.24

2 files

0.2.23

2 files

0.2.22

2 files

0.2.21

2 files

0.2.20

2 files

0.2.19

2 files

0.2.18

2 files

0.2.17

2 files

0.2.16

2 files

0.2.15

2 files

0.2.14

2 files

0.2.13

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 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