AI-Driven Intrusion Detection System for Real-Time Network Threat Detection
- About
- Features
- Architecture
- Installation
- Usage
- Dataset
- Screenshots
- Project Structure
- Contributing
- Author
IDS with AI is an intelligent Intrusion Detection System that leverages Machine Learning to detect and alert malicious network activities in real-time.
Built with the renowned UNSW-NB15 dataset, this system employs a Random Forest classifier to achieve high-accuracy detection of network intrusions, distinguishing between Normal and Malicious traffic patterns.
| Aspect | Details |
|---|---|
| π§ AI Model | Random Forest Classifier |
| π Dataset | UNSW-NB15 (42 features) |
| β‘ Processing | Real-time packet analysis |
| π Dashboard | Auto-refreshing web UI |
| πΎ Storage | SQLite database logging |
β
AI-Powered Detection β Random Forest ML model with ~85-90% accuracy
β
Real-time Monitoring β Live network packet capture using Scapy
β
Web Dashboard β Beautiful, responsive UI with auto-refresh
β
Threat Alerts β Instant visual notifications for malicious activity
β
Persistent Logging β SQLite database for historical analysis
β
Binary Classification β Normal (0) vs Malicious (1) detection
β
Modular Design β Easy to extend with additional models
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β IDS with AI Architecture β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Network βββββββΆβ AI Sniffer βββββββΆβ SQLite β β
β β Traffic β β (Scapy+ML) β β Database β β
β ββββββββββββββββ ββββββββββββββββ ββββββββ¬ββββββββ β
β β β
β βΌ β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Web ββββββββ Flask ββββββββ Detection β β
β β Browser β β Server β β Logs β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python 3.8 or higher
- Git
- pip (Python package manager)
git clone https://github.com/shamanthwick/IDS-With-AI.git
cd IDS-With-AIpip install -r requirements.txtDownload the UNSW-NB15 training dataset:
- Search for
UNSW_NB15_training-set.csvonline - Place it in the project root folder
python train_model.pyThis generates:
ids_rf_model.pklβ Trained Random Forest modelids_scaler.pklβ Feature scaler
python sniffer.pyOpen a new terminal:
python app.pyOpen browser and navigate to:
http://127.0.0.1:5000
| Feature | Description |
|---|---|
| π Live Statistics | Real-time threat counts and totals |
| π Detection Logs | Recent network activity table |
| π Auto-Refresh | Updates every 3 seconds |
| π·οΈ Status Badges | Color-coded Normal/Malicious indicators |
| π¨ Dark Theme | Modern, eye-friendly UI |
| Property | Value |
|---|---|
| Name | UNSW-NB15 |
| Type | Network Intrusion Detection |
| Classes | Binary (Normal/Malicious) |
| Features | 42 network traffic features |
| Source | University of New South Wales |
- π₯οΈ Fuzzers
- π Analysis
- πͺ Backdoors
- π₯ DoS (Denial of Service)
- π― Exploits
- π Generic
- π‘ Reconnaissance
- π Shellcode
- π Worms
To enhance the robustness of this IDS, future iterations can incorporate more modern and diverse datasets:
A large-scale dataset created by the Canadian Institute for Cybersecurity (CIC) representing modern network traffic environments.
- Key Features:
- Capture period of 10 days with realistic background traffic.
- Extensive feature set (80+ network flow features).
- Large volume of data (terabytes of raw traffic).
- Types of Attacks: Brute Force, DoS, DDoS, Heartbleed, Botnet, Infiltration, and Web Attacks.
- Why it's Modern: It captures much newer attack vectors and more complex network topologies compared to UNSW-NB15.
A heterogeneous dataset collecting data from Telemetry, Operating Systems, and Network (ToN) sensors in an IoT/IIoT environment.
- Key Features:
- Multi-layered data including Network traffic, IoT telemetry, and OS logs.
- Realistic Industrial IoT (IIoT) environment simulation.
- High-dimensional and diverse feature sets.
- Types of Attacks: DoS, DDoS, Ransomware, Backdoor, Injection, XSS, Scanning, and MitM.
- Why it's Modern: Specifically designed for the IoT era, addressing vulnerabilities in smart devices that traditional datasets like UNSW-NB15 overlook.
A dataset created in a realistic network environment specifically to capture various botnet attack scenarios.
- Key Features:
- High-density Botnet-specific traffic patterns.
- Includes 5% sub-sampled versions for efficient research and training.
- Detailed per-packet and per-flow statistical metrics.
- Types of Attacks: DDoS, DoS, OS Fingerprinting, Service Discovery, Keylogging, and Data Exfiltration.
- Why it's Modern: Provides a much more specialized and deep focus on botnet behaviors, which have evolved significantly since the release of earlier datasets.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Model Evaluation Results β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Metric β Score β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ€
β Accuracy β ~85-90% β
β Precision β ~85% β
β Recall β ~85% β
β F1-Score β ~85% β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
*Results may vary based on training data and network conditions
IDS-With-AI/
β
βββ π train_model.py # AI model training script
βββ π sniffer.py # Network packet sniffer
βββ π app.py # Flask web server
βββ π requirements.txt # Python dependencies
βββ π README.md # Project documentation
β
βββ π templates/
β βββ π index.html # Dashboard UI
β
βββ π§ .gitignore # Git ignore rules
β
βββ π¦ Generated Files (not in repo)
βββ ids_rf_model.pkl # Trained model
βββ ids_scaler.pkl # Feature scaler
βββ ids_logs.db # Detection logs
Contributions are welcome! Here's how you can help:
- π΄ Fork the repository
- πΏ Create a feature branch (
git checkout -b feature/AmazingFeature) - πΎ Commit your changes (
git commit -m 'Add AmazingFeature') - π Push to the branch (
git push origin feature/AmazingFeature) - π Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
| GitHub | @shamanthwick |
| shamantharsingh@gmail.com |
- π UNSW-NB15 Dataset creators
- π§ Scapy developers
- π€ Scikit-learn team
- π Flask community
If you find this project useful, please β star this repository!