Skip to content
项目

chamanthmvs/Phishing-Website-Detection

在 GitHub 查看

关于

It is a project of detecting phishing websites which are main cause of cyber security attacks. It is done using Machine learning with Python

安全与隐私

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Phishing Website Detection

Phishing Website Detection classifies URLs as legitimate or potentially phishing using machine learning. It is built as two decoupled services:

  • a FastAPI backend that owns feature extraction and the trained models and exposes a JSON API;
  • a Next.js frontend that talks to the backend only through that API.

For the visual project presentation, visit the project page.

At a glance: 20 lexical URL features · 3 compared models (Random Forest, Gradient Boosting, Logistic Regression) · ~90% accuracy · 0.96 ROC AUC · clean API/UI separation · fully offline, reproducible training. See docs/IMPROVEMENTS.md for the full history.

Architecture

┌──────────────────────┐      HTTP / JSON       ┌───────────────────────────┐
│  Next.js frontend     │  ───────────────────►  │  FastAPI backend           │
│  (frontend/)          │   GET  /api/models     │  (backend/)                │
│  no model, no data,   │   POST /api/scan       │  - featureExtraction.py    │
│  no Python            │  ◄───────────────────  │  - models/*.sav + metadata │
└──────────────────────┘                        └───────────────────────────┘

The frontend contains no model, no dataset, and no scikit-learn — every prediction is requested from the backend API. This keeps the two layers independently developed, tested, and deployed.

How it works

The model uses lexical features — 20 signals computed purely from the URL string, with no request to the site being scanned. This makes every scan fast, deterministic, privacy-preserving, and reproducible, and it behaves identically on a laptop and on a locked-down cloud host.

Family Example signals
Length URL / hostname / path length
Composition counts of ., -, @, ?, &, =, %, digits; digit ratio
Structure subdomain count, raw-IP host, // redirection, repeated http token
Reputation heuristics HTTPS usage, prefix/suffix -, URL shorteners, phishing keywords

Model comparison

Three models are trained and compared on a held-out 25% test set (2,553 URLs; 1,560 legitimate / 993 phishing). The best is served as the API default.

Model Accuracy ROC AUC CV accuracy
Random Forest (default) 89.5% 0.959 90.2%
Histogram Gradient Boosting 90.0% 0.957 90.0%
Logistic Regression 80.4% 0.874 81.0%

Exact numbers and feature importances live in backend/models/models_metadata.json, regenerated on every training run.

Quick start

1. Backend

cd backend
python3 -m venv ../.venv && source ../.venv/bin/activate
pip install -r requirements.txt
python train.py                       # train the models (offline, reproducible)
uvicorn app.main:app --reload --port 8000

2. Frontend (in a second terminal; requires Node.js 20.9+)

cd frontend
npm install
cp .env.local.example .env.local      # defaults to http://localhost:8000
npm run dev                           # http://localhost:3000

See backend/README.md and frontend/README.md for details.

Tests

cd backend
pip install -r requirements-dev.txt
python -m pytest                      # feature extraction + registry + API

Repository layout

backend/     FastAPI API, feature extraction, training, models, tests
frontend/    Next.js app (App Router, TypeScript)
docs/        GitHub Pages presentation + improvement log
notebooks/   original exploratory notebooks (historical; see note below)

A note on the notebooks

notebooks/ holds the original exploratory work, which relied on live WHOIS/DNS lookups and an Alexa traffic-rank API that was shut down in 2022. The current pipeline replaces that with a purely lexical, offline, reproducible approach. The notebooks are retained for historical context only.

Disclaimer

A heuristic tool for learning, experimentation, and responsible security research. A prediction is not a guarantee that a website is safe or malicious — always use good judgement.

License

Released under the MIT License.

Built by

Built by chamanthmvs.

探索相关项目

加载中…