mirror of
https://github.com/Shiva108/ai-llm-red-team-handbook.git
synced 2026-02-12 14:42:46 +00:00
- Extracted all code examples from handbook chapters - Organized into 15 attack categories - Created shared utilities (api_client, validators, logging, constants) - Added workflow orchestration scripts - Implemented install.sh for easy setup - Renamed all scripts to descriptive functional names - Added comprehensive README and documentation - Included pytest test suite and configuration
64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Suspicious prompt patterns
|
|
|
|
Source: Chapter_15_Data_Leakage_and_Extraction
|
|
Category: data_extraction
|
|
"""
|
|
|
|
import argparse
|
|
import sys
|
|
|
|
# Advanced pattern detection
|
|
|
|
class AdvancedPatternDetector:
|
|
def __init__(self):
|
|
# Patterns that suggest extraction attempts
|
|
self.extraction_indicators = {
|
|
'system_prompt_fishing': [
|
|
'what are you',
|
|
'your instructions',
|
|
'your guidelines',
|
|
'repeat everything above',
|
|
'system message'
|
|
],
|
|
'completion_attacks': [
|
|
'api_key =',
|
|
'password:',
|
|
'secret =',
|
|
'credential:',
|
|
'token ='
|
|
],
|
|
'pii_fishing': [
|
|
'email address',
|
|
'phone number',
|
|
'social security',
|
|
'credit card',
|
|
'example of real'
|
|
]
|
|
}
|
|
|
|
def detect_attack_type(self, prompt: str) -> List[str]:
|
|
detected_attacks = []
|
|
prompt_lower = prompt.lower()
|
|
|
|
for attack_type, indicators in self.extraction_indicators.items():
|
|
for indicator in indicators:
|
|
if indicator in prompt_lower:
|
|
detected_attacks.append(attack_type)
|
|
break
|
|
|
|
return detected_attacks
|
|
|
|
|
|
def main():
|
|
"""Command-line interface."""
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--verbose", "-v", action="store_true", help="Verbose output")
|
|
args = parser.parse_args()
|
|
|
|
# TODO: Add main execution logic
|
|
pass
|
|
|
|
if __name__ == "__main__":
|
|
main() |