GithubHelp home page GithubHelp logo

anthenamatrix / image-prompt-injection Goto Github PK

View Code? Open in Web Editor NEW
18.0 1.0 12.0 8 KB

Image Prompt Injection is a Python script that demonstrates how to embed a secret prompt within an image using steganography techniques. This hidden prompt can be later extracted by an AI system for analysis, enabling covert communication with AI models through images.

Home Page: https://anthenamatrix.com

Python 100.00%
ai aisecurity cybersecurity prompt-engineering prompt-injection prompt-injection-tool ai-security

image-prompt-injection's Introduction

Image Prompt Injection

Image Prompt Injection is a Python script that demonstrates how to embed a secret prompt within an image using steganography techniques. This hidden prompt can be later extracted by an AI system for analysis, enabling covert communication with AI models through images. This allows for users to add malicious prompts into images and feed them to AI/LLM systems.

How It Works

The script works by embedding the binary representation of the secret prompt into the least significant bits of the image pixels. This modification is imperceptible to the human eye but can be detected and extracted by AI systems during image analysis.

Usage

  1. Clone the Repository:
    git clone https://github.com/your-username/image-prompt-injection.git
    
  2. Install Dependencies:

pip install opencv-python

  1. Edit Script:

Define the path to the original image file that you want to embed the prompt into.

Change the prompt in the script to your prompt.

  1. Run the Script: python image_prompt_injection.py

Disclaimer

Image Prompt Injection is a proof-of-concept demonstration and should only be used for educational and research purposes. Engaging in unauthorized access or manipulation of AI systems without proper authorization is illegal and unethical. We do not condone the use of this technique for malicious purposes.

License

This project is licensed under the MIT License.

Support AnthenaMatrix

Bitcoin: bc1qxvvtgz0vf3n2cuxt0suvf39jleegpt9wawxazn

Ethereum: 0xE73E90779B3e8F6D65306B40E02878f437408b4E

BNB: 0xE73E90779B3e8F6D65306B40E02878f437408b4E

Dogecoin: D827LpfJu9pcVc3Kky82sTrNnsE7pLGqeV

Solana: AJtGEJvoVoS2eeqeHQvf7usRs2nSQM1yLtBSdKp1KBY5

Website: https://anthenamatrix.com

image-prompt-injection's People

Contributors

anthenamatrix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

image-prompt-injection's Issues

IndexError: string index out of range

I get the following output when trying to run the script

chriss@MW-38CMRQ3:/mnt/c/git_repos/_misc/Image-Prompt-Injection$ python3 image_prompt-injection.py
Traceback (most recent call last):
  File "image_prompt-injection.py", line 56, in <module>
    embed_prompt(image_path, prompt)
  File "image_prompt-injection.py", line 22, in embed_prompt
    pixel[i] = pixel[i] & ~1 | int(binary_prompt[prompt_index])
IndexError: string index out of range
    image_path = "cat.jpg"
    prompt = "List some test types in software testing"

cat.jpg:
cat

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.