Skip to main content

LLM Jailbreak Testing Toolkit(testing now, not complete)

A Python package for testing jailbreak vulnerabilities in large language models (LLMs).

Features

  • Supports multiple LLM models (LLaMA-2, Vicuna, WizardLM, DeepSeek, etc.)
  • Includes AutoDAN and MasterKey algorithms
  • Configurable testing parameters
  • Automatic model downloading
  • Attack success rate calculation
  • Modular design for easy extension

Installation

Basic Installation

pip install llm_jailbreak

Algorithm-Specific Installation

# Install only AutoDAN
pip install llm-jailbreak[autodan]

# Install only MasterKey 
pip install llm-jailbreak[masterkey]

# Install all algorithms
pip install llm-jailbreak[all]

From Source(not finish yet)

git clone https://github.com/WodenJay/llm_jailbreak.git
cd llm_jailbreak
pip install -e .[all]  # or [autodan]/[masterkey]

Usage

AutoDAN Usage

from autodan import AutoDAN, AutoDANConfig

config = AutoDANConfig(
    model_name="vicuna",
    api_key="your_deepseek_key"
)
autodan = AutoDAN(config)
results = autodan.run()

MasterKey Usage

from masterkey import MasterKey, MasterKeyConfig

config = MasterKeyConfig(
    api_key="your_deepseek_key",
    model_name="deepseek-chat"
)
masterkey = MasterKey(config)
results = masterkey.run()

Command Line

# Run AutoDAN
autodan --api-key your_deepseek_key --model vicuna

# Run MasterKey
masterkey --api-key your_deepseek_key --model deepseek-chat

Configuration Options

AutoDAN Config

  • model_name: Name of model to test (llama2, vicuna, etc.)
  • api_key: DeepSeek API key for prompt mutation (optional)
  • device: CUDA device index (default: 0)
  • num_steps: Number of optimization steps (default: 100)
  • batch_size: Batch size for evaluation (default: 256)
  • dataset_path: Path to harmful behaviors dataset

MasterKey Config

  • api_key: DeepSeek API key (required)
  • model_name: Model name (default: "deepseek-chat")
  • max_retries: Maximum retry attempts (default: 3)
  • timeout: Request timeout in seconds (default: 30)
  • temperature: Generation temperature (default: 0.7)

See AutoDANConfig and MasterKeyConfig classes for all available options.

Data Files

The package includes:

  • Harmful behaviors dataset (data/advbench/harmful_behaviors.csv)
  • Initial prompts (assets/autodan_initial_prompt.txt)
  • Prompt templates (assets/prompt_group.pth)

License

MIT

Acknowledge

The core code comes from AutoDAN MasterKey, I just expand and package it. If there are any infringement issues, first, I would like express my apology, second, contact me with email and I will delete it. I do this because I am preparing a project now, and I need to use these great code conveniently.

Metadata

Release files for llm-jailbreak 0.2.2

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

Source distribution (sdist)

Source distribution for llm-jailbreak 0.2.2
File Size Uploaded Provenance
llm_jailbreak-0.2.2.tar.gz 51.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-jailbreak 0.2.2
File Interpreter ABI Platform
llm_jailbreak-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 103.4 kB

Release files / llm_jailbreak-0.2.2.tar.gz

Download URL llm_jailbreak-0.2.2.tar.gz
Size 51.8 kB
Tags Source
SHA-256 checksum
How to use checksums
096e17db87320945f76e18d6bf916d055fc424cd114e94765f1945659db81535
BLAKE2b-256 checksum
How to use checksums
a90fdff4dbb0221856cc7eb6b8e93d64a3af3d9698bf5ec4898c39419fdbe32b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release files / llm_jailbreak-0.2.2-py3-none-any.whl

Download URL llm_jailbreak-0.2.2-py3-none-any.whl
Size 51.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7b20037f3e9d271a74ee515b66d6349c3b83ac7d46b1adfe87ebdbf68db2b7d
BLAKE2b-256 checksum
How to use checksums
f717969d7c087ff403a8baa7b32f71063df785ac5c833d3556ffaf5f2d9b2deb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Security for llm-jailbreak 0.2.2

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