A charset generator for CTFs
Project description
Charset Generator
Overview
This package is designed to make CTF char-by-char bruteforce simpler.
Installation
pip install charset-generator
Documentation
Charsets can be generated from string.printable using gen_charset.
If frequency_sorted is True, then it will be ordered based on frequency,
with the most frequent characters appearing first.
gen_charset(regex: str, frequency_sorted: bool = False) -> str:
Characters can be produced from a generator using yielding.yield_charset.
If allow_interruptions is True, then the user can press the interrupt_key,
to temporarily take over, allowing them to choose the next character. This is
useful for cases where the user can predict the next character faster than it
would take to bruteforce through the charset.
yielding.yield_charset(regex: str, frequency_sorted: bool = False, allow_interruptions: bool = False, interrupt_key: str = "esc") -> Generator[str, None, None]:
ai.assess_predictability and ai.predict_next_char are both highly experimental.
Together, they allow you to use OpenAI to predict the next character of a flag,
given some prefix known_text.
Use these with caution.
ai.assess_predictability(
known_text: str, openai_api_key: str, model: str = "gpt-4o-mini",
role: str = "You are a professional CTF hacker.",
prompt: str = (
"You will receive the first part of a flag. Analyze it and decide how confident you are in predicting "
"the next character with 100% accuracy. Provide a brief explanation, then on a new line output exactly "
"'~~' followed by one of these options: 'Very confident', 'Somewhat confident', or 'Not confident'.\n"
"Example:\n"
"The flag starts with 'CTF{' but many characters could follow.\n"
"~~Not confident\n"
)
) -> str
ai.predict_next_char(
known_text: str, openai_api_key: str, banned_chars: List[str] = [], model: str = "gpt-4o-mini",
role: str = "You are a professional CTF hacker.",
prompt: str = (
"You will receive the first part of a flag. Predict the next character with no extra text. "
"Your answer must be exactly one character. Note that flags may include leet speak or underscores.\n"
)
) -> str
Project details
Release history Release notifications | RSS feed
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 charset_generator-1.0.1.tar.gz.
File metadata
- Download URL: charset_generator-1.0.1.tar.gz
- Upload date:
- Size: 41.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95a0c67b82671dbf7df51185fcb738f1d14891ed6e404e111bcc934afb137fbe
|
|
| MD5 |
ef42c8227f138762ea1b2d41aeb2f297
|
|
| BLAKE2b-256 |
88145e4e3341ea983398f7aa9a4cf6a3b1686e247f82b456d40e46c5c2fd20c1
|
File details
Details for the file charset_generator-1.0.1-py3-none-any.whl.
File metadata
- Download URL: charset_generator-1.0.1-py3-none-any.whl
- Upload date:
- Size: 30.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68de26176fd8867839680ef5dd6881537ff18813d55548001a45911b7d36c12b
|
|
| MD5 |
cf1c0caa5122a3dedac4fcfe21da8f5c
|
|
| BLAKE2b-256 |
d3b215f9969492125dd89af39400dcd597d81deccf7bab1cdc16fa176c2afcf8
|