Skip to content

AdityaP700/PrivacyGuard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

25 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PrivacyGuard : Your On-device ML-powered phishing defense with privacy-first P2P threat sharing and homograph detection.

PrivacyGuard Banner PrivacyGuard is an intelligent browser extension that protects users from phishing attacks and malicious websites using advanced machine learning, heuristic analysis, and homograph detection. Built with privacy-first principles, all analysis happens locally in your browserโ€”no data ever leaves your device.

Demo Link

Youtube

License Version


โœจ Key Features

๐Ÿค– AI-Powered Detection

  • Custom TensorFlow.js Model: Trained on 100k+ samples with 88.8% accuracy
  • 16 URL Features: Real-time analysis of lexical patterns and suspicious traits
  • On-Device Processing: Complete privacy - no data sent to servers
  • Sub-500ms Analysis: Fast threat assessment

๐Ÿšฆ Smart Alert System

  • ๐Ÿ”ด Red Alert: Full-page warnings for high-risk sites (>75 risk score)
  • ๐ŸŸก Yellow Alert: Non-intrusive notifications for suspicious sites (30-75 score)
  • ๐ŸŸข Green Status: Silent monitoring for safe sites (<30 score)

๐Ÿ›ก๏ธ Multi-Layer Protection

  • Homograph Detection: Catches Unicode/Punycode spoofing attacks
  • Heuristic Analysis: Flags suspicious URL patterns and forms
  • P2P Intelligence: Community-driven threat sharing (mock implementation)
  • Smart Whitelisting: Learn from your browsing preferences

๐ŸŽฏ Live Demonstrations

Landing Page Interface

PrivacyGuard Banner )

Alert System in Action

Alert Type Visual Example Trigger Conditions
๐Ÿ”ด High Risk PrivacyGuard Banner ML Score >75, Homograph attacks, Known phishing
๐ŸŸก Caution [Add yellow alert screenshot] ML Score 30-75, Suspicious patterns
๐ŸŸข Safe PrivacyGuard Banner ML Score <30, Whitelisted domains

Console Output & Model Analysis

PrivacyGuard Banner


๐Ÿ“Š Performance & Accuracy

Trained and validated using comprehensive datasets:

๐Ÿ“ˆ Model Performance

Dataset Sources:
โ”œโ”€โ”€ Primary: github.com/ebubekirbbr/dephides (~100k samples)
โ””โ”€โ”€ Secondary: IEEE DataPort phishing dataset (validation)

Results:
โ”œโ”€โ”€ Accuracy: 88.88%

โšก Runtime Performance

  • Analysis Speed: 450ms average per URL
  • Memory Usage: ~15MB additional browser memory
  • CPU Impact: <2% during analysis
  • Model Loading: 1.8s (cached after first load)

๐Ÿ› ๏ธ Technical Architecture

Core Components

PrivacyGuard/
โ”œโ”€โ”€ js/
โ”‚   โ”œโ”€โ”€ content.js          # Main analysis engine & alert system
โ”‚   โ”œโ”€โ”€ tf.min.js          # TensorFlow.js runtime
โ”‚   โ””โ”€โ”€ tfjs_model/        # Trained ML model files
โ”œโ”€โ”€ popup/
โ”‚   โ”œโ”€โ”€ popup.html         # Extension interface
โ”‚   โ”œโ”€โ”€ popup.js           # UI logic & controls
โ”‚   โ””โ”€โ”€ popup.css          # Styling
โ”œโ”€โ”€ manifest.json          # Extension configuration
โ””โ”€โ”€ icons/                 # Extension icons

Detection Pipeline

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Browser Extension                        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚   Content   โ”‚  โ”‚   Popup     โ”‚  โ”‚    Background       โ”‚  โ”‚
โ”‚  โ”‚   Script    โ”‚  โ”‚   Interface โ”‚  โ”‚    Service          โ”‚  โ”‚
โ”‚  โ”‚             โ”‚  โ”‚             โ”‚  โ”‚                     โ”‚  โ”‚
โ”‚  โ”‚ โ€ข ML Model  โ”‚  โ”‚ โ€ข Risk      โ”‚  โ”‚ โ€ข Storage Mgmt      โ”‚  โ”‚
โ”‚  โ”‚ โ€ข Heuristicsโ”‚  โ”‚   Display   โ”‚  โ”‚ โ€ข Settings          โ”‚  โ”‚
โ”‚  โ”‚ โ€ข Homograph โ”‚  โ”‚ โ€ข Controls  โ”‚  โ”‚ โ€ข P2P Simulation    โ”‚  โ”‚
โ”‚  โ”‚ โ€ข Alerts    โ”‚  โ”‚ โ€ข Analytics โ”‚  โ”‚                     โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 Detection Engines                           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚    ML       โ”‚  โ”‚  Heuristic  โ”‚  โ”‚     Homograph       โ”‚  โ”‚
โ”‚  โ”‚   Engine    โ”‚  โ”‚   Analysis  โ”‚  โ”‚     Detection       โ”‚  โ”‚
โ”‚  โ”‚             โ”‚  โ”‚             โ”‚  โ”‚                     โ”‚  โ”‚
โ”‚  โ”‚ โ€ข 16 URL    โ”‚  โ”‚ โ€ข HTTPS     โ”‚  โ”‚ โ€ข Punycode          โ”‚  โ”‚
โ”‚  โ”‚   Features  โ”‚  โ”‚   Check     โ”‚  โ”‚ โ€ข Mixed Scripts     โ”‚  โ”‚
โ”‚  โ”‚ โ€ข TF.js     โ”‚  โ”‚ โ€ข Form      โ”‚  โ”‚ โ€ข Confusables       โ”‚  โ”‚
โ”‚  โ”‚   Model     โ”‚  โ”‚   Detection โ”‚  โ”‚ โ€ข Unicode Analysis  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Alert Implementation with Shadow DOM

// Isolated CSS to prevent conflicts
const createAlert = (riskData) => {
    const container = document.createElement('div');
    const shadow = container.attachShadow({mode: 'closed'});
    
    shadow.innerHTML = `
        <style>
            .privacy-guard-alert {
                position: fixed; z-index: 2147483647;
                font-family: -apple-system, BlinkMacSystemFont, sans-serif;
                /* Fully isolated styles */
            }
        </style>
        ${getAlertHTML(riskData)}
    `;
    
    document.body.appendChild(container);
};

๐Ÿš€ Quick Setup & Installation

1. Clone Repository

git clone https://github.com/yourusername/PrivacyGuard.git
cd PrivacyGuard

2. Install in Chrome

  1. Open chrome://extensions/
  2. Enable Developer Mode (top right)
  3. Click "Load unpacked"
  4. Select the PrivacyGuard folder
  5. Pin the extension icon for easy access

3. Test the Extension

# Serve test files locally
python -m http.server 8000

# Test URLs:
http://localhost:8000/college.html     # Yellow alert (HTTP)
http://www.xn--pypal-4ve.com/         # Red alert (Homograph)
https://www.google.com                # Green (Safe)

๐Ÿงช Advanced Testing & Console Commands

View Analysis Data

// Check whitelist
chrome.storage.local.get('privacyGuardWhitelist', console.log);

// View P2P data
chrome.storage.local.get(['privacyGuardP2PUserPhishing', 'privacyGuardP2PUserSafe'], console.log);

// Manual analysis
analyzeCurrentURL().then(console.log);

Mock P2P Network Testing

// Add to phishing list
 const p2pSettings = await new Promise(resolve => {
        chrome.storage.local.get([P2P_ENABLED_KEY, P2P_USER_CONFIRMED_SAFE_KEY, P2P_USER_CONFIRMED_PHISHING_KEY], result => resolve(result));
    });

๐Ÿ”ฌ Dataset & Model Training

Training Data Sources

  1. Primary Dataset: github.com/ebubekirbbr/dephides

    • ~100,000 balanced samples (legitimate + phishing URLs)
    • Combined from PhishTank, Tranco rankings, academic sources
  2. Validation Dataset: Tranco

    • Curated academic dataset for cross-validation
    • Used for performance benchmarking

Google Colab Training Results

PrivacyGuard Banner

Feature Engineering

# 16 lexical features extracted from URLs
const featureDescriptions = [
  "1. length",
  "2. hostname_length",
  "3. path_length",
  "4. query_length",
  "5. num_dots",
  "6. num_hyphens",
  "7. num_at",
  "8. num_question_marks",
  "9. num_equals",
  "10. num_underscore",
  "11. num_percent",
  "12. num_slash",
  "13. has_https",
  "14. has_ip",
  "15. num_digits",
  "16. num_let_

๐ŸŽฎ Interactive Demo Scenarios

Scenario 1: Safe Browsing

Visit: https://www.google.com
Result: ๐ŸŸข Green status, no alerts
Popup: Shows low risk score, clean analysis

Scenario 2: Suspicious HTTP Site

Visit: http://localhost:8000/college.html
Result: ๐ŸŸก Yellow corner alert appears
Action: Choose "Trust", "Block", or "Details"

Scenario 3: Homograph Attack

Visit: http://www.xn--pypal-4ve.com/ (fake PayPal)
Result: ๐Ÿ”ด Full-page red warning blocks access
Reason: Punycode homograph detection triggered

Scenario 4: ML-Detected Phishing

Visit: Your phishing.html test file
Result: ๐Ÿ”ด Red alert based on ML model + heuristics
Details: High-risk features identified and scored

๐Ÿ“ˆ Recent Updates & Improvements

v1.0.0 - Latest Release

  • โœ… Fixed ML Score Inversion: Corrected risk calculation bug
  • โœ… Enhanced Shadow DOM: Complete CSS isolation for alerts
  • โœ… Improved Homograph Detection: Better Unicode analysis
  • โœ… Performance Optimization: Faster model loading and inference
  • โœ… Enhanced P2P Mock: More realistic community simulation

Key Bug Fixes

  • Alert positioning issues on responsive sites
  • Memory leaks in model tensor operations
  • Edge cases in URL feature extraction
  • Improved error handling for malformed URLs

๐Ÿ›ฃ๏ธ Roadmap & Future Features

๐Ÿ”„ Next Release (v1.1)

  • Enhanced ML Model: Retrain with larger, more diverse dataset
  • Dark Mode Support: UI themes for better user experience
  • Advanced Analytics: Detailed threat statistics and trends
  • Export/Import Settings: Backup and sync user preferences

โš ๏ธ Known Limitations

Technical Constraints

  • Model Size: ~2MB addition to extension size
  • Feature Scope: Currently limited to lexical URL features
  • Browser Support: Optimized for Chromium-based browsers
  • P2P System: Currently mock implementation using local storage

Detection Limitations

  • Sophisticated Attacks: May miss advanced social engineering
  • Content-based Phishing: Limited analysis of page content beyond forms
  • Zero-day Threats: Effectiveness depends on training data coverage
  • Language Support: Homograph detection primarily covers Latin scripts

User Experience

  • False Positives: ~5.8% rate may require manual whitelisting
  • Alert Fatigue: Balance between security and usability
  • Performance: Slight delays possible on resource-constrained devices

๐Ÿค Contributing

We welcome contributions! Here's how to get involved:

๐Ÿ› Report Issues

  • Use GitHub Issues for bugs and feature requests
  • Include browser version, extension version, and reproduction steps
  • Screenshots of alerts/console output are helpful

๐Ÿ’ป Code Contributions

# Fork the repository
git clone https://github.com/yourusername/PrivacyGuard.git
cd PrivacyGuard

# Create feature branch
git checkout -b feature/your-feature-name

# Make changes and test thoroughly
# Submit pull request with detailed description

๐Ÿ“š Documentation

  • Improve README sections
  • Add code comments and examples
  • Create user guides and tutorials

๐Ÿ“„ License & Credits

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Datasets: ebubekirbbr/dephides and Tranco
  • ML Framework: TensorFlow.js team for browser-based ML capabilities
  • UI Framework: Minimal custom CSS with Shadow DOM for isolation
  • Community: Beta testers and security researchers who provided feedback

๐Ÿ“ž Support & Contact

๐Ÿ†˜ Need Help?

๐Ÿ“ง Contact


โญ Star this repository if PrivacyGuard helps keep you safe online! โญ

Built with ๐Ÿ’™ for safer browsing | Protecting privacy while fighting phishing

[๐Ÿ› Report Issues

About

Smart Anti Phishing Extension

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published