How yassinom/zeroshield works
Project Type and Purpose
• ZeroShield is a specialized security tool (not a traditional web full-stack) built in Python. Its purpose is real-time zero-day attack detection on Linux systems using ML/DL. It includes network traffic monitoring, storage, model-based prediction, and a minimal GUI for reporting.
File Structure Analysis
• Top-level scripts:
• main.py – Orchestrator that initializes components
• sniffer.py – Captures live network traffic
• prediction.py & zerodayprediction.py – Load models and classify traffic
• gui.py – Presents alerts/results to the user
• models/
• autoencoder_model.keras – Pretrained deep autoencoder for anomaly detection
• tabnet_UGransome.zip – Pretrained TabNet model for threat classification
• requirements.txt – Python deps (Scapy, TensorFlow/Keras, PyMongo, PyQT or other GUI libs)
• Docker integration for MongoDB (README instructions)
• README provides architecture screenshot, ML focus, and deployment steps.
Key Components
a. Network Traffic Source
– Linux network interface (e.g., eth0)
– sniffer.py (Scapy or libpcap wrapper)
b. Message Bus / Data Buffer (optional)
– In-memory queue or direct hand-off from sniffer.py to prediction modules
c. ML Inference Pipeline
– prediction.py (loads autoencoder_model.keras)
– zerodayprediction.py (loads TabNet model)
– Preprocessing layer (feature extraction from raw packets)
d. Data Storage
– MongoDB container (stores raw traffic, features, prediction results)
– Access via PyMongo
e. User Interface / Reporting
– gui.py displays alerts, statistics, graphs
f. Orchestration
– main.py ties together the sniffer, prediction pipeline, DB, and GUI
Relationships & Data Flow
1) main.py starts MongoDB connection & GUI
2) sniffer.py captures packets → feature extractor
3) Extracted features → prediction.py & zerodayprediction.py
4) Predictions & metadata → MongoDB
5) gui.py queries MongoDB & displays real-time alerts
6) (Optional) CLI or logging subsystem for audit
Architectural Patterns & Design Principles
• Pipe-and-Filter: sniffer → features → models → DB/GUI
• Single Responsibility: each script focuses on one concern
• Loose Coupling via MongoDB as a persistence bus
• Modular ML Components: interchangeable models in models/
Technologies & Frameworks
• Python 3.x
• Scapy or libpcap (network capture)
• TensorFlow/Keras (autoencoder_model.keras)
• PyTorch/TabNet (tabnet_UGransome.zip)
• MongoDB (Docker container)
• PyMongo (DB client)
• PyQT or Tkinter (gui.py)
• Docker for database isolation
Detailed Breakdown
• Layer 1 (Infrastructure): Linux Host, Dockerized MongoDB
• Layer 2 (Capture & Ingestion): sniffer.py → feature extraction
• Layer 3 (ML Inference): autoencoder + TabNet modules
• Layer 4 (Data Persistence): MongoDB collections for raw packets, features, predictions
• Layer 5 (Presentation): gui.py, CLI logs, optional REST endpoint