Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Phishing Detection System

Dept. of AI & Emerging Technologies

Six-model ensemble (3 classical ML + 3 deep learning) served via FastAPI, packaged in Docker, with a Chrome extension for real-time tab analysis.


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Chrome Extension                      β”‚
β”‚  popup.html / popup.js  β†’  background.js (SW)           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚  POST /predict
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   FastAPI  (api.py)                     β”‚
β”‚  Latency middleware Β· Request/Prediction/Error logs     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              PhishingPredictor  (predict.py)            β”‚
β”‚                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  Structured ML      β”‚   β”‚  Deep Learning           β”‚ β”‚
β”‚  β”‚  (ARFF features)    β”‚   β”‚  (URL char sequences)    β”‚ β”‚
β”‚  β”‚  ── Random Forest   β”‚   β”‚  ── LSTM (BiDir)         β”‚ β”‚
β”‚  β”‚  ── XGBoost         β”‚   β”‚  ── Character CNN        β”‚ β”‚
β”‚  β”‚  ── SVM (RBF)       β”‚   β”‚  ── Transformer encoder  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚                     Weighted Fusion                     β”‚
β”‚                     (F1-proportional)                   β”‚
β”‚                            β”‚                            β”‚
β”‚                     SHAP Explainability                 β”‚
β”‚                     Top-N Feature Report                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Repo layout

phishing-detector/
β”œβ”€β”€ train.py               ← train all 6 models
β”œβ”€β”€ predict.py             ← inference engine (importable)
β”œβ”€β”€ api.py                 ← FastAPI app
β”œβ”€β”€ benchmark.py           ← latency benchmark suite
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ .gitignore / .dockerignore
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ features.py        ← URL / WHOIS / DNS / SSL / HTML features
β”‚   └── models/
β”‚       β”œβ”€β”€ dl_models.py   ← LSTM Β· CNN Β· Transformer (PyTorch)
β”‚       └── artifacts/     ← saved .pkl / .pt  (git-ignored)
β”‚
β”œβ”€β”€ data/                  ← put your CSV + ARFF here (git-ignored)
β”‚   β”œβ”€β”€ phishing_site_urls.csv
β”‚   └── Training_Dataset.arff
β”‚
β”œβ”€β”€ logs/                  ← JSONL request / prediction / error logs
β”‚   β”œβ”€β”€ requests.jsonl
β”‚   β”œβ”€β”€ predictions.jsonl
β”‚   └── errors.jsonl
β”‚
└── extension/             ← Chrome / Edge extension (MV3)
    β”œβ”€β”€ manifest.json
    β”œβ”€β”€ background.js
    β”œβ”€β”€ popup.html
    β”œβ”€β”€ popup.js
    └── icons/             

Quick start

1 Β· Install dependencies

python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

2 Β· Place datasets

data/phishing_site_urls.csv   (549k URLs, columns: URL, Label)
data/Training_Dataset.arff    (11k samples, 30 features + Result)

3 Β· Train all models

python train.py \
  --csv   data/phishing_site_urls.csv \
  --arff  data/Training_Dataset.arff  \
  --sample 50000 \
  --epochs 10    \
  --device cpu

Artifacts saved to src/models/artifacts/.

4 Β· Run the API

uvicorn api:app --host 0.0.0.0 --port 8000 --reload

5 Β· Test a prediction

curl -s -X POST http://localhost:8000/predict \
  -H "Content-Type: application/json"         \
  -d '{"url":"http://login-paypal-verify.com/update?account=true"}' \
  | python -m json.tool

6 Β· Run benchmarks

python benchmark.py --requests 200 --concurrency 8

Docker

Build & run

# Build
docker build -t phishing-detector:latest .

# Run
docker run -d -p 8000:8000 \
  -v $(pwd)/src/models/artifacts:/app/src/models/artifacts:ro \
  -v $(pwd)/logs:/app/logs \
  --name phishing-api \
  phishing-detector:latest

With Compose

docker compose up -d
docker compose logs -f api

API reference

Method Endpoint Description
POST /predict Classify a URL (full ensemble)
GET /health Liveness check
GET /metrics Aggregate latency stats (last 1000)

POST /predict β€” request body

{
  "url":          "https://example.com",
  "include_shap": true,
  "fetch_html":   false
}

Response schema

{
  "url":         "...",
  "label":       "phishing | safe",
  "is_phishing": true,
  "confidence":  0.87,
  "model_votes": {
    "rf":          {"label":"phishing","confidence":0.91},
    "xgb":         {"label":"phishing","confidence":0.85},
    "svm":         {"label":"phishing","confidence":0.79},
    "lstm":        {"label":"phishing","confidence":0.88},
    "cnn":         {"label":"phishing","confidence":0.86},
    "transformer": {"label":"phishing","confidence":0.92}
  },
  "top_features": [
    {"feature":"has_suspicious_words","value":1.0,"importance":0.23}
  ],
  "shap_values":  {"has_suspicious_words": 0.18, "...": "..."},
  "metadata": {
    "domain": "login-paypal-verify.com",
    "domain_age_days": 12,
    "ssl_valid":       false,
    "has_mx":          false
  },
  "latency_ms":   14.3,
  "request_id":   "a1b2c3d4"
}
response

Chrome extension

  1. Open Chrome β†’ chrome://extensions
  2. Enable Developer mode
  3. Click Load unpacked β†’ select the extension/ folder
  4. Add icons to extension/icons/ (icon16/48/128.png)
  5. Change API_BASE in background.js to match your server

Chrome Extention Interface

phishguard_extention

Live feed alternatives: OpenPhish Β· PhishTank

About

A real-time zero-day phishing detector (Chrome Extension + FastAPI). A novel 6-model ensemble fuses deep learning text analysis with classical ML network forensics (SSL, DNS). By cross-referencing live structural data against NLP sequences, it organically eliminates false positives to deliver sub-second threat intelligence at the browser edge.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages