Real-time phishing URL detection system using Machine Learning and PhishTank database verification.
PhishGuard is a ML-powered phishing detection system that analyzes URLs in real-time to identify potential phishing attempts. It combines a trained Random Forest classifier with PhishTank database lookups to provide accurate threat detection.
- ML-Powered Detection: Random Forest model trained on 20,000+ URLs with 99% accuracy
- 60 URL Features: Comprehensive feature extraction including entropy, domain analysis, and suspicious patterns
- Real-time API: FastAPI-based REST API for instant URL verification
- Web Dashboard: Interactive Bootstrap 5 dashboard with statistics and alerts
- PhishTank Integration: Cross-references URLs against known phishing database
- Alert System: Automatic alert generation with severity levels
PhishTank is a collaborative clearing house for phishing data. It provides a free, community-driven database of verified phishing URLs.
- Dataset:
verified_online.csv - Size: 46,000+ verified phishing URLs
- Fields: phish_id, url, submission_time, verification_time, target (brand being impersonated)
- Top Targets: IRS, Facebook, Microsoft, DHL, Amazon, PayPal, Netflix
Tranco is a research-grade top websites ranking that combines multiple popularity lists (Alexa, Cisco Umbrella, Majestic) to create a more reliable ranking.
- Dataset: Tranco List 7N42X
- Size: 1,000,000 top domains
- Source: Combined ranking from multiple sources
- Usage: Top 5,000 domains used for legitimate URL training
| Class | Samples | Percentage |
|---|---|---|
| Phishing | 10,000 | 50% |
| Legitimate | 10,000 | 50% |
| Total | 20,000 | 100% |
| Metric | Score |
|---|---|
| Accuracy | 99.08% |
| Precision | 99.55% |
| Recall | 98.60% |
| F1 Score | 99.07% |
| AUC-ROC | 99.78% |
url_length- Total URL lengthurl_entropy- Shannon entropy of URLpath_entropy- Shannon entropy of pathsubdomain_length- Length of subdomainpath_length- Length of URL pathnum_digits- Count of digits in URLhas_suspicious_path- Contains login/verify/account keywordsnum_subdomains- Number of subdomain levelsis_suspicious_tld- Uses suspicious TLD (.tk, .ml, etc.)
- Python 3.11+
# Clone the repository
git clone https://github.com/zawster/phish-guard.git
cd phish-guard
# Install dependencies
pip install -r requirements.txt
# Train the model (required first time)
python scripts/train_model.py
# Start the server
uvicorn src.api.app:app --reload --host 127.0.0.1 --port 8000Open http://127.0.0.1:8000 in your browser to access:
- Dashboard: Real-time statistics and charts
- URL Checker: Interactive URL analysis tool
- Alerts: Manage phishing detection alerts
curl -X POST http://127.0.0.1:8000/api/v1/detect \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'Response:
{
"url": "https://example.com",
"is_phishing": false,
"confidence": 0.95,
"ml_score": 0.05,
"phishtank_match": false,
"detection_source": "ml",
"features": { ... }
}| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/detect |
Check single URL |
| POST | /api/v1/detect/batch |
Check multiple URLs (max 100) |
| GET | /api/v1/detect/history |
Get check history |
| GET | /api/v1/alerts |
List all alerts |
| PATCH | /api/v1/alerts/{id} |
Update alert status |
| GET | /api/v1/stats/dashboard |
Dashboard statistics |
| GET | /api/v1/stats/daily |
Daily detection trend |
| GET | /health |
Health check |
The model extracts 60 features from each URL:
- URL length, domain length, path length, query length, subdomain length
- Dots, hyphens, slashes, digits, special characters (@, ?, =, &)
- Number of subdomains, TLD type, IP address detection, HTTPS usage
- Brand names in wrong places, suspicious keywords (login, verify, account)
- Suspicious TLDs (.tk, .ml, .xyz), URL shorteners, punycode
- Shannon entropy of domain, path, and full URL (randomness detection)
1. Extract 60 features from URL
2. ML model predicts phishing probability (0.0 - 1.0)
3. Check URL against PhishTank database
4. Combine results:
- PhishTank match → 100% confidence (definite phishing)
- ML score > 0.5 → Flagged as phishing
- ML score < 0.5 → Considered safe
5. Generate alert if phishing detected
6. Store result in database
| Component | Technology |
|---|---|
| Backend | FastAPI, Uvicorn |
| Database | SQLite, SQLAlchemy |
| ML | scikit-learn (Random Forest) |
| Frontend | Jinja2, Bootstrap 5, Chart.js |
| Data Processing | pandas, numpy |
| URL Parsing | tldextract |
Environment variables (optional):
# .env file
DEBUG=true
API_HOST=0.0.0.0
API_PORT=8000
MODEL_THRESHOLD=0.5- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- PhishTank - Phishing URL database
- Tranco List - Top websites ranking
- Claude Code with Opus 4.5 - AI-assisted development for interface design and API structure
This tool is for educational and research purposes. While it achieves high accuracy, no phishing detection system is 100% accurate. Always exercise caution when clicking links and verify suspicious URLs through multiple sources.


