Skip to content

banchan01/Ptector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ptector

Ptector is a URL-based anti-phishing Chrome extension developed as a CS204 - interconnection of CPS course project at SMU.
It detects phishing websites in real time using a ML model and provides immediate feedback through a browser extension.

default.mp4

Features

  • Real-time URL analysis
  • Machine learning-based phishing detection
  • Detailed analysis popup

Safe Website

Phishing Detected

Architecture

The project consists of three main components:

  1. Chrome Extension

    • Content scripts for webpage interaction
    • Background service worker
    • Popup interface for results display
  2. Flask Backend

    • REST API for URL analysis
    • Integration with ML model
    • Page rank and Google index checking
  3. Machine Learning

  • CNN (Raw URL-based) image Initially trained a CNN model directly on raw URL strings, achieving approximately 92% accuracy.
    This approach captured character-level patterns but lacked interpretability and flexibility.

  • DNN (Feature-based) image Switched to a feature-based DNN after identifying the need for explicit learning of URL characteristics.
    This improved performance to approximately 95% accuracy by leveraging structured URL features.

  • Random Forest (Final Model) model-rf-5 Due to the limited dataset size and model complexity, a Random Forest model was selected as the final approach.
    Applied feature importance-based feature selection, achieving 94% accuracy with significantly faster inference, making it more suitable for real-time browser usage.

Installation

  1. Install Python dependencies:
  • Run cd flask-backend to navigate to the backend directory.
  • Set-up python virtual environment py -3.11 -m venv .venv
  • Activate the virtual environment with source .venv/bin/activate
  • Install dependencies with python -m pip install -r requirements.txt
  1. Set up environment variables:
  • Create .env file in flask-backend directory
  • Copy the code and replace
    # API Keys
    OPENPAGE_API_KEY=<your_openpage_api_key>
    
    # Google Index API Key
    GOOGLE_API_KEY=<your_google_api_key>
    GOOGLE_SEARCH_ENGINE_ID=<your_google_search_engine_id>
    
  1. Steps to get required API keys
  • OpenPage Rank API

  • Google API Key

    • Go to Google Cloud Console : https://console.cloud.google.com/
    • Create new project/Select existing project
    • Go to "APIs & Services" > "Library"
    • Enable "Custom Search API"
    • Go to "Credentials"
    • Create API Key (Create Credentials > API Key)
    • Replace <your_google_api_key> in .env with your actual API key
  • Google Search Engine ID

    • Go to Programmable Search Engine : https://programmablesearchengine.google.com/
    • Click "Create Search Engine"
    • Configure settings:
      • Set search engine name
      • Use "*" for all sites
      • Click "Create" to finalize the setup
      • Copy Search Engine ID and replace <your_google_search_engine_id> in .env
  1. Load the Chrome extension:
  • Open Chrome extensions page
  • Enable Developer mode
  • Click "Load unpacked"
  • Select the /chromeExtension directory

Usage

  1. Start the Flask backend:
    • Run cd flask-backend to navigate to the backend directory.
    • Start the app with python app.py.
    • Enjoy the extension!

Tech Stack

Frontend

HTML5 CSS3 JavaScript

Backend

Python Flask

Machine Learning

scikit-learn NumPy Pandas

APIs

OpenPageRank Google Custom Search

License

MIT License

Copyright (c) 2024 banchan_01

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A Chrome extension for detecting phishing URLs using ML model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors