A comprehensive phishing website detection system using Machine Learning. This project combines advanced web scraping, feature engineering, and gradient boosting models to identify malicious URLs with high accuracy.
- Advanced URL Analysis: Extracts lexical, domain, and content-based features from URLs
- WHOIS Integration: Checks domain registration age and registrar information
- Machine Learning Detection:
- Random Forest - Fast baseline model
- XGBoost - High-performance gradient boosting
- Ensemble Voting - Combines multiple models for superior accuracy
- Explainable AI: Uses SHAP to explain model predictions
- Real-time API: Flask-based API for easy integration
- Modern Interface: Clean, responsive web interface
- Analytics Tracking: Uses SQLite3 to persistently track visitor counts, total scans, and detection statistics
- Backend: Python 3.11+, Flask, Flask-CORS
- Database: SQLite3
- Machine Learning: Scikit-learn, XGBoost, SHAP, NumPy, Pandas
- Web Scraping: Requests, Beautiful Soup, python-whois
- Frontend: HTML, CSS, JavaScript (Vanilla)
- Python 3.11 or higher
- pip (Python package installer)
-
Clone the repository:
git clone <repository-url> cd Phishing-Detector
-
Create a virtual environment:
python3 -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
python app.pyThe server will start at http://[IP_ADDRESS].
Check a URL (POST):
curl -X POST http://[IP_ADDRESS]/predict -H "Content-Type: application/json" -d '{"url": "https://www.google.com"}'Get Feature Importances (GET):
curl http://[IP_ADDRESS]/feature_importancesPhishing-Detector/
├── models/ # Trained ML models and scalers
├── data/ # Datasets
│ ├── test_urls.csv
│ ├── train_urls.csv
│ └── updated_dataset.csv
├── templates/ # HTML templates
│ └── index.html
├── app.py # Flask application and API
├── stats.db # SQLite database for analytics tracking
├── features.py # Feature engineering
├── phishing_detector.ipynb # Jupyter notebook experiments
└── requirements.txt # Dependencies
The models/ directory contains:
ensemble_model.pkl: Final ensemble modelrandom_forest_model.pkl: Random Forest classifierxgboost_model.pkl: XGBoost classifierscaler.pkl: StandardScaler for feature scaling
The features.py module extracts 30+ features including:
- Lexical Features: URL length, word count, special character ratio
- Domain Features: Domain length, presence of IP address, TLD verification
- Content Features: Presence of suspicious keywords, HTML length
- External Features: WHOIS registration age, SSL certificate status
To retrain the models with new data:
- Update the dataset in
data/ - Run the Jupyter notebook or training scripts
- The models will be saved to
models/
It's recommended to use the provided virtual environment. To deactivate:
deactivate- Update
features.pywith the new feature extraction logic - Update
phishing_detector.ipynbto test the new feature - Retrain the models
- Update
requirements.txtif new libraries are needed
This project is licensed under the MIT License.
Built with ❤️ by Deon George | Dhanush M