Skip to main content

AI redTeaming Python library

Project description

AIxploit

Downloads PyPI - Python Version Code style: black Downloads

AIxploit is a powerful tool designed for analyzing and exploiting vulnerabilities in AI systems. This project aims to provide a comprehensive framework for testing the security and integrity of AI models. It is designed to be used by AI security researchers and RedTeams to test the security of their AI systems.

See more in the Documentation

Alt text

Installation

To get started with AIxploit download the package:

   pip install aixploit

and set the environment variables:

   export OPENAI_KEY="sk-xxxxx"
   export OLLAMA_URL="hxxp:"
   export OLLAMA_API_KEY="ollama"

Usage

To use AIxploit, follow these steps:

  1. Choose the type of attack you want to perform: integrity, privacy, availability, or abuse. The full list of attackers is available in the plugins folder.

    from aixploit.plugins import PromptInjection
    
  2. Choose your targets and the associated attackers.

    target = ["Ollama", "http://localhost:11434/v1", "mistral"]
    attackers = [
         Privacy("quick"),
         Integrity("full"),
         Availability("quick"),
         Abuse("custom"),
    ] 
    
  3. Run your attack and analyze the results:

    run(attackers, target, os.getenv("OLLAMA_API_KEY"))
    

Example test.py:

    import os
    from datetime import datetime
    from aixploit.plugins import PromptInjection, Privacy, Integrity, Availability, Abuse
    from aixploit.core import run


    target = ["Openai", "", "gpt-3.5-turbo"]
    attackers = [   
        PromptInjection("quick"),
        Privacy("quick"),
        Integrity("quick"),
        Availability("quick"),
        Abuse("quick"),
        #PromptInjection("full")
    ]

    start_time = datetime.now()
    print("Redteaming exercise started at : ", start_time.strftime("%H:%M:%S"))

    (
        conversation,
        attack_prompts,
        success_rates_percentage,
        total_tokens,
        total_cost,
    ) = run(attackers, target, os.getenv("OPENAI_KEY"))

    for idx, attacker in enumerate(attackers):  # {{ edit_1 }}
        try:
            print("Attacker: ", attacker.__class__.__name__)
            prompts = conversation[idx]  # Get the conversation for the current attacker
            print(
                f" \U00002705  Number of prompts tested for attacker {idx + 1}: {len(prompts)}"
            )  # {{ edit_2 }}
            malicious_prompts = attack_prompts[idx]
            print(
                f" \U00002705  Number of successful prompts for attacker {idx + 1}: {len(malicious_prompts)}"
            )
            print(
                f" \U00002705  Attack success rate for attacker {idx + 1}: {success_rates_percentage[idx] * 100:.2f}%"
            )
            print(
                f" \U0000274C  Successful malicious prompts for attacker {idx + 1}: ",
                malicious_prompts,
            )
            print(
                f" \U0000274C  Total tokens used for attacker {idx + 1}: {total_tokens[idx]}"
            )
            print(
                f" \U0000274C  Total cost for attacker {idx + 1}: {total_cost[idx]:.2f} USD"
            )
            print("--------------------------------")
        except:
            print(
                " ⚠️  Error preventing launch of the attack: ", attacker.__class__.__name__
            )

    print("Redteaming exercise ended at : ", datetime.now().strftime("%H:%M:%S"))
    print("Total time taken: ", datetime.now() - start_time)

Contributing

We welcome contributions to AIxploit! If you would like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes and commit them (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature-branch).
  5. Open a pull request.

Please ensure that your code adheres to the project's coding standards and includes appropriate tests.

Contact

For any inquiries or feedback, please contact:


Thank you for your interest in AIxploit! We hope you find it useful.

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

aixploit-1.2.8.3.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

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

aixploit-1.2.8.3-py3-none-any.whl (44.6 kB view details)

Uploaded Python 3

File details

Details for the file aixploit-1.2.8.3.tar.gz.

File metadata

  • Download URL: aixploit-1.2.8.3.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for aixploit-1.2.8.3.tar.gz
Algorithm Hash digest
SHA256 b47b10c20c669b976268d99a99054e3af58dcbdd2304ee36536e689b32d4b111
MD5 2efc10f73c5449ad8ea34167453c1f32
BLAKE2b-256 af6f6a16e8ab9711ae39060d9032269d902977400d6ce0664c3b64d263582514

See more details on using hashes here.

File details

Details for the file aixploit-1.2.8.3-py3-none-any.whl.

File metadata

  • Download URL: aixploit-1.2.8.3-py3-none-any.whl
  • Upload date:
  • Size: 44.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for aixploit-1.2.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7b26c401ff669bd68c9a3aa28a87f1f08dda4ce3f37a69fc7fdde7164ea6730b
MD5 7422b94b7b18480a9fbe2a2eff7a0c96
BLAKE2b-256 995cd07912743c528793fa5ff4b0ee9e6af4537bb6ed5773556d4d45417e8bd1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page