Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ PhishGuard AI

AI-Driven Phishing Detection Platform

Python scikit-learn FastAPI Streamlit License

URL phishing detection Β· Email analysis via Claude AI Β· Domain reputation (URLhaus) Β· Screenshot brand-similarity Β· Chrome extension


πŸ“Έ Screenshots

URL Analyzer β€” Clean Dashboard

Dashboard

URL Analyzer β€” Phishing Detected (93.8% risk)

Phishing detected

URL Analyzer β€” Legitimate URL (0% risk)

Legitimate URL

Email Analyzer β€” AI Phishing Detection

Email analysis

Domain Reputation β€” URLhaus Threat Intel

Domain reputation

Screenshot Analysis β€” Visual Brand Similarity

Screenshot analysis


✨ Features

Feature Engine Size
πŸ”— URL Analyzer Random Forest + custom feature attribution Core
βœ‰οΈ Email Analyzer Claude API (claude-haiku) / keyword fallback Core
🌐 Domain Reputation URLhaus (abuse.ch), free, no API key needed Core
πŸ–ΌοΈ Screenshot Analysis Playwright + perceptual hash (pHash) Optional +280MB
πŸ”Œ Browser Extension Chrome MV3, calls FastAPI backend No extra install

πŸš€ Quick Start

First-time setup (one command)

Linux / macOS:

git clone https://github.com/dedsechack-1337/PhishGuardAI.git
cd PhishGuardAI
chmod +x setup_and_run.sh run.sh run_api.sh
./setup_and_run.sh

Windows:

git clone https://github.com/dedsechack-1337/PhishGuardAI.git
cd PhishGuardAI
setup_and_run.bat

The script will:

  1. Create a Python virtual environment
  2. Install all core dependencies (~510MB)
  3. Ask if you want the Screenshot Analysis add-on (+280MB, optional)
  4. Generate the URL training dataset
  5. Train the Random Forest model
  6. Launch the web UI and open your browser

First run takes 3–5 minutes. Subsequent runs use ./run.sh and launch instantly.

Every day after that

./run.sh        # Linux/macOS β€” just opens the dashboard
run.bat         # Windows

πŸ“¦ Install Size Breakdown

Component Size Required
Python core ML (scikit-learn, pandas, numpy) ~290MB βœ… Yes
Streamlit web UI ~30MB βœ… Yes
FastAPI + uvicorn ~8MB βœ… Yes
anthropic SDK ~2MB βœ… Yes
requests, pillow, imagehash ~9MB βœ… Yes
Core total ~510MB
Playwright + Chromium browser +280MB Optional
With screenshot add-on ~790MB

XGBoost (~250MB) and SHAP (~340MB) are not installed by default. Install requirements-dev.txt only if you want to retrain with XGBoost.


🌐 Browser Extension

The Chrome extension scans the page you're currently viewing using the FastAPI backend.

Install

  1. Start the API backend:

    ./run_api.sh    # Linux/macOS
    run_api.bat     # Windows

    Backend runs at http://localhost:8000 β€” docs at http://localhost:8000/docs

  2. Open Chrome and go to chrome://extensions/

  3. Enable Developer mode (top-right toggle)

  4. Click Load unpacked and select the extension/ folder

Usage

Click the πŸ›‘οΈ PhishGuard icon in your toolbar on any page β†’ SCAN THIS PAGE β†’ instant risk verdict + breakdown.


πŸ”‘ Email Analysis β€” Claude API Setup

For AI-powered email phishing detection, set your Anthropic API key:

# Linux/macOS
export ANTHROPIC_API_KEY=sk-ant-...

# Windows
set ANTHROPIC_API_KEY=sk-ant-...

Without a key, the email analyzer uses a built-in keyword-based fallback that still catches common phishing patterns.

Get a free API key at console.anthropic.com.


πŸ–ΌοΈ Screenshot Analysis β€” Optional Add-on

Install after the main setup:

# Linux/macOS
pip install playwright==1.48.0
python -m playwright install chromium

# Windows (in venv)
venv\Scripts\pip install playwright==1.48.0
venv\Scripts\python -m playwright install chromium

Then rebuild the brand reference database (captures screenshots of major brands once):

python src/build_brand_reference.py

Restart the UI β€” the Screenshot Analysis tab will now be fully functional.


πŸ“‚ Project Structure

PhishGuardAI/
β”œβ”€β”€ setup_and_run.sh / .bat     # First-time setup + launch
β”œβ”€β”€ run.sh / run.bat            # Daily launch (fast)
β”œβ”€β”€ run_api.sh / run_api.bat    # FastAPI backend for browser extension
β”œβ”€β”€ requirements.txt            # Core deps (~510MB)
β”œβ”€β”€ requirements-screenshot.txt # Screenshot add-on (+280MB)
β”œβ”€β”€ requirements-dev.txt        # Optional: XGBoost for retraining
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app.py                  # Streamlit web UI (4 tabs)
β”‚   β”œβ”€β”€ api.py                  # FastAPI backend (5 endpoints)
β”‚   β”œβ”€β”€ feature_extraction.py   # 25 URL feature signals
β”‚   β”œβ”€β”€ train.py                # RF model training pipeline
β”‚   β”œβ”€β”€ predict.py              # URL inference + explanations
β”‚   β”œβ”€β”€ predict_email.py        # Email inference (Claude API / fallback)
β”‚   β”œβ”€β”€ domain_reputation.py    # URLhaus threat intel lookup
β”‚   β”œβ”€β”€ screenshot_analysis.py  # Playwright capture + pHash comparison
β”‚   β”œβ”€β”€ build_brand_reference.py# Build brand reference hash database
β”‚   └── generate_dataset.py     # Synthetic URL training dataset
β”‚
β”œβ”€β”€ extension/                  # Chrome browser extension (MV3)
β”‚   β”œβ”€β”€ manifest.json
β”‚   β”œβ”€β”€ popup.html
β”‚   β”œβ”€β”€ popup.js
β”‚   └── icons/
β”‚
β”œβ”€β”€ models/                     # Trained model artifacts (auto-generated)
β”‚   β”œβ”€β”€ random_forest.joblib
β”‚   β”œβ”€β”€ explainer.joblib        # Lightweight feature attribution data
β”‚   └── feature_names.joblib
β”‚
β”œβ”€β”€ data/                       # Datasets (auto-generated)
β”‚   β”œβ”€β”€ urls_dataset.csv
β”‚   └── brand_reference_hashes.json
β”‚
└── screenshots/                # README screenshots

πŸ› οΈ API Endpoints

The FastAPI backend (http://localhost:8000) provides:

Endpoint Method Description
/ GET Health check + model status
/analyze/url POST URL risk score + explanation
/analyze/email POST Email risk score + signals
/analyze/reputation POST URLhaus domain/URL lookup
/analyze/screenshot POST Capture screenshot + brand comparison
/analyze/full POST Combined URL + reputation analysis

Interactive docs: http://localhost:8000/docs


πŸ”„ Using Real Datasets

Replace the synthetic training data with real phishing datasets for production-quality accuracy:

URLs (aim for 90–97% accuracy on real data):

Emails:

All datasets just need url,label or text,label CSV columns β€” the training scripts work unchanged.


πŸ› Troubleshooting

Problem Fix
streamlit: not found Activate venv: source venv/bin/activate
ANTHROPIC_API_KEY not set Email uses keyword fallback β€” works fine without key
URLhaus timeout/blocked Domain reputation returns "unknown" gracefully β€” check your network allows urlhaus-api.abuse.ch
Screenshot tab says "not installed" Run pip install playwright && python -m playwright install chromium
Extension shows "❌ offline" Start API first: ./run_api.sh
Models not found error Run python src/train.py from the project root

πŸ“‹ Versions

Package Version
Python 3.10–3.12
scikit-learn 1.5.2
pandas 2.2.3
numpy 1.26.4
streamlit 1.39.0
fastapi 0.115.5
anthropic 0.39.0
playwright 1.48.0 (optional)

πŸ‘€ Author

dedsechack-1337 πŸ”— GitHub Β· πŸ”— PhoenixSIEM


⚠️ For research and educational use only. Always verify suspicious links through multiple channels.

About

AI-Driven Phishing Detection Platform

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages