Skip to content

A comprehensive phishing detection tool with advanced URL analysis, email header validation, domain similarity checks, and homograph attack detection. Features a risk scoring system, web interface, CLI, and REST APIโ€”ideal for personal protection, security training, and educational use.

License

Notifications You must be signed in to change notification settings

Hafizmuhammadajmallatif/phishing-detection-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Phishing Detection Tool

A comprehensive Python-based tool for detecting phishing attempts in URLs, emails, and domains. This tool uses multiple detection techniques to identify potential phishing attacks and provide actionable recommendations.

Features

๐Ÿ” URL Scanner

  • Suspicious Pattern Detection: Identifies keywords commonly used in phishing URLs
  • Homograph Attack Detection: Detects lookalike characters (e.g., 'paypaI' vs 'paypal')
  • Domain Age Analysis: Flags recently registered domains
  • SSL Certificate Validation: Checks for HTTPS usage
  • URL Shortener Detection: Identifies and expands shortened URLs
  • IP Address Detection: Flags direct IP usage instead of domain names
  • Path Complexity Analysis: Detects unnecessarily complex URL structures

๐Ÿ“ง Email Analyzer

  • Header Authentication: Validates SPF, DKIM, and DMARC records
  • Sender Verification: Compares From and Reply-To addresses
  • URL Extraction: Automatically scans email body for malicious links
  • Subject Line Analysis: Detects urgent/threatening language patterns

๐ŸŒ Domain Checker

  • Similarity Detection: Compares domains against commonly spoofed websites
  • Levenshtein Distance: Calculates mathematical similarity between domains
  • Visual Similarity: Identifies domains that look similar to legitimate ones

๐Ÿ“Š Batch Analysis

  • Process up to 50 URLs simultaneously
  • Generate summary reports with risk distribution
  • Export results for further analysis

Installation

  1. Clone the repository bash git clone https://github.com/yourusername/phishing-detection-tool.git cd phishing-detection-tool

  2. Create a virtual environment bash python -m venv venv

On Windows

venv\Scripts\activate

On macOS/Linux

source venv/bin/activate

  1. Install dependencies bash pip install -r requirements.txt

  2. Create required directories bash mkdir templates

  3. Move the HTML file to templates directory bash

Save the HTML content as templates/index.html

Project Structure

phishing-detection-tool/ โ”‚ โ”œโ”€โ”€ phishing_detector.py # Core detection engine โ”œโ”€โ”€ app.py # Flask web application โ”œโ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ templates/ โ”‚ โ””โ”€โ”€ index.html # Web interface โ””โ”€โ”€ README.md # This file

Usage

Running the Web Interface

  1. Start the Flask application bash python app.py

  2. Open your browser Navigate to http://localhost:5000

  3. Choose a detection method

  • URL Scanner: Analyze individual URLs
  • Email Analyzer: Check email headers and content
  • Domain Checker: Verify domain legitimacy
  • Batch Analysis: Process multiple URLs

Using as a Python Module

python from phishing_detector import PhishingDetector

Initialize detector

detector = PhishingDetector()

Analyze a URL

result = detector.analyze_url("http://amaz0n.com/verify-account") print(f"Risk Level: {result['risk_level']}") print(f"Risk Score: {result['risk_score']}") print(f"Risk Factors: {result['risk_factors']}")

Check domain similarity

similar = detector.check_domain_similarity("amaz0n.com") for match in similar: print(f"Similar to {match['legitimate_domain']}: {match['similarity_score']}")

Analyze email headers

headers = { "From": "[email protected]", "Reply-To": "[email protected]", "Subject": "Urgent: Verify your account" } email_result = detector.analyze_email_headers(headers) print(f"Email Risk: {email_result['risk_level']}")

API Endpoints

POST /analyze_url

Analyzes a single URL for phishing indicators.

Request: json { "url": "https://example.com" }

Response: json { "url": "https://example.com", "risk_level": "LOW", "risk_score": 0.15, "risk_factors": ["Not using HTTPS"], "recommendations": ["Always use HTTPS for sensitive data"] }

POST /analyze_email

Analyzes email headers and body content.

Request: json { "headers": { "From": "[email protected]", "Subject": "Test Email" }, "body": "Email content with https://link.com" }

POST /check_domain

Checks domain similarity to known legitimate sites.

Request: json { "domain": "amaz0n.com" }

POST /batch_analyze

Analyzes multiple URLs in a single request.

Request: json { "urls": [ "https://example1.com", "https://example2.com" ] }

Risk Scoring System

The tool uses a weighted scoring system to calculate risk:

Factor Weight Description
URL Length 0.10 Unusually long URLs (>75 chars)
Suspicious Keywords 0.15 Contains phishing-related words
Subdomain Count 0.10 Excessive subdomains (>2)
HTTPS Missing 0.20 Not using secure protocol
IP Address 0.25 Uses IP instead of domain
URL Shortener 0.15 Uses URL shortening service
Homograph Attack 0.20 Contains lookalike characters
Recent Domain 0.15 Registered within 30 days
Suspicious TLD 0.10 Uses high-risk TLDs
Path Complexity 0.05 Complex URL structure

Risk Levels

  • LOW (0-20%): Minimal risk indicators
  • MEDIUM (20-50%): Some suspicious characteristics
  • HIGH (50-80%): Multiple risk factors present
  • CRITICAL (80-100%): Strong phishing indicators

Security Considerations

  1. Privacy: This tool does not store or log analyzed URLs or emails
  2. Network Requests: URL expansion and domain lookups require internet access
  3. Rate Limiting: Implement rate limiting in production to prevent abuse
  4. HTTPS: Always use HTTPS when deploying the web interface

Common Phishing Indicators

URLs to Watch For

  • Misspelled domain names (e.g., "arnazon" instead of "amazon")
  • Excessive subdomains (e.g., "amazon.security.account-verify.com")
  • IP addresses instead of domain names
  • Suspicious TLDs (.tk, .ml, .ga)
  • URL shorteners hiding the real destination

Email Red Flags

  • Urgent language ("Act now!", "Account will be suspended")
  • Generic greetings ("Dear customer" instead of your name)
  • Mismatched sender addresses
  • Poor grammar or spelling
  • Requests for sensitive information

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

Future Enhancements

  • Machine learning model for improved detection
  • Browser extension for real-time protection
  • Integration with threat intelligence feeds
  • Mobile app development
  • API rate limiting and authentication
  • Database for storing analysis history

License

This project is licensed under the MIT License. Use responsibly and ethically.

Disclaimer

This tool is for educational and defensive purposes only. Always verify suspicious communications through official channels. The tool provides risk assessments but cannot guarantee 100% accuracy in detecting all phishing attempts.

Ethical Usage

This tool should only be used for:

  • Personal protection against phishing
  • Educational purposes
  • Security awareness training
  • Authorized security assessments

Never use this tool to:

  • Create phishing campaigns
  • Bypass security measures
  • Conduct unauthorized testing

Support

For questions or support, please open an issue on GitHub or contact the maintainers.

About

A comprehensive phishing detection tool with advanced URL analysis, email header validation, domain similarity checks, and homograph attack detection. Features a risk scoring system, web interface, CLI, and REST APIโ€”ideal for personal protection, security training, and educational use.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published