Skip to content

arhadnane/SwarmID-Intrusion-Detection-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SwarmID - Anomaly-Based Intrusion Detection System Using Swarm Intelligence

.NET C# Blazor LiteDB SignalR

A comprehensive intrusion detection system that leverages swarm intelligence algorithms (Ant Colony Optimization and Bee Algorithm) to detect network anomalies in real-time. The system provides advanced network traffic analysis, anomaly classification, and an intuitive web-based dashboard for security monitoring.

πŸš€ Features

🧠 Swarm Intelligence Algorithms

  • Ant Colony Optimization (ACO): Mimics ant foraging behavior for pattern recognition
  • Bee Algorithm: Uses bee colony optimization for efficient anomaly detection
  • Hybrid Detection: Combines both algorithms for enhanced accuracy

πŸ“Š Real-time Monitoring

  • Live network traffic analysis and visualization
  • Instant anomaly alerts via SignalR
  • Interactive dashboard with filtering and search capabilities
  • Real-time performance metrics and statistics

πŸ” Multi-format Traffic Analysis

  • Zeek Logs: Parse and analyze Zeek network security monitor logs
  • Snort Alerts: Integration with Snort intrusion detection alerts
  • PCAP Files: Direct packet capture file analysis
  • Real-time Traffic: Live network traffic simulation and monitoring

🎯 Anomaly Classification

  • Port Scan Detection: Identify reconnaissance activities
  • DDoS Attack Detection: Detect distributed denial-of-service patterns
  • Command & Control (C&C): Identify botnet communication
  • Data Exfiltration: Detect unauthorized data transfers

πŸ“ˆ Performance Metrics

  • Detection Accuracy: 89-92% across both algorithms
  • Processing Speed: 120-150ms per traffic record
  • Memory Efficiency: 38-45MB resource usage
  • Low False Positives: 3-5% false positive rate

πŸ—οΈ Architecture

The system follows a clean architecture pattern with clear separation of concerns:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    SwarmID.Dashboard                        β”‚
β”‚                   (Blazor Server UI)                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                     SwarmID.Api                             β”‚
β”‚                 (ASP.NET Core Web API)                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                   SwarmID.Core                              β”‚
β”‚              (Business Logic & Algorithms)                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                SwarmID.TrafficAnalysis                      β”‚
β”‚               (Traffic Parsing & Analysis)                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                      LiteDB                                 β”‚
β”‚                 (Lightweight Database)                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

SwarmID/
β”œβ”€β”€ SwarmID.Core/                    # Core business logic and algorithms
β”‚   β”œβ”€β”€ Algorithms/                  # Swarm intelligence implementations
β”‚   β”‚   β”œβ”€β”€ AntColonyOptimizationDetector.cs
β”‚   β”‚   └── BeeAlgorithmDetector.cs
β”‚   β”œβ”€β”€ Interfaces/                  # Core interfaces
β”‚   β”œβ”€β”€ Models.cs                    # Data models and entities
β”‚   └── Repositories/                # Data access layer
β”œβ”€β”€ SwarmID.TrafficAnalysis/         # Network traffic parsing
β”‚   └── ZeekLogParser.cs            # Zeek log format parser
β”œβ”€β”€ SwarmID.Api/                     # REST API backend
β”‚   └── Controllers/                 # API controllers
β”‚       β”œβ”€β”€ AnomaliesController.cs
β”‚       └── TrafficController.cs
β”œβ”€β”€ SwarmID.Dashboard/               # Blazor Server frontend
β”‚   β”œβ”€β”€ Pages/                       # Razor pages
β”‚   β”‚   β”œβ”€β”€ Index.razor             # Main dashboard
β”‚   β”‚   β”œβ”€β”€ Anomalies.razor         # Anomaly management
β”‚   β”‚   └── Traffic.razor           # Traffic monitoring
β”‚   └── Data/                        # Database files
β”œβ”€β”€ SwarmID.Tests/                   # Unit and integration tests
└── diagrams/                        # System architecture diagrams

πŸš€ Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/arhadnane/SwarmID-Intrusion-Detection-System
    cd swarmid
  2. Restore dependencies

    dotnet restore
  3. Build the solution

    dotnet build
  4. Run tests

    dotnet test

Running the Application

Option 1: Using Visual Studio

  1. Open SwarmID.sln in Visual Studio 2022
  2. Set multiple startup projects:
    • SwarmID.Api
    • SwarmID.Dashboard
  3. Press F5 to start debugging

Option 2: Using Command Line

Start the API (Terminal 1):

cd SwarmID.Api
dotnet run

Start the Dashboard (Terminal 2):

cd SwarmID.Dashboard
dotnet run

Access the Application

πŸ“Έ Screenshots

Main Dashboard

Main Dashboard Real-time system overview with anomaly detection statistics and performance metrics

Traffic Analysis Page

Traffic Analysis Network traffic monitoring with file upload and real-time analysis capabilities

Anomaly Management

Anomaly Management Comprehensive anomaly review and management interface

API Documentation (Swagger)

API Documentation Interactive API documentation with endpoint testing capabilities

Real-time Monitoring

Real-time Monitoring Live network traffic visualization and instant anomaly alerts

PCAP File Upload

PCAP Upload File upload interface for PCAP, Zeek logs, and Snort alerts analysis

πŸ“Š Usage

1. Dashboard Overview

  • Navigate to the main dashboard to see real-time system status
  • Monitor active anomalies and system performance metrics
  • View algorithm performance comparisons

2. Traffic Monitoring

  • Go to the Traffic page for live network traffic analysis
  • Upload PCAP files or Zeek logs for analysis
  • Monitor real-time traffic patterns and statistics

3. Anomaly Management

  • Access the Anomalies page to review detected threats
  • Update anomaly status and add analyst feedback
  • Filter and search through historical anomalies

4. API Integration

  • Use the REST API for programmatic access
  • Integrate with existing security tools and SIEM systems
  • Access Swagger documentation for API details

πŸ§ͺ Testing

The project includes comprehensive test coverage:

# Run all tests
dotnet test

# Run tests with coverage
dotnet test --collect:"XPlat Code Coverage"

# Run specific test project
dotnet test SwarmID.Tests/

Test Coverage:

  • βœ… Unit tests for swarm algorithms
  • βœ… Integration tests for API controllers
  • βœ… Repository layer tests
  • βœ… Traffic analysis tests
  • βœ… End-to-end workflow tests

πŸ”§ Configuration

Algorithm Parameters

Configure swarm intelligence algorithms in appsettings.json:

{
  "SwarmConfiguration": {
    "AnomalyThreshold": 75.0,
    "NumberOfAnts": 50,
    "NumberOfEmployedBees": 20,
    "MaxIterations": 100,
    "PheromoneEvaporationRate": 0.1
  }
}

Database Configuration

LiteDB configuration for data storage:

{
  "ConnectionStrings": {
    "DefaultConnection": "Data/swarmid.db",
    "LogConnection": "Data/swarmid-log.db"
  }
}

πŸ“ˆ Performance Optimization

Algorithm Tuning

  • Adjust ant colony parameters for different network environments
  • Optimize bee algorithm parameters based on traffic patterns
  • Fine-tune detection thresholds for specific use cases

Scalability

  • Horizontal scaling support through load balancing
  • Asynchronous processing for high-volume traffic
  • Configurable worker threads for parallel analysis

πŸ”’ Security Considerations

  • Input validation for all network traffic data
  • Secure API endpoints with proper authentication
  • Sanitized database queries to prevent injection attacks
  • Encrypted storage for sensitive configuration data

πŸ“š Documentation

πŸ“Έ Adding Screenshots

To add screenshots to this documentation:

  1. Prerequisites: Ensure both services are running

    # Terminal 1: Start API
    cd SwarmID.Api
    dotnet run
    
    # Terminal 2: Start Dashboard  
    cd SwarmID.Dashboard
    dotnet run
  2. Take Screenshots: Visit the URLs and capture screenshots

  3. Save Images: Place PNG files in docs/images/ with exact names:

    • dashboard-main.png
    • traffic-analysis.png
    • anomaly-management.png
    • api-swagger.png
    • realtime-monitoring.png
    • pcap-upload.png
  4. Automatic Display: Images will appear automatically in the README

See docs/SCREENSHOT_GUIDE.md for detailed instructions.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow SOLID principles and clean architecture patterns
  • Write comprehensive unit tests for new features
  • Use async/await patterns for I/O operations
  • Implement proper error handling and logging
  • Follow C# coding conventions and best practices

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Authors

πŸ™ Acknowledgments

  • Inspired by swarm intelligence research in cybersecurity
  • Built with modern .NET technologies and best practices
  • Special thanks to the open-source community for tools and libraries

SwarmID - Protecting networks through the power of swarm intelligence 🐝🐜