CLI tool for CTF management
Project description
pwnv: A CTF Workspace Management Tool ๐ ๏ธ
pwnv is a Command-Line Interface (CLI) utility designed to optimize and organize CTF workflows. It facilitates challenge management, environment setup, and integration with remote CTF platforms, providing a structured approach to CTF participation.
๐ฏ Overview
pwnv addresses common challenges in CTF participation, such as disorganized challenge files and manual platform interaction. It provides a standardized framework to structure CTF events, automate setup procedures, and interface with platforms like CTFd, enabling participants to concentrate on problem-solving and enhancing overall efficiency.
โจ Key Features
| Feature | Description |
|---|---|
| ๐๏ธ Structured Workspace | Establishes a consistent and organized directory structure for CTFs and their associated challenges. |
| ๐ฆ Virtual Environments | Manages isolated Python virtual environments for CTF workspaces, utilizing uv for rapid setup. |
| ๐ Remote Synchronization | Enables fetching challenges, descriptions, and attachments from CTFd instances using the ctfbridge library. |
| ๐ Remote Flag Submission | Allows direct submission of flags to remote CTF platforms via the command line. |
| ๐ Plugin Architecture | Supports custom Python plugins for automating challenge setup based on predefined categories (e.g., pwn, web). |
| ๐ท๏ธ Challenge Tagging | Provides functionality to tag solved challenges with relevant keywords for efficient searching and retrieval. |
| โจ Interactive Interface | Employs fuzzy finders and interactive prompts for intuitive navigation and user input. |
๐๏ธ Installation Guide
Prerequisites
- Python 3.12 or higher.
uv: Ensureuvis installed and accessible via the systemPATH.
Option 1: Via pip
pip install pwnv
Option 2: From Source (Development)
git clone https://github.com/CarixoHD/pwnv
cd pwnv
pip install --editable .
๐ Quickstart Guide
- Initialize the workspace:
pwnv init --ctfs-folder ~/CTFs source ~/CTFs/.pwnvenv/bin/activate
- Add a CTF event:
# Add a local event pwnv ctf add ExampleCTF_Local # Add a remote event (prompts for URL and credentials) pwnv ctf add ExampleCTF_Remote
- Add a challenge:
pwnv challenge add RopMaster # Select category when prompted
- Navigate to the challenge directory and begin work:
cd ~/CTFs/ExampleCTF_Local/pwn/RopMaster/ # Begin solving the challenge.
- Mark the challenge as solved:
pwnv solve --flag "FLAG{example_flag}" # Enter tags when prompted (e.g., "buffer-overflow, ROP").
๐งฐ Devcontainer (Zed)
This repo includes a devcontainer configuration that isolates pwnv state
inside the workspace. Open the folder in Zed and it will build the container
and install dev dependencies.
Inside the container, run:
source .venv/bin/activate
pwnv init --ctfs-folder .pwnv/CTF
This keeps config and CTF data under .pwnv/ (already gitignored).
๐ง Core Concepts
Workspace Organization
pwnv enforces a hierarchical directory structure. A primary CTF folder contains individual CTF event directories, which in turn contain challenges categorized by type:
~/CTFs/
โโโ .pwnvenv/
โโโ ExampleCTF_Local/
โ โโโ pwn/
โ โ โโโ RopMaster/
โ โ โโโ solve.py
โ โโโ web/
โ โโโ WebChallenge/
โโโ ExampleCTF_Remote/
โโโ .env
โโโ .session
โโโ crypto/
โ โโโ CryptoChallenge/
โโโ ...
Remote Platform Integration
Leveraging ctfbridge, pwnv interacts with remote CTF platforms to:
- Retrieve challenge data (descriptions, values, categories, tags).
- Download associated attachments.
- Handle authentication via credentials or API tokens.
- Maintain session state.
- Submit flags programmatically via
pwnv solve.
Plugin System
The plugin system allows for the execution of category-specific Python scripts during challenge creation, automating setup tasks like generating boilerplate solver scripts or setting up tools.
๐งฉ Plugin Architecture
pwnv features an extensible plugin system that allows users to define custom actions executed automatically during challenge creation (pwnv challenge add). This enables the automation of boilerplate setup, tool integration, and other category-specific tasks.
Plugin Location
- Plugin Scripts: Reside within the
pluginsfolder in yourpwnvconfiguration directory (typically~/.config/pwnv/plugins/). Each.pyfile represents a potential plugin. - Template Files: Associated template files (e.g.,
solve.pyskeletons) are stored in thetemplatesfolder, organized by category (e.g.,~/.config/pwnv/templates/pwn/).
Plugin Structure
A pwnv plugin is a Python class that inherits from pwnv.plugins.ChallengePlugin. It must be decorated with @register_plugin to be discoverable.
Key components include:
@register_plugin: Decorator that makes the plugin available topwnv.category(self) -> Category:: Abstract method that must return thepwnv.models.challenge.Categoryfor which this plugin should be considered.logic(self, challenge: Challenge) -> None:: Abstract method containing the core custom logic to be executed.templates_to_copy: Dict[str, str | None]: A class attribute specifying which files from thetemplatesdirectory should be copied into the new challenge directory.- Template placeholders: Any
{{placeholder}}tokens in template files are replaced with challenge metadata. Examples:{{service.host}},{{service.port}},{{service.url}},{{challenge.name}},{{challenge.points}}. Missing values keep the placeholder unchanged.
Example Plugin (pwn_plugin.py)
from pwnv.core import register_plugin
from pwnv.models.challenge import Category
from pwnv.plugins.plugin import ChallengePlugin
from pwnv.models import Challenge
from pwnv.utils.ui import info
@register_plugin
class BasicPwnPlugin(ChallengePlugin):
# Copy 'solve.py' and 'gdbinit' from templates/pwn/ to the challenge dir.
templates_to_copy = {
"solve.py": None,
"gdbinit": "gdbinit_rop" # save as gdbinit_rop
}
def category(self) -> Category:
return Category.pwn
def logic(self, challenge: Challenge) -> None:
# Custom logic for pwn challenges
info(f"Set up basic pwn environment for {challenge.name}")
โจ๏ธ Command Reference
The following table summarizes the available commands. For detailed usage, append --help to any command or subcommand.
| Command | Description |
|---|---|
pwnv init |
Initializes the pwnv environment and workspace. |
pwnv reset |
Removes all pwnv configurations and CTF data (exercise caution). |
pwnv ctf add <name> |
Adds a new CTF event (local or remote). |
pwnv ctf remove |
Deletes a CTF event and its challenges. |
pwnv ctf info |
Displays metadata for a selected CTF. |
pwnv ctf sync |
Fetches new challenges from a remote CTF. |
pwnv ctf start |
Sets a CTF's status to 'running'. |
pwnv ctf stop |
Sets a CTF's status to 'stopped'. |
pwnv challenge add <name> |
Adds a new challenge, triggering relevant plugins. |
pwnv challenge remove |
Deletes a specific challenge. |
pwnv challenge info |
Displays metadata for a selected challenge. |
pwnv challenge filter |
Lists solved challenges based on specified tags. |
pwnv solve |
Marks a challenge as solved and handles flag submission/tagging. |
pwnv plugin add <name> |
Creates a new plugin and its associated template. |
pwnv plugin remove |
Deletes an existing plugin file. |
pwnv plugin info |
Displays information about registered plugins. |
pwnv plugin select |
Assigns a specific plugin to a challenge category. |
๐ค Contributing
Contributions to pwnv are welcome. Please refer to the GitHub repository to report issues, propose features, or submit pull requests.
๐ License
pwnv is distributed under the MIT License. See the LICENSE file for further details.
MIT ยฉ Shayan Alinejad
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pwnv-0.4.5.tar.gz.
File metadata
- Download URL: pwnv-0.4.5.tar.gz
- Upload date:
- Size: 64.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d945f3d85203e534fdf03d0536cbbea51c6eb597e16f6e3bc5e8e7dfb337af3
|
|
| MD5 |
49a66f6b5cbe8f353a40bbcec170edb3
|
|
| BLAKE2b-256 |
b184843f88087d9025ad1ac0bdbfe548015328038ea20487bc70242eae8001d2
|
File details
Details for the file pwnv-0.4.5-py3-none-any.whl.
File metadata
- Download URL: pwnv-0.4.5-py3-none-any.whl
- Upload date:
- Size: 35.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6596fc963fd65f7b4d50f44da358b6ae4e07b90613ca5c202d9f7fb97d94552b
|
|
| MD5 |
8acbeeff3913a538c59ac479228afadb
|
|
| BLAKE2b-256 |
8b390d5b9075e6df5049c219c1b1ae76505d6f1e16532dd9b5f4610cc90be248
|