Skip to content

Byakuya3456/Mlfirewall

Repository files navigation

AI Sentinel: ML-Based PC Firewall

AI Sentinel is a real-time, machine-learning-powered firewall designed for PCs. It uses an Isolation Forest model to monitor network traffic and detect anomalies, providing an interactive web dashboard for visualization and control.

🌟 Key Features

  • ML Detection Engine: High-performance classification using the trained firewall_anomaly_detection_model.pkl.
  • Premium Dashboard: A sleek, dark-themed UI built with FastAPI, Tailwind CSS, and Chart.js.
  • Real-Time Analytics:
    • Anomaly Risk Charts: Dynamic line charts plotting risk scores in real-time.
    • Traffic Stats: Detailed counters for total flows and detected anomalies.
    • Activity Logs: An auto-updating table of detailed network flow events.
  • Interactive Controls:
    • Sensitivity Threshold: Adjust the model's sensitivity on-the-fly.
    • Simulation Mode: Safely test the firewall in a sandbox environment using the provided dataset.

🛠️ Project Structure

  • firewall_engine.py: The core classification and packet processing engine.
  • dashboard_app.py: FastAPI server that serves the dashboard and manages the core engine.
  • static/index.html: The premium dashboard frontend.
  • firewall_anomaly_detection_model.pkl: The trained Isolation Forest model and scaler.
  • optional/: Contains non-essential files, including log2.csv, ESP32 deployment code, and research notebooks.

🚀 Quick Start

1. Prerequisites

Ensure you have Python 3.8+ installed. It is recommended to use the existing virtual environment.

2. Install Dependencies

Run the following in your terminal:

.\venv\Scripts\python.exe -m pip install fastapi uvicorn pandas scikit-learn numpy plyer pydivert

3. Run the Firewall (Dashboard + Engine)

Option A: Manual Start (Visible)

python dashboard_app.py

Option B: Background Start (Hidden) Double-click start_firewall.vbs to launch the firewall invisibly.

4. Enable Live Mode (Important!)

To monitor real-time network traffic instead of simulation:

  1. Open the dashboard at http://localhost:8000.
  2. Toggle "Simulation Mode" to OFF.
  3. Click "Start Engine".
  4. Note: Real-time traffic monitoring requires running the dashboard/terminal as Administrator because it uses WinDivert to intercept packets.

⚙️ Auto-Start with Windows

To have the firewall turn on automatically with your PC:

  1. Press Win + R, type shell:startup, and press Enter.
  2. Create a Shortcut to start_firewall.vbs in that folder.
  3. The AI Sentinel will now launch in the background every time you log in!

🔔 Notifications

The firewall will now send Windows Toast notifications whenever a threat is detected by the ML model.


Built for the PC Firewall AI project.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors