inderjeet/NetworkSecurity
๐ก๏ธ Network Security System: Phishing URL Detection
๐ Table of Contents
- About The Project
- Architecture
- Features
- Tech Stack
- Dataset
- Project Structure
- Pipeline Workflow
- Screenshots
- Installation
- Usage
- Model Performance
- Experiment Tracking
- Future Enhancements
- Contributing
- License
- Contact
๐ Live Demo
- Live Application: inderjeet-networksecurity.hf.space
- Experiment Tracking: DagsHub Experiments
๐ฏ About The Project
In the digital age, cybersecurity threats such as phishing attacks are becoming increasingly sophisticated. This project implements a robust Network Security Machine Learning Pipeline designed to detect phishing URLs with high accuracy.
It leverages a modular MLOps architecture, ensuring scalability, maintainability, and reproducibility. The system automates the entire flow from data ingestion to model deployment, utilizing advanced techniques like drift detection and automated model evaluation.
๐๏ธ Architecture
The system follows a strict modular pipeline architecture, orchestrated by a central training pipeline.
โจ Features
- ๐ End-to-End Pipeline: Fully automated workflow from data ingestion to model deployment.
- ๐ก๏ธ Data Validation: Comprehensive schema checks and data drift detection using KS tests.
- ๐ Robust Preprocessing: Automated handling of missing values (KNN Imputer) and feature scaling (Robust Scaler).
- ๐ค Multi-Model Training: Experiments with RandomForest, DecisionTree, GradientBoosting, and AdaBoost using GridSearchCV.
- ๐ Experiment Tracking: Integrated with MLflow and DagsHub for tracking parameters, metrics, and models.
- โก Fast API: High-performance REST API built with FastAPI for real-time predictions.
- ๐ณ Containerized: Docker support for consistent deployment across environments.
- โ๏ธ Cloud Ready: Designed to be deployed on platforms like AWS or Hugging Face Spaces.
๐ ๏ธ Tech Stack
- Languages: Python 3.8+
- Frameworks: FastAPI, Uvicorn
- ML Libraries: Scikit-learn, Pandas, NumPy
- MLOps: MLflow, DagsHub
- Database: MongoDB
- Containerization: Docker
- Frontend: HTML, CSS (Custom Design System), JavaScript
๐ Dataset
The project utilizes a dataset containing various URL features to distinguish between legitimate and phishing URLs.
- Source: Phishing Dataset for Machine Learning (or similar Phishing URL dataset)
- Features: IP Address, URL Length, TinyURL, forwarding, etc.
- Target:
Result(LEGITIMATE / PHISHING)
๐ Project Structure
NetworkSecurity/
โโโ images/ # Project diagrams and screenshots
โโโ networksecurity/ # Main package
โ โโโ components/ # Pipeline components (Ingestion, Validation, Transformation, Training)
โ โโโ pipeline/ # Training and Prediction pipelines
โ โโโ entity/ # Artifact and Config entities
โ โโโ constants/ # Project constants
โ โโโ utils/ # Utility functions
โ โโโ exception/ # Custom exception handling
โโโ data_schema/ # Schema definitions
โโโ Dockerfile # Docker configuration
โโโ app.py # FastAPI application entry point
โโโ requirements.txt # Project dependencies
โโโ README.md # Project documentationโ๏ธ Pipeline Workflow
1. Data Ingestion ๐ฅ
Fetches data from MongoDB, handles fallback to local CSV, and performs train-test split.
2. Data Validation โ
Validates data against schema and checks for data drift.
3. Data Transformation ๐
Imputes missing values and scales features for optimal model performance.
4. Model Training ๐ค
Trains and tunes multiple models, selecting the best one based on F1-score/Accuracy.
๐ธ Screenshots
Prediction Results & Threat Assessment
Experiment Tracking (DagsHub/MLflow)
๐ป Installation
Prerequisites
- Python 3.8+
- MongoDB Account
- DagsHub Account (for experiment tracking)
Step-by-Step
- Clone the Repository
git clone https://github.com/Inder-26/NetworkSecurity.git
cd NetworkSecurity- Create Virtual Environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install Dependencies
pip install -r requirements.txt- Set Environment Variables Create a
.envfile with your credentials:
MONGO_DB_URL=your_mongodb_url_here
MLFLOW_TRACKING_URI=https://dagshub.com/your_username/project.mlflow
MLFLOW_TRACKING_USERNAME=your_username
MLFLOW_TRACKING_PASSWORD=your_password๐ Usage
Run the Web Application
python app.pyVisit http://localhost:8000 to access the UI.
Train a New Model
To trigger the training pipeline:
http://localhost:8000/trainOr use the "Train New Model" button in the UI.
๐ Model Performance
The system evaluates models using accuracy and F1 score.
- Best Model: [Automatically selected, typically RandomForest or GradientBoosting]
- Recall: Optimized to minimize false negatives (missing a phishing URL is dangerous).
Model Evaluation Metrics
Below are the performance visualizations for the best trained model:
Confusion Matrix
ROC Curve
Precision-Recall Curve
๐งช Experiment Tracking
All runs are logged to DagsHub. You can view parameters, metrics, and models in the MLflow UI.
๐ Future Enhancements
- [ ] Implement Deep Learning models (LSTM/CNN) for URL text analysis.
- [ ] Add real-time browser extension.
- [ ] Deploy serverless architecture.
- [ ] Add more comprehensive unit and integration tests.
๐ค Contributing
Contributions are welcome! Please fork the repository and create a pull request.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ License
Distributed under the MIT License. See LICENSE for more information.
๐ Contact
Inder - GitHub Profile
