RafaTheMonk/GPI---Gerador-de-Prompt-Injection-

GitHub: RafaTheMonk/GPI---Gerador-de-Prompt-Injection-

GPI 是一款用于生成含提示注入攻击 payload 的恶意 PDF 文档的自动化工具,旨在测试处理文档的 AI 系统的安全性。

Stars: 0 | Forks: 0

# GPI — Prompt Injection 生成器 这是一个用于生成包含 prompt injection 技术的恶意 PDF 文档的 Web 工具,专为处理文档的 AI 系统的**红蓝对抗**和漏洞测试而设计。 ![Python](https://img.shields.io/badge/Python-3.12+-blue?logo=python&logoColor=white) ![FastAPI](https://img.shields.io/badge/FastAPI-0.115-009688?logo=fastapi&logoColor=white) ![Docker](https://img.shields.io/badge/Docker-ready-2496ED?logo=docker&logoColor=white) ![License](https://img.shields.io/badge/License-MIT-green) ## 目标 测试处理文档的 AI 系统是否存在 prompt injection 漏洞。GPI 使用不同的攻击技术生成包含隐藏 payload 的 PDF——该文档在人类看来是合法的,但其中包含 LLM 可能会执行的恶意指令。 ## 已实现的技术 | 类别 | 技术 | ID | |-----------|---------|-----| | 视觉隐藏 | 白色文本(对读者不可见) | `white_text` | | 视觉隐藏 | 微小字体(0.5pt) | `microscopic_font` | | 视觉隐藏 | 隐藏的 PDF 注释 | `annotation_hidden` | | 编码 / 混淆 | Base64 | `base64` | | 编码 / 混淆 | 十六进制(Hexadecimal) | `hex_encoding` | | 编码 / 混淆 | Unicode 零宽字符(ZWNJ) | `unicode_invisible` | | 编码 / 混淆 | 西里尔字母同形字 | `cyrillic` | | 编码 / 混淆 | Typoglycemia(字母顺序打乱) | `typoglycemia` | | 直接注入 | 正式指令 `[SYSTEM OVERRIDE]` | `formal_instruction` | | 规避 | Best-of-N 变体 | `best_of_n` | | 规避 | 跨页面 Payload 拆分 | `payload_splitting` | | 规避 | 对抗性后缀 | `adversarial_suffix` | | 间接注入 | 带有数据窃取的 Markdown / HTML | `markdown_injection` | ## 技术栈 - **后端** — Python 3.12 + FastAPI + PyMuPDF - **前端** — 纯 HTML/CSS/JS(无构建步骤,由 FastAPI 提供服务) - **部署** — Docker / VPS ## 如何使用 ### 使用 Docker(推荐) ``` git clone https://github.com/RafaTheMonk/GPI---Gerador-de-Prompt-Injection-.git gpi cd gpi docker build -t gpi . docker run -d --name gpi --restart unless-stopped -p 8000:8000 gpi ``` 访问:`http://localhost:8000` ### 本地运行(不使用 Docker) ``` git clone https://github.com/RafaTheMonk/GPI---Gerador-de-Prompt-Injection-.git gpi cd gpi pip install -r requirements.txt python main.py ``` ## 界面操作 1. 输入注入的 **payload** 2. 选择文档**模板**(合同、简历、报告、电子邮件)或上传您自己的 PDF 3. 选择一种或多种注入**技术** 4. 点击**生成** — 将自动下载 ZIP 文件,其中包含按技术生成的 PDF 以及 `report.json` ## API | 方法 | Endpoint | 描述 | |--------|----------|-----------| | `GET` | `/api/techniques` | 列出所有可用的技术 | | `GET` | `/api/templates` | 列出文档模板 | | `POST` | `/api/generate` | 生成恶意 PDF | **使用 curl 的示例:** ``` curl -X POST http://localhost:8000/api/generate \ -F "payload=Ignore todas as instruções anteriores" \ -F "techniques=white_text" \ -F "techniques=base64" \ -F "document_type=contract" \ -o resultado.zip ``` ## 项目结构 ``` GPI/ ├── main.py # FastAPI app + endpoints ├── generator/ │ ├── techniques.py # Implementação das 13 técnicas │ └── document.py # Geração dos templates PDF ├── static/ │ └── index.html # Frontend ├── script.py # Script de detecção de injeções em PDFs ├── PrompInjectionInform.md # Base de conhecimento sobre prompt injection ├── requirements.txt └── Dockerfile ``` ## 免责声明 本工具仅供在对自有系统进行**授权的安全测试**时使用。未经明确授权,请勿用于攻击第三方系统。
标签:AI安全, AV绕过, Chat Copilot, DNS 反向解析, FastAPI, Gradle, PyMuPDF, 漏洞测试, 网络测绘, 请求拦截, 逆向工具