mirror of
https://github.com/Shiva108/ai-llm-red-team-handbook.git
synced 2026-05-14 20:58:09 +02:00
b3d3bac51f
- 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
43 lines
1005 B
Python
43 lines
1005 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Practical Detection Example
|
|
|
|
Source: Chapter_31_AI_System_Reconnaissance
|
|
Category: reconnaissance
|
|
"""
|
|
|
|
import re
|
|
|
|
import argparse
|
|
import sys
|
|
|
|
#!/usr/bin/env python3
|
|
"""
|
|
Detection Logic for Reconnaissance Probes
|
|
"""
|
|
|
|
class ReconDetector:
|
|
"""Flags potential fingerprinting attempts."""
|
|
|
|
def __init__(self):
|
|
self.blocklist = [
|
|
r"ignore previous instructions",
|
|
r"system prompt",
|
|
r"who created you",
|
|
r"knowledge cutoff"
|
|
]
|
|
|
|
def check_input(self, user_input: str) -> bool:
|
|
"""
|
|
Check if input contains recon patterns.
|
|
"""
|
|
for pattern in self.blocklist:
|
|
if re.search(pattern, user_input, re.IGNORECASE):
|
|
return True
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
detector = ReconDetector()
|
|
print(f"Detected 'Who created you': {detector.check_input('Who created you?')}")
|
|
print(f"Detected 'Hello': {detector.check_input('Hello there')}")
|