The AI Pattern Detector is a multi-component system designed to detect GTG-1002 style autonomous AI-driven cyberattacks. This document describes the system architecture, component relationships, and data flow.
graph TB
subgraph "User Interface Layer"
DASH[Dashboard<br/>Streamlit App]
end
subgraph "Detection Layer"
BASE[AIPatternDetector<br/>Rule-Based Detection]
ENH[EnhancedAIPatternDetector<br/>AI-Enhanced Detection]
end
subgraph "AI Analysis Layer"
OLLAMA[OllamaClient<br/>LLM Integration]
ANALYZER[AIThreatAnalyzer<br/>Threat Analysis]
ASSISTANT[SecurityAssistant<br/>Q&A Engine]
end
subgraph "Simulation Layer"
SIM[AttackSimulator<br/>Traffic Generation]
end
subgraph "Data Layer"
MODELS[Data Models<br/>Request, Detection, Alert]
CONFIG[Configuration<br/>Settings Management]
end
DASH --> BASE
DASH --> ENH
DASH --> SIM
ENH --> BASE
ENH --> ANALYZER
ANALYZER --> OLLAMA
ASSISTANT --> OLLAMA
BASE --> MODELS
ENH --> MODELS
SIM --> MODELS
BASE --> CONFIG
ENH --> CONFIG
Dashboard (Streamlit App)
- Location:
dashboard/app.py - Purpose: Interactive web interface for real-time threat visualization
- Components:
- Metrics panel
- Threat visualizations (timeline, gauge, distribution)
- Alert feed
- Configuration controls
- AI insights panel
AIPatternDetector
- Location:
ai_tools/detection/ai_pattern_detector.py - Purpose: Core rule-based detection engine
- Capabilities:
- Superhuman speed detection
- Systematic enumeration detection
- Behavioral anomaly detection
- Threat scoring (0-100)
EnhancedAIPatternDetector
- Location:
ai_tools/detection/enhanced_detector.py - Purpose: AI-enhanced detection combining rule-based and AI analysis
- Capabilities:
- Inherits all AIPatternDetector capabilities
- AI-powered threat analysis
- Natural language explanations
- False positive reduction
- Dynamic threat scoring
OllamaClient
- Location:
ai_tools/ai_analysis/ollama_client.py - Purpose: Wrapper for local Ollama LLM integration
- Capabilities:
- Connection management
- Request pattern analysis
- Intent classification
- Threat explanation generation
- Response recommendation
AIThreatAnalyzer
- Location:
ai_tools/ai_analysis/threat_analyzer.py - Purpose: Enhanced threat analysis using Ollama
- Capabilities:
- Context-aware pattern recognition
- Attack scenario generation
- Incident report generation
- Threat explanation
SecurityAssistant
- Location:
ai_tools/ai_analysis/security_assistant.py - Purpose: AI-powered security advisor
- Capabilities:
- Q&A interface
- Security recommendations
- Detection logic explanation
- Incident summary generation
AttackSimulator
- Location:
ai_tools/simulation/attack_simulator.py - Purpose: Generate realistic network traffic for testing
- Capabilities:
- Normal traffic generation
- Attack traffic generation
- Configurable attack intensity
- Realistic request patterns
Data Models
- Location:
ai_tools/utils/models.py - Types:
Request: HTTP request representationDetection: Threat detection resultAlert: Security alertThreatLevel: Enum (normal, suspicious, malicious)PatternType: Enum (normal, superhuman_speed, systematic_enumeration, behavioral_anomaly)
Configuration
- Location:
ai_tools/config.py - Purpose: Centralized configuration management
- Settings:
- Detection thresholds
- Request history limits
- Dashboard refresh rates
- Ollama configuration
- AI feature flags
sequenceDiagram
participant SIM as AttackSimulator
participant DET as Detector
participant AI as AI Analyzer
participant DASH as Dashboard
SIM->>DET: Generate Request
DET->>DET: Rule-Based Analysis
alt AI Enabled
DET->>AI: Analyze Detection
AI->>AI: LLM Analysis
AI->>DET: Enhanced Analysis
DET->>DET: Adjust Threat Score
end
DET->>DASH: Detection Result
DASH->>DASH: Update Visualizations
DASH->>DASH: Generate Alerts
flowchart TD
START[Detection Created] --> CHECK{AI Enabled?}
CHECK -->|No| RULE[Rule-Based Only]
CHECK -->|Yes| AVAIL{Ollama Available?}
AVAIL -->|No| FALLBACK[Fallback to Rule-Based]
AVAIL -->|Yes| ANALYZE[AI Analysis]
ANALYZE --> INTENT[Intent Classification]
ANALYZE --> EXPLAIN[Generate Explanation]
ANALYZE --> REC[Generate Recommendations]
INTENT --> SCORE[Adjust Threat Score]
EXPLAIN --> RESULT[Enhanced Detection]
REC --> RESULT
SCORE --> RESULT
RULE --> RESULT
FALLBACK --> RESULT
RESULT --> END[Return Detection]
- Interface: Direct Python imports
- Data:
Detectionobjects - Frequency: Real-time (every 2 seconds)
- Interface: Method calls (
analyze_detection()) - Data:
Detectionobjects → AI analysis dictionaries - Frequency: On-demand (when threat detected)
- Interface: HTTP API calls
- Data: Prompts → LLM responses
- Frequency: On-demand (when AI analysis requested)
- Interface: Generator pattern (
generate_requests()) - Data:
Requestobjects - Frequency: Continuous (configurable rate)
graph LR
subgraph "Local Development"
DEV[Developer Machine]
OLLAMA_LOCAL[Ollama Local]
end
subgraph "Production Deployment"
SERVER[Application Server]
OLLAMA_PROD[Ollama Server]
DB[(Detection Storage)]
end
DEV --> SERVER
OLLAMA_LOCAL --> OLLAMA_PROD
SERVER --> DB
SERVER --> OLLAMA_PROD
- Local Processing: All AI analysis happens locally (no data leaves environment)
- Graceful Degradation: System works without Ollama
- Error Handling: Comprehensive error handling prevents crashes
- Input Validation: All inputs validated before processing
- No Sensitive Data: No sensitive data sent to LLM
- Request Processing: < 100ms per request
- AI Analysis: < 2 seconds per detection (when enabled)
- Dashboard Refresh: 2 seconds (configurable)
- Memory Usage: Scales with detection history (max 1000 detections)
- Horizontal Scaling: Multiple detector instances possible
- Vertical Scaling: Limited by single-threaded Python
- AI Bottleneck: Ollama inference time
- Storage: In-memory (can be extended to persistent storage)
- Persistent Storage: Database integration for detection history
- Distributed Processing: Multi-instance deployment
- Advanced Caching: LLM response caching
- Real-time Streaming: WebSocket support for live updates
- Multi-model Support: Support for multiple LLM providers
- Anthropic. (2025, November 17). Disrupting the first reported AI-orchestrated cyber espionage campaign [Threat Intelligence Report]. Anthropic. https://www.anthropic.com/research/disrupting-ai-cyber-espionage
Last Updated: 2025-01-XX Version: 1.0