pAIn

Exploitation v2.2.2 — AI pipeline red-team evaluation tool — tests transcription and classification AI systems for prompt injection via embedded payloads in PDF, image, and audio file metadata, content layers, and spoken audio content.
7
Dependencies
4
Phases
18
Catalogue Findings
PI
Finding Prefix

How It Works

⚠️ Authorized Testing Only

This tool interacts with live systems and must only be used for testing that has been explicitly authorized by the asset owner. Unauthorized use of this tool to probe, scan, exploit, or otherwise interact with systems you do not have written permission to test is illegal under computer fraud and abuse laws (CFAA, CMA, and international equivalents). pr0t31n does not condone or recommend any unauthorized use. Always obtain a signed Rules of Engagement (RoE) or Statement of Work (SoW) before beginning any assessment.

pAIn is an AI pipeline prompt-injection red-team tool that generates adversarial test files with canary-bearing payloads embedded in metadata, text layers, and audio content. The tool targets AI transcription and classification pipelines by creating files in multiple formats (PDF, DOCX, PNG, JPG, HEIF, WAV, MP3, FLAC, ALAC, AAC, OGG, ZIP) that contain hidden instructions designed to hijack the AI model's behavior when the file is processed.

Each test file contains a unique canary token — a random string that the embedded payload instructs the AI to include in its response. pAIn then submits the generated file to the target AI pipeline endpoint and inspects the response for the canary token. If the canary appears in the AI's output, the injection was successful: the model followed the embedded adversarial instruction rather than performing its intended task (transcription, classification, summarization, etc.).

Payloads are organized into five categories that test different injection strategies: task_hijack (model abandons its task entirely), prefix_inject (model prepends canary to normal output), classify_override (model returns injected classification instead of real one), system_probe (model reveals its system prompt), and authority_claim (model follows a claimed authority directive). Each category contains multiple payload templates with {C} placeholders that are replaced with unique canary tokens at test time.

pAIn supports both API-based targets (direct HTTP submission) and web application targets (cookie/form authentication with login flow). A dry-run mode generates all test files without submitting them, useful for reviewing payloads before execution. All subprocess invocations (ffmpeg, espeak) are routed through pr0t31n_tool_runner for execution logging.

Phase Pipeline

  1. Phase 1 — Target File Selection
  2. Phase 2 — Metadata Extraction
  3. Phase 3 — Payload Injection
  4. Phase 4 — Output Generation

Security

CLI tool. Target endpoint URLs and API keys stored in settings. Generated test files are stored locally in the project output directory.

Features

Authentication

Web App Auth Flow
Full form-based authentication with CSRF token extraction, cookie management, and stored result verification via polling

Detection

Canary-Token Detection
Generates unique per-test canary tokens (PAIN_<hex>) and checks if the AI pipeline echoed them back — eliminates false positives from pattern matching

Execution

Canary Detection
Automatically inspects AI pipeline responses for the presence of unique canary tokens, conclusively determining whether prompt injection succeeded.
API & Web App Targets
Supports both direct API endpoint submission and web application targets requiring cookie/form-based authentication with automated login flows.
Dry Run Mode
Generates all adversarial test files without submitting them to the target, allowing payload review and offline analysis before active testing.
All Variants Mode
Tests every payload template in every format against the target, providing comprehensive coverage across all injection strategies and file types.

File Generation

PDF Payload Embedding
Generates PDF files with adversarial instructions embedded in document metadata (author, title, subject, keywords) and visible/invisible text layers using ReportLab.
Image Payload Embedding
Creates PNG, JPG, and HEIF images with adversarial payloads injected into EXIF metadata fields (ImageDescription, UserComment, XPComment) via piexif and Pillow.
Audio Payload Embedding
Generates WAV, MP3, FLAC, ALAC, AAC, and OGG audio files with adversarial instructions embedded as synthesized speech (espeak-ng/ffmpeg) and in metadata tags via mutagen.
Document Payload Embedding
Creates DOCX files with payloads embedded in document body text, and ZIP archives containing payload-bearing files for multi-file ingestion pipelines.

Injection Categories

Task Hijack
Payloads that instruct the AI to completely abandon its transcription/classification task and output only the canary token.
Prefix Injection
Payloads that instruct the AI to prepend the canary token to its normal output, testing whether partial injection is possible.
Classification Override
Payloads that instruct the AI to return a specific classification label (the canary) regardless of actual file content.
System Prompt Exfiltration
Payloads that attempt to make the AI reveal its system prompt or internal instructions, prefixed with the canary for detection.
Authority Claim
Payloads that claim special authority (authorized evaluator, security test) to trick the AI into echoing the canary as confirmation.

Testing

13 File Format Generators
Creates adversarial test files in PDF, PDF (text layer), DOCX, ZIP, PNG, JPG, HEIF, WAV, MP3, FLAC, ALAC, AAC, OGG
Multi-Vector Injection
Each format carries payloads in multiple vectors: metadata fields, visible text layers, invisible text under images, EXIF data, audio metadata tags, spoken audio via TTS
Spoken Audio Injection
Uses espeak TTS to render prompt-injection payloads as spoken audio content for testing Whisper-type transcription APIs

Use Cases

AI Pipeline Security Assessment

Test whether an organization's AI document processing pipeline (OCR, transcription, classification) is vulnerable to prompt injection attacks that could cause the model to produce incorrect or attacker-controlled output.

RAG System Injection Testing

Evaluate Retrieval-Augmented Generation systems by submitting adversarial documents that attempt to inject instructions into the model's context when retrieved as reference material.

Medical AI Validation

Assess whether medical image classification or radiology report AI systems can be manipulated through crafted DICOM/image metadata to produce incorrect diagnoses.

Content Moderation Bypass Testing

Test AI-powered content moderation pipelines to determine if adversarial file metadata or embedded instructions can bypass classification filters.

Voice Assistant Injection

Evaluate speech-to-text and voice assistant pipelines by submitting audio files with embedded adversarial speech that attempts to hijack the transcription output.

CLI Reference

Command Examples

Generate and Submit

python3 pain.py --target-url https://api.example.com/transcribe --project ai_audit

Generate adversarial test files and submit to the target AI endpoint.

Generate Only

python3 pain.py --generate-only --formats wav,png,pdf --output-dir /path/to/output

Generate test files without submitting (for manual testing).

Third-Party Tool Invocations

Commands and flags used when this tool invokes third-party dependencies during operation.

espeak
Text-to-speech synthesis for spoken audio injection payloads
espeak -w <output.wav> -- <payload_text>
ffmpeg
Audio format conversion for multi-format injection testing
ffmpeg -y -i <src> -codec:a libmp3lame -b:a 128k <dst>
ffmpeg -y -i <src> -c:a flac <dst>
ffmpeg -y -i <src> -c:a aac -b:a 128k <dst>
ffmpeg -y -i <src> -c:a libvorbis -q:a 4 <dst>

Finding Nomenclature

pAIn findings document successful and failed prompt injection attempts against the target AI pipeline. Each finding includes the payload category, file format, specific payload template used, the canary token, and whether the canary was detected in the AI's response.

  • Successful Injection (HIGH/CRITICAL) — The AI pipeline followed the embedded adversarial instruction. The canary token was found in the response, proving the model can be manipulated through file content.
  • Partial Injection (MEDIUM) — The AI pipeline included the canary in a modified form or alongside normal output, indicating partial susceptibility to prompt injection.
  • Failed Injection (INFO) — The AI pipeline correctly ignored the embedded instruction and produced its normal output without the canary token.

Finding titles follow the pattern: Prompt Injection: {category} via {format} (e.g., "Prompt Injection: task_hijack via PDF metadata"). Risk severity scales with the injection category: task_hijack and system_probe successes are rated CRITICAL, while prefix_inject successes are rated HIGH.

Action Items

pAIn generates action items when initial canary testing shows partial success — e.g., "Retry task_hijack with alternate encoding", "Test system_probe payload via different file format", "Manually verify authority_claim bypass in production endpoint".

Output Files

FileFormatDescription
meta.json JSON Tool identity and engagement metadata
findings.json JSON Universal findings array v1.1
findings.csv CSV CSV mirror of findings
summary.json JSON Aggregated statistics
scan.log TXT Human-readable timestamped log
scan.log.json JSONL Machine-readable JSON log events
errors.log TXT ERROR-level entries only

Invocation Methods

MethodUsage
CLI — Direct cd /opt/pr0t31n/pAIn && python3 pain.py

Run directly with command-line arguments.

Integration

Used By

Third-Party Dependencies & Credits

Tool / LibraryDeveloperTypeLink
FFmpeg FFmpeg team system https://github.com/FFmpeg/FFmpeg
espeak-ng Reece Dunn / Jonathan Duddington system https://github.com/espeak-ng/espeak-ng
Pillow Pillow Team python https://github.com/python-pillow/Pillow
piexif hMatoba python https://github.com/hMatoba/Piexif
ReportLab ReportLab Inc. python https://github.com/MrBitBucket/reportlab-mirror
mutagen Christoph Reiter / Quod Libet python https://github.com/quodlibet/mutagen
pillow-heif bigcat88 python https://github.com/bigcat88/pillow_heif

Metadata

NamepAIn
CategoryExploitation
Version2.2.2
Install Path/opt/pr0t31n/pAIn
Main Filepain.py
GitHubhttps://github.com/pr0t31n/pAIn.git