Skip to content

Repository files navigation

🤖 AI Security Battle System

Red Team vs Blue Team: Adversarial ML Combat Simulation

A comprehensive adversarial machine learning security simulation where Red Team attackers battle against Blue Team defenders in a 30-minute AI/ML security warfare scenario.


🎯 Project Overview

This system simulates real-world AI/ML security scenarios where:

  • 🔴 Red Team launches sophisticated attacks (adversarial inputs, model extraction, evasion)
  • 🔵 Blue Team deploys ML-powered defenses (anomaly detection, rate limiting, input validation)

The battle runs for 30 minutes with 10 rounds, and the final results determine whether AI/ML security systems are robust enough for modern applications.


📁 Project Structure

ai-security-battle/
├── database/                   # Database layer
│   ├── schema.sql              # Database schema
│   ├── db_config.py            # Database manager & repositories
│   ├── models.py               # Data models
│   └── seed_data.py            # Initialize with sample data
│
├── blue_team/                  # Blue Team (Defenders)
│   ├── ml_models/              # ML models for defense
│   ├── defenses/               # Defense mechanisms
│   ├── monitoring/             # Monitoring systems
│   ├── api/                    # API endpoints
│   └── blue_agent.py           # Blue Team orchestrator
│
├── red_team/                   # Red Team (Attackers)
│   ├── attacks/                # Attack implementations
│   ├── reconnaissance/         # Probing and scanning
│   ├── adaptation/             # Strategy adaptation
│   └── red_agent.py            # Red Team orchestrator
│
├── battle_engine/              # Battle coordination
│   ├── orchestrator.py         # Main battle controller
│   ├── round_manager.py        # Round timing
│   ├── scoring_system.py       # Score tracking
│   └── logger.py               # Event logging
│
├── shared/                     # Shared utilities
│   ├── config.py               # Configuration
│   ├── constants.py            # Constants & enums
│   └── utils.py                # Utility functions
│
├── results/                    # Battle results & logs
├── tests/                      # Unit tests
├── docker/                     # Docker configuration
├── requirements.txt            # Python dependencies
├── setup.py                    # Package setup
├── run_battle.py               # Main entry point
└── README.md                   # This file

🚀 Quick Start

1. Installation

cd ai-security-battle

# Create virtual environment (recommended)
python -m venv venv
venv\Scripts\activate  # On Windows

# Install dependencies
pip install -r requirements.txt

2. Initialize Database

python database/seed_data.py

3. Run the Battle!

# Standard battle (30 minutes, 10 rounds)
python run_battle.py

# Quick battle (10 minutes, 5 rounds)
python run_battle.py --quick

# Custom configuration
python run_battle.py --rounds 8 --duration 20

# Initialize database and run
python run_battle.py --init

🎮 How It Works

Battle Flow

  1. Initialization - Both teams train their models
  2. Rounds 1-10 - Red attacks, Blue defends
  3. Adaptation - Both teams adjust strategies
  4. Conclusion - Winner determined, report generated

🔴 Red Team Arsenal

  • Adversarial Inputs - Craft inputs to fool ML classifier
  • Model Extraction - Steal model via queries
  • Evasion Attacks - Adapt to detection patterns
  • Inference Attacks - Extract training data info

🔵 Blue Team Defenses

  • Rate Limiting - Prevent API abuse
  • Input Validation - Schema and range checking
  • Anomaly Detection - Isolation Forest algorithm
  • ML Authentication - Random Forest classifier

📊 Scoring

Red Team

  • Successful breach: +10 points
  • Evade detection: +5 points
  • Model extraction: +15 points

Blue Team

  • Attack detected: +8 points
  • Attack blocked: +12 points
  • Zero breaches round: +15 points

⚙️ Configuration

Edit shared/config.py to customize battle settings, defense parameters, and attack configurations.


🧪 Testing

pytest tests/ -v

📜 License

MIT License - Educational and research purposes


Built for AI/ML Security Research & Education 🚀

About

A Red Team vs. Blue Team Adversarial AI Simulation.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages