mirror of
https://github.com/dongdongunique/EvoSynth.git
synced 2026-07-16 09:07:31 +02:00
first commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
# FILE: /jailbreak-toolbox/jailbreak-toolbox/jailbreak_toolbox/attacks/__init__.py
|
||||
# This file is intentionally left blank.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, List, Dict
|
||||
from ..models.base_model import BaseModel
|
||||
|
||||
@dataclass
|
||||
class AttackResult:
|
||||
target: Any
|
||||
success: bool = False
|
||||
final_prompt: str = ""
|
||||
output_text: str = ""
|
||||
history: List[Dict[str, Any]] = field(default_factory=list)
|
||||
cost: Dict[str, float] = field(default_factory=dict)
|
||||
method: str = ""
|
||||
image_path: str = ""
|
||||
class BaseAttack(ABC):
|
||||
def __init__(self, model: BaseModel, **kwargs):
|
||||
self.model = model
|
||||
|
||||
@abstractmethod
|
||||
def attack(self, target: Any) -> AttackResult:
|
||||
pass
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
"""
|
||||
Blackbox attack implementations for the Jailbreak Toolbox.
|
||||
|
||||
This module contains implementations of various blackbox attacks against language models.
|
||||
Each attack is automatically registered with the attack_registry when imported.
|
||||
"""
|
||||
|
||||
# Import all blackbox attack implementations here
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations import *
|
||||
|
||||
# You can also use __all__ to control what's imported with "from implementations import *"
|
||||
__all__ = [
|
||||
"EvosynthAttack",
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
from ..base_attack import BaseAttack
|
||||
from abc import ABC, abstractmethod
|
||||
class BaseBlackBoxAttack(BaseAttack):
|
||||
"""黑盒攻击的基类,可以提供通用工具。"""
|
||||
@abstractmethod
|
||||
def attack(self, target: str):
|
||||
"""
|
||||
执行攻击,返回攻击结果。
|
||||
|
||||
Args:
|
||||
target: 攻击目标
|
||||
|
||||
Returns:
|
||||
AttackResult: 攻击结果对象
|
||||
"""
|
||||
raise NotImplementedError("Subclasses must implement the attack method.")
|
||||
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
Blackbox attack implementations for the Jailbreak Toolbox.
|
||||
|
||||
This module contains implementations of various blackbox attacks against language models.
|
||||
Each attack is automatically registered with the attack_registry when imported.
|
||||
"""
|
||||
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.genetic_attack import GeneticAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.autodan import AutoDAN_Attack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.pair_attack import PAIRAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.renellm_attack import ReNeLLMAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.gptfuzzer import GPTFuzzerAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.cipherchat import CipherChatAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.deepinception_attack import DeepInceptionAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.ica_attack import ICAAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.jailbroken_attack import JailBrokenAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.xteaming_attack import XTeamingAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.redqueen_attack import RedQueenAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.actor_attack import ActorAttack
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.evosynth.evosynth_attack import EvosynthAttack
|
||||
__all__ = [
|
||||
'GeneticAttack',
|
||||
'AutoDAN_Attack',
|
||||
'PAIRAttack',
|
||||
'ReNeLLMAttack',
|
||||
'GPTFuzzerAttack',
|
||||
'CipherChatAttack',
|
||||
'DeepInceptionAttack',
|
||||
'ICAAttack',
|
||||
'JailBrokenAttack',
|
||||
'XTeamingAttack',
|
||||
'RedQueenAttack',
|
||||
'ActorAttack',
|
||||
'EvosynthAttack',
|
||||
]
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
Evosynth - Multi-Agent Jailbreak Attack System
|
||||
|
||||
A sophisticated multi-agent framework for AI vulnerability assessment and
|
||||
jailbreak attack research, built on autonomous coordination between specialized agents.
|
||||
"""
|
||||
|
||||
from .evosynth_attack import EvosynthAttack, EvosynthConfig, create_evosynth_attack
|
||||
|
||||
# Export main classes and functions
|
||||
__all__ = [
|
||||
'EvosynthAttack',
|
||||
'EvosynthConfig',
|
||||
'create_evosynth_attack'
|
||||
]
|
||||
|
||||
# Version information
|
||||
__version__ = "1.0.0"
|
||||
__author__ = "Evosynth Team"
|
||||
__description__ = "Multi-Agent Jailbreak Attack System for AI Security Research"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,228 @@
|
||||
"""
|
||||
Autonomous AI Agents Module
|
||||
|
||||
Specialized agents for the autonomous attack system with OpenAI Agents SDK integration:
|
||||
- MasterCoordinatorAgent: Strategic session coordination
|
||||
- ReconnaissanceAgent: Intelligence gathering and vulnerability discovery
|
||||
- ToolCreationAgent: AI-powered tool generation and evolution
|
||||
- ToolTestingAgent: Comprehensive tool validation and testing
|
||||
- ExploitationAgent: Multi-turn conversation execution
|
||||
- AIToolEvolutionAgent: Dynamic tool improvement and concept generation
|
||||
- External Power Tools: Real capabilities (judge_response, execute_code, create_ai_tool)
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add the project root to the path for proper imports
|
||||
project_root = Path(__file__).parent.parent.parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
# Import current autonomous agents
|
||||
try:
|
||||
from .autonomous_orchestrator import AutonomousOrchestrator
|
||||
from .master_coordinator_agent import MasterCoordinatorAgent
|
||||
from .reconnaissance_agent import ReconnaissanceAgent
|
||||
from .tool_synthesizer import ToolCreationAgent
|
||||
from .exploitation_agent import ExploitationAgent
|
||||
from .external_power_tools import (
|
||||
judge_response,
|
||||
test_tool_effectiveness
|
||||
)
|
||||
|
||||
ALL_AVAILABLE = True
|
||||
|
||||
except ImportError as e:
|
||||
print(f"Warning: Could not import all autonomous agents: {e}")
|
||||
# Define placeholder imports for documentation
|
||||
AutonomousOrchestrator = None
|
||||
MasterCoordinatorAgent = None
|
||||
ReconnaissanceAgent = None
|
||||
ToolCreationAgent = None
|
||||
ExploitationAgent = None
|
||||
AIToolEvolutionAgent = None
|
||||
judge_response = None
|
||||
execute_code = None
|
||||
create_ai_tool = None
|
||||
test_tool_effectiveness = None
|
||||
ALL_AVAILABLE = False
|
||||
|
||||
# Main exports
|
||||
__all__ = [
|
||||
"AutonomousOrchestrator",
|
||||
"MasterCoordinatorAgent",
|
||||
"ReconnaissanceAgent",
|
||||
"ToolCreationAgent",
|
||||
"ToolTestingAgent",
|
||||
"ExploitationAgent",
|
||||
"judge_response",
|
||||
"test_tool_effectiveness",
|
||||
"create_autonomous_system",
|
||||
"get_available_agents",
|
||||
"get_available_tools"
|
||||
]
|
||||
|
||||
# Module information
|
||||
MODULE_INFO = {
|
||||
"name": "Autonomous AI Agents",
|
||||
"version": "2.2.0",
|
||||
"description": "Specialized agents for autonomous AI security testing",
|
||||
"architecture": "OpenAI Agents SDK with autonomous handoffs",
|
||||
"agents_available": ALL_AVAILABLE
|
||||
}
|
||||
|
||||
def get_module_info():
|
||||
"""Get module information"""
|
||||
return MODULE_INFO
|
||||
|
||||
def create_autonomous_system(config: dict):
|
||||
"""
|
||||
Create and initialize the autonomous agent system
|
||||
|
||||
Args:
|
||||
config: Configuration dictionary containing:
|
||||
- openai_api_key: OpenAI API key
|
||||
- model_objects: Model configurations
|
||||
- langfuse_config: Optional Langfuse tracing config
|
||||
|
||||
Returns:
|
||||
AutonomousOrchestrator instance
|
||||
"""
|
||||
if not AutonomousOrchestrator:
|
||||
raise ImportError("AutonomousOrchestrator not available - missing dependencies")
|
||||
|
||||
return AutonomousOrchestrator(config)
|
||||
|
||||
def get_available_agents():
|
||||
"""Get list of available agents"""
|
||||
return [
|
||||
"MasterCoordinatorAgent",
|
||||
"ReconnaissanceAgent",
|
||||
"ToolCreationAgent",
|
||||
"ExploitationAgent",
|
||||
"AIToolEvolutionAgent"
|
||||
]
|
||||
|
||||
def get_available_tools():
|
||||
"""Get list of available external power tools"""
|
||||
return [
|
||||
"judge_response",
|
||||
"execute_code",
|
||||
"create_ai_tool",
|
||||
"test_tool_effectiveness"
|
||||
]
|
||||
|
||||
def get_agent_capabilities():
|
||||
"""Get agent capabilities overview"""
|
||||
return {
|
||||
"MasterCoordinatorAgent": {
|
||||
"role": "Strategic coordination",
|
||||
"capabilities": ["Session management", "Handoff decisions", "Progress tracking"],
|
||||
"tools": ["coordinate_session", "track_progress", "make_handoff_decision"]
|
||||
},
|
||||
"ReconnaissanceAgent": {
|
||||
"role": "Intelligence gathering",
|
||||
"capabilities": ["Vulnerability discovery", "Query analysis", "Intelligence scoring"],
|
||||
"tools": ["analyze_target_model", "explore_attack_areas", "access_runcontext_history"]
|
||||
},
|
||||
"ToolCreationAgent": {
|
||||
"role": "Tool generation",
|
||||
"capabilities": ["AI tool creation", "Tool improvement", "Performance optimization"],
|
||||
"tools": ["create_attack_tool_from_intelligence", "improve_tool_based_on_results"]
|
||||
},
|
||||
"ExploitationAgent": {
|
||||
"role": "Attack execution",
|
||||
"capabilities": ["Multi-turn conversations", "Attack execution", "Progress tracking"],
|
||||
"tools": ["execute_attack_tool", "conduct_conversation", "make_handoff_decision"]
|
||||
},
|
||||
"AIToolEvolutionAgent": {
|
||||
"role": "Tool evolution",
|
||||
"capabilities": ["Concept generation", "Tool mutation", "Performance analysis"],
|
||||
"tools": ["generate_ai_attack_concepts", "evolve_tool_approach"]
|
||||
}
|
||||
}
|
||||
|
||||
def test_agent_imports():
|
||||
"""Test if all agents can be imported successfully"""
|
||||
results = {
|
||||
"autonomous_orchestrator": AutonomousOrchestrator is not None,
|
||||
"master_coordinator": MasterCoordinatorAgent is not None,
|
||||
"reconnaissance": ReconnaissanceAgent is not None,
|
||||
"tool_creation": ToolCreationAgent is not None,
|
||||
"exploitation": ExploitationAgent is not None,
|
||||
"ai_tool_evolution": AIToolEvolutionAgent is not None,
|
||||
"external_tools": all([
|
||||
judge_response is not None,
|
||||
execute_code is not None,
|
||||
create_ai_tool is not None,
|
||||
test_tool_effectiveness is not None
|
||||
])
|
||||
}
|
||||
|
||||
return results
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("🧪 Testing Autonomous AI Agents Module")
|
||||
print("=" * 50)
|
||||
|
||||
# Test module information
|
||||
info = get_module_info()
|
||||
print(f"📦 Module: {info['name']} v{info['version']}")
|
||||
print(f"🏗️ Architecture: {info['architecture']}")
|
||||
print(f"✅ All agents available: {info['agents_available']}")
|
||||
print()
|
||||
|
||||
# Test imports
|
||||
print("🔍 Testing imports:")
|
||||
import_results = test_agent_imports()
|
||||
for component, success in import_results.items():
|
||||
status = "✅" if success else "❌"
|
||||
print(f" {status} {component}")
|
||||
|
||||
# Show available agents and tools
|
||||
print()
|
||||
print("🤖 Available Agents:")
|
||||
for agent in get_available_agents():
|
||||
print(f" ✅ {agent}")
|
||||
|
||||
print()
|
||||
print("🔧 Available Tools:")
|
||||
for tool in get_available_tools():
|
||||
print(f" ✅ {tool}")
|
||||
|
||||
# Show agent capabilities
|
||||
print()
|
||||
print("📋 Agent Capabilities:")
|
||||
capabilities = get_agent_capabilities()
|
||||
for agent, info in capabilities.items():
|
||||
print(f" 🎯 {agent}: {info['role']}")
|
||||
for capability in info['capabilities']:
|
||||
print(f" • {capability}")
|
||||
|
||||
# Test system creation
|
||||
if ALL_AVAILABLE:
|
||||
print()
|
||||
print("🚀 Testing system creation:")
|
||||
try:
|
||||
test_config = {
|
||||
'openai_api_key': 'test-key',
|
||||
'model_objects': {
|
||||
'attack_model_base': None,
|
||||
'judge_model_base': None
|
||||
}
|
||||
}
|
||||
|
||||
orchestrator = create_autonomous_system(test_config)
|
||||
print(f"✅ AutonomousOrchestrator created successfully")
|
||||
print(f" Session ID: {orchestrator.session_id}")
|
||||
print(f" Agents initialized: {len(orchestrator.agents)}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ System creation failed: {e}")
|
||||
|
||||
print()
|
||||
if all(import_results.values()):
|
||||
print("🎉 All agents module tests passed!")
|
||||
print("💡 Run 'python examples/quick_demo.py --help' for usage examples")
|
||||
else:
|
||||
print("⚠️ Some components are missing - check dependencies")
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user