Real-time AI-powered network intrusion detection and prevention system with auto-blocking, live dashboard, email alerts, and GeoIP tracking. CyberSentinel | AI IDS IPS | Intrusion Detection System Python | Network Security ML | Pakistani Cybersecurity Project | Real-time Attack Detection | MalikTaha8331 GitHub
| Feature | Description |
|---|---|
| 🤖 AI Detection | Random Forest ML model with 99.92% accuracy |
| 🚫 Auto-Blocking | Severe threats (>75% confidence) blocked automatically |
| 📊 Live Dashboard | Real-time charts, alerts, and threat statistics |
| 📡 Live Traffic Monitor | Packet-level monitoring with protocol filters |
| 🔐 OWASP Security | bcrypt, rate limiting, brute force protection |
| 📧 Email Alerts | Instant email on severe attack detection |
| 🌍 GeoIP Tracking | Country and city of attack source |
| 🧙 Setup Wizard | First-time personalized account creation |
| 🔑 OTP Password Reset | Forgot password via 6-digit email OTP |
| 📋 Historical Logs | Persistent JSON logs with search and filters |
| ⚔️ Attack Types | Identifies DoS, Port Scan, Brute Force, SYN Flood etc. |
| 📄 PDF Reports | One-click security report generation |
| ⚡ Auto Installer | One-command setup on Windows and Linux |
Network Traffic
↓
Scapy Live Sniffer (sniffer.py)
↓
Feature Extraction (41 NSL-KDD features)
↓
Random Forest ML Model (99.92% accuracy)
↓
Threat Classification (Normal / Suspicious / Moderate / Severe)
↓
Flask API + Dashboard (app.py)
↓
Auto-Block or Alert Admin
| Category | Confidence | Action |
|---|---|---|
| ✅ NORMAL | Prediction = 0 | No action |
| ⚪ SUSPICIOUS | < 55% | Block button shown |
| 🟡 MODERATE THREAT | 55% - 75% | Block button shown |
| 🔴 SEVERE THREAT | > 75% | Auto-blocked immediately |
| Model | Accuracy | F1-Score | AUC-ROC |
|---|---|---|---|
| Random Forest ⭐ | 99.92% | 99.92% | 100.00% |
| Deep Neural Network | 99.51% | 99.51% | 99.98% |
| SVM | 96.09% | 95.99% | 99.16% |
Dataset: NSL-KDD (125,973 training + 22,544 test records)
# Step 1 — Clone repository
https://github.com/MalikTaha8331/CyberSentinal.git
cd CyberSentinal
# Step 2 — Run installer
install.bat
# Step 1 — Clone repository
https://github.com/MalikTaha8331/CyberSentinal.git
cd CyberSentinal
# Step 2 — Make installer executable
chmod +x install.sh
# Step 3 — Run installer
./install.sh
# Clone repo
git clone https://github.com/MalikTaha8331/ai-ids-fyp.git
cd ai-ids-fyp
# Install dependencies
pip install -r requirements.txt
# Start CyberSentinel
python start_ids.py
# Start everything (Flask + Sniffer auto-starts from dashboard)
cd src
python app.py
Open browser at:
http://127.0.0.1:5000
First time? The Setup Wizard will appear — create your admin account!
⚠️ Must run as Administrator on Windows for packet capture
# Option 1 — From dashboard (recommended)
# Click the "Sniffer: OFF" button in the nav bar
# Option 2 — Manual terminal (run as Administrator)
cd src
python sniffer.py auto
ai-ids-fyp/
├── src/
│ ├── app.py # Flask web server + API routes
│ ├── predict.py # ML model loader + threat classifier
│ ├── sniffer.py # Live Scapy packet capture
│ ├── simulate.py # NSL-KDD pipeline simulator
│ ├── features.py # Feature definitions + encodings
│ ├── auth.py # OWASP authentication + brute force
│ ├── user_store.py # User credentials management
│ ├── mailer.py # Email OTP + alert system
│ ├── pdf_report.py # PDF report generator
│ └── requirements.txt # Python dependencies
├── templates/
│ ├── index.html # Main dashboard
│ ├── live.html # Live traffic monitor
│ ├── history.html # Historical logs
│ ├── login.html # Login page
│ ├── setup.html # First-time setup wizard
│ ├── forgot.html # Forgot password
│ ├── otp.html # OTP verification
│ └── reset.html # Password reset
├── static/
│ └── style.css # Purple Gold Cyberpunk theme
├── models/ # Trained ML models (Git LFS)
│ ├── best_model.pkl # Deployed Random Forest
│ ├── random_forest.pkl # Random Forest
│ ├── svm_model.pkl # SVM model
│ └── dnn_model.keras # Deep Neural Network
├── data/
│ ├── raw/ # Original NSL-KDD files (gitignored)
│ └── processed/ # Cleaned datasets (Git LFS)
├── notebooks/
│ ├── 01_eda.ipynb # Exploratory Data Analysis
│ ├── 02_preprocessing.ipynb
│ ├── 03_random_forest.ipynb
│ ├── 04_svm.ipynb
│ ├── 05_dnn.ipynb
│ └── 06_model_comparison.ipynb
├── logs/ # Security logs (gitignored)
├── docs/ # Documentation + screenshots
├── setup.py # Auto installer
├── start_ids.py # Main launcher
├── install.bat # Windows installer
├── install.sh # Linux installer
└── README.md
externally-managed-environment (Linux/Kali)error: externally-managed-environment
Fix:
pip install -r requirements.txt --break-system-packages
Sniffer error: Interface 'None' not foundFix — Auto detect interface:
python sniffer.py auto
Fix — Specify interface manually:
# Find your interface name first
python -c "from scapy.all import IFACES; [print(f'{i.name} | {i.ip}') for i in IFACES.values()]"
# Then run with your interface
python sniffer.py WiFi
# or
python sniffer.py Ethernet
Operation not permitted / Raw socket error[open_sockraw] socket(): Operation not permitted
Fix — Run as Administrator:
sudo# Linux
sudo python sniffer.py auto
# Windows — open Admin CMD then
python sniffer.py auto
UnicodeEncodeError with emojisUnicodeEncodeError: 'charmap' codec can't encode character
Fix — Set UTF-8 encoding:
# Windows
set PYTHONIOENCODING=utf-8
python app.py
flask_limiter UserWarningUserWarning: Using the in-memory storage for tracking rate limits
This is just a warning, not an error. App works fine. To suppress:
# In app.py, add storage_uri to limiter
limiter = Limiter(
app=app,
key_func=get_remote_address,
storage_uri="memory://",
default_limits=["5000 per day", "1000 per hour"]
)
TemplateNotFound: login.htmljinja2.exceptions.TemplateNotFound: login.html
Fix — Make sure you cloned the full repo:
git clone https://github.com/MalikTaha8331/ai-ids-fyp.git
Not just downloaded as ZIP. The templates/ folder must exist.
Model file not foundFileNotFoundError: models/best_model.pkl not found
Fix — Pull Git LFS files:
git lfs install
git lfs pull
If Git LFS is not installed:
# Windows
winget install GitHub.GitLFS
# Linux
sudo apt install git-lfs
git lfs install
git lfs pull
bcrypt installation fails on Windowserror: Microsoft Visual C++ 14.0 is required
Fix:
pip install bcrypt --only-binary=bcrypt
scapy not capturing packets on WindowsFix — Install Npcap:
CyberSentinel uses Gmail SMTP for OTP and alert emails.
To configure:
src/mailer.py:SENDER_EMAIL = 'your-email@gmail.com'
SENDER_PASSWORD = 'your-16-char-app-password'
⚠️ Never commit real credentials to GitHub!
| Page | URL | Description |
|---|---|---|
| Main Dashboard | / |
Stats, charts, alerts, blocked IPs |
| Live Traffic | /live |
Real-time packet feed with filters |
| History | /history |
Paginated security event logs |
| Login | /login |
OWASP-compliant authentication |
| Setup | /setup |
First-time account creation |
| Endpoint | Method | Description |
|---|---|---|
/predict |
POST | Classify network traffic |
/alerts |
GET | Get recent alerts |
/stats |
GET | Get traffic statistics |
/block |
POST | Manually block an IP |
/unblock |
POST | Unblock an IP |
/blocked |
GET | List blocked IPs |
/traffic |
GET/POST | Live traffic data |
/sniffer/start |
POST | Start packet sniffer |
/sniffer/stop |
POST | Stop packet sniffer |
/report/pdf |
GET | Download PDF report |
/logs |
GET | Get historical logs |
flask
flask-cors
flask-limiter
scikit-learn
tensorflow
scapy
pandas
numpy
bcrypt
joblib
reportlab
requests
scipy
imbalanced-learn
| Field | Details |
|---|---|
| Project Title | AI-Powered Intrusion Detection & Prevention System |
| Dataset | NSL-KDD (125,973 training + 22,544 test records) |
| Best Model | Random Forest (99.92% accuracy) |
| Other Models | DNN (99.51%), SVM (96.09%) |
| University | Sir Syed CASE Institute of Technology, Islamabad |
| Program | BS Cybersecurity |
| Year | 2025-2026 |
Malik Taha
MIT License — free to use, modify and distribute.