SIH 2026 β Problem Statement #100
Phishing is the #1 cyber threat vector. Traditional solutions tell users "This site is dangerous" β but never explain why. Users either blindly trust the warning or ignore it because they don't understand it.
Most existing tools:
- Use blacklist-based detection (misses new domains)
- Provide no explanation for the verdict
- Cannot detect brand impersonation in real-time
- Require cloud lookups that add latency
ThreatLens-Shield is an explainable AI phishing detection system that:
- Analyzes every URL using 34 lexical/structural features
- Scores it 0β100 using a trained Random Forest classifier
- Explains why it's risky in plain language
- Prevents the user from proceeding on high-risk sites
- Works both as a web scanner and a Chrome extension
Traditional tools say: "Dangerous website."
ThreatLens-Shield says: "Dangerous β because the hostname contains a brand keyword in an unofficial domain, no HTTPS is active, and the URL contains multiple credential-related keywords."
User Input (URL)
β
βΌ
βββββββββββββββββββ
β Frontend β threatlens-shield.netlify.app
β index.html β Plain HTML/CSS/JS β no framework
ββββββββββ¬βββββββββ
β POST /api/scan
βΌ
βββββββββββββββββββ
β Flask Backend β sih-l2l2.onrender.com
β app.py β Gunicorn + CORS
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Feature Engine β backend/ml/feature_extractor.py
β 34 URL features β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β RandomForest β backend/model/phishing_model.joblib
β Classifier β 50 trees, class_weight=balanced
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Risk Engine β backend/ml/explain.py
β + Explainabilityβ Score 0-100, Verdict, Reasons
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β JSON Response β risk_score, verdict, reasons,
β β confidence, features, explanations
βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Chrome Extensionβ extension/ β Manifest V3
β Prevention β In-page overlay for HIGH RISK / DANGEROUS
βββββββββββββββββββ
| Feature | Status |
|---|---|
| 34-feature URL analysis | β Implemented |
| Random Forest ML classifier | β Implemented |
| 0β100 risk scoring | β Implemented |
| 4 risk levels (SAFE / SUSPICIOUS / HIGH RISK / DANGEROUS) | β Implemented |
| Plain-language explanations | β Implemented |
| Brand impersonation detection | β Implemented |
| HTTPS / IP hostname detection | β Implemented |
| Punycode / homograph detection | β Implemented |
| Chrome Extension (Manifest V3) | β Implemented |
| In-browser prevention overlay | β Implemented |
| Flask REST API | β Implemented |
| Live Netlify frontend | β Deployed |
| Render backend deployment | β Deployed |
| 135 automated tests | β All passing |
| Feature | Phase |
|---|---|
| QR code inspection | Roadmap |
| Download file protection | Roadmap |
| Gmail / Outlook link scanning | Roadmap |
| Domain age (WHOIS) features | Roadmap |
| Live threat intelligence feeds | Roadmap |
| SHAP explainability | Roadmap |
| User feedback loop / retraining | Roadmap |
Random Forest Classifier
- 50 decision trees
class_weight="balanced"β handles class imbalancerandom_state=42β fully reproduciblemax_features="sqrt"β prevents overfitting
- Source: Faizan Ahmad's phishing URL dataset (~420,000 URLs)
- Training sample: 60,000 URLs (30,000 legitimate + 30,000 phishing), stratified
- Split: 80% train / 20% test, stratified
| Metric | Score |
|---|---|
| Accuracy | 88.54% |
| Precision | 88.79% |
| Recall | 88.22% |
| F1-Score | 88.50% |
| Test set size | 12,000 URLs |
| Rank | Feature | Importance |
|---|---|---|
| 1 | url_entropy |
0.1284 |
| 2 | path_length |
0.1193 |
| 3 | hostname_entropy |
0.1058 |
| 4 | num_digits |
0.0986 |
| 5 | url_length |
0.0924 |
| 6 | url_depth |
0.0776 |
| 7 | hostname_length |
0.0756 |
| 8 | num_hyphens |
0.0693 |
| 9 | num_dots |
0.0570 |
| 10 | suspicious_keyword_count |
0.0322 |
All features are extracted locally from the URL string β no external API calls.
URL Structure: url_length, hostname_length, path_length, url_depth,
num_dots, num_hyphens, num_digits, num_special_chars,
num_query_params, url_parameter_count
Hostname Analysis: num_subdomains, hostname_token_count, hostname_entropy,
abnormal_hostname_length, ip_hostname, punycode_detected
Scheme & Security: https_enabled, http_enabled
Obfuscation: has_at_symbol, has_double_slash_in_path,
encoded_char_count, percent_encoded_count, url_entropy
Suspicious Keywords: suspicious_keyword_count, login_keyword_count,
verify_keyword_count, account_keyword_count,
secure_keyword_count, password_keyword_count,
update_keyword_count, payment_keyword_count
Brand Signals: brand_impersonation_indicator, brand_keyword_count
TLD Analysis: suspicious_tld
| Score | Verdict | Browser Behavior |
|---|---|---|
| 0β29 | π’ SAFE | Green β badge β allow normally |
| 30β59 | π‘ SUSPICIOUS | Yellow ? badge β allow, no interruption |
| 60β79 | π HIGH RISK | Orange ! badge β allow, no interruption |
| 80β100 | π΄ DANGEROUS | Full-page red overlay β Go Back / Continue Anyway |
Base URL: https://sih-l2l2.onrender.com
{ "status": "ok", "service": "ThreatLens-Shield API" }Request:
{ "url": "http://paypal-secure-login.example.com" }Response:
{
"success": true,
"url": "http://paypal-secure-login.example.com",
"risk_score": 91,
"verdict": "DANGEROUS",
"confidence": 0.905,
"reasons": [
"HTTPS is not enabled (insecure connection).",
"The hostname is abnormally long, often used to hide the real domain.",
"The URL contains multiple credential-related keywords.",
"Potential brand impersonation pattern detected."
],
"features": { "url_length": 38.0, "num_hyphens": 2.0, "...": "..." },
"explanations": [
{ "feature": "url_entropy", "value": 4.21, "importance": 0.1284 },
{ "feature": "hostname_entropy", "value": 3.91, "importance": 0.1058 }
]
}| Layer | Technology |
|---|---|
| Frontend | Vanilla HTML5 / CSS3 / JavaScript |
| Backend | Python 3.14 + Flask 3.0 + Built-in WSGI |
| ML | scikit-learn 1.9 (RandomForestClassifier) |
| Data | numpy, joblib (pandas/scipy used only for training) |
| Testing | pytest (135 tests) |
| Extension | Chrome Extension Manifest V3 |
| Frontend Hosting | Netlify |
| Backend Hosting | Render (free tier) |
| CORS | flask-cors with environment-variable origin control |
- Python 3.10+
- Git
git clone https://github.com/Shivansh1146/SIH.git
cd SIH/ThreatLens-Shieldcd backend
python -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
pip install -r requirements.txtcd backend
python ml/train_model.py
# Downloads dataset, trains RandomForest, saves model to backend/model/cd backend
python app.py
# β http://127.0.0.1:5000Simply open index.html in your browser (or serve with Live Server).
# Health
curl http://127.0.0.1:5000/api/health
# Scan
curl -X POST http://127.0.0.1:5000/api/scan \
-H "Content-Type: application/json" \
-d '{"url": "http://paypal-secure-login.example.com"}'cd backend
pytest tests/ -v
# β 135 passed- Open Chrome β type
chrome://extensionsβ press Enter - Toggle Developer mode ON (top-right corner)
- Click Load unpacked
- Select the
extension/folder from this repo - The ThreatLens-Shield icon appears in your toolbar β no local server needed!
- Browse any website β ThreatLens-Shield automatically scans it in the background
- SAFE (0β29) β Green β badge on the toolbar icon
- SUSPICIOUS (30β59) β Yellow ? badge β browsing continues normally
- HIGH RISK (60β79) β Orange ! badge β browsing continues normally
- DANGEROUS (80β100) β Full-page red overlay blocks navigation with Go Back and Continue Anyway buttons
API: The extension calls
https://sih-l2l2.onrender.com/api/scan(live production backend β no local setup required).
β οΈ Cold start: If the Render backend has been idle for 15+ minutes, the first scan may take ~30 seconds. Subsequent scans are instant.
- URL: https://threatlens-shield.netlify.app
- Auto-deploys from the
mainbranch on push - Config:
netlify.toml
- URL: https://sih-l2l2.onrender.com
- Deployed from the
backend/root directory - Config:
render.yaml - Start command:
python app.py(Memory optimized for 512MB RAM tier) - Dependencies:
requirements-prod.txt(Excludes heavy training libraries like Pandas/SciPy) - Env vars:
FRONTEND_ORIGIN=https://threatlens-shield.netlify.app
β οΈ Render Free Tier: The service spins down after inactivity. The first request after idle may take 50β60 seconds to respond. Subsequent requests are fast.
| Step | Action | Expected Result |
|---|---|---|
| 1 | Open https://threatlens-shield.netlify.app | Frontend loads with scanner |
| 2 | Scan https://github.com |
Low risk score, SAFE or SUSPICIOUS verdict |
| 3 | Scan http://paypal-secure-login.example.com |
Score 85+, DANGEROUS verdict |
| 4 | Read reasons | "No HTTPS", "Brand impersonation", "Credential keywords" |
| 5 | Read explainability | Feature importances: url_entropy, path_length |
| 6 | Load extension β browse to GitHub | Popup shows low risk, badge shows β |
| 7 | Navigate to a suspicious URL | Full-page overlay: β THREATLENS-SHIELD WARNING |
- Render cold start: Free tier spins down after 15 min of inactivity β first scan after idle is slow (~30s)
- Short domain bias: Very short bare domains (e.g.
github.com) have low entropy and may score higher than expected. A heuristic override protects known official brand domains - Lexical only: All 34 features are extracted from the URL string only. No DOM analysis, no WHOIS, no live threat intelligence feeds
- YouTube / non-brand sites: Sites not in the brand list that have query parameters may score as SUSPICIOUS (30β59) β this is honest model behavior, not a bug
ThreatLens-Shield/
βββ index.html # Frontend (single-page)
βββ netlify.toml # Netlify config
βββ render.yaml # Render deployment config
βββ README.md
βββ extension/ # Chrome Extension (Manifest V3)
β βββ manifest.json
β βββ background.js # Service worker + API calls
β βββ content.js # DOM analysis + prevention overlay
β βββ popup.html / popup.js # Extension popup UI
β βββ styles.css
βββ backend/
βββ app.py # Flask application factory
βββ requirements.txt # Full dev requirements
βββ requirements-prod.txt # Lean prod requirements
βββ Procfile # Start command
βββ .env.example # Environment variable template
βββ ml/
β βββ feature_extractor.py # 34-feature URL analysis engine
β βββ train_model.py # Training pipeline
β βββ explain.py # Risk engine + explainability
βββ model/
β βββ phishing_model.joblib # Trained model (9MB, committed)
β βββ feature_metadata.json # Training provenance + metrics
βββ tests/
βββ test_api.py # 22 API endpoint tests
βββ test_features.py # 92 feature extractor tests
βββ test_model.py # 21 model integrity tests
SIH 2026 β PS #100
Real-Time AI/ML-Based Phishing Detection and Prevention System
ThreatLens-Shield β See through phishing before it sees you.