Skip to main content

A CLI tool to detect phishing URLs using machine learning

Project description

LinkSentry

A command-line tool to detect phishing URLs using machine learning.

Features

  • 🔍 Single URL Check - Quickly analyze any URL for phishing indicators
  • 📁 Batch Processing - Check multiple URLs from a file
  • 🤖 ML-Powered - Uses Random Forest trained on 88,000+ URLs with 111 features
  • 🌐 Optional Deep Analysis - DNS, WHOIS, and SSL lookups with --full flag
  • 📊 Multiple Output Formats - Plain text or JSON output

Installation

pip install linksentry

For full feature extraction (DNS/WHOIS lookups):

pip install linksentry[full]

Usage

Check a Single URL

# Basic check
linksentry check "https://suspicious-site.xyz/login"

# With full feature extraction (DNS/WHOIS)
linksentry check "https://example.com" --full

# Output as JSON
linksentry check "https://example.com" --json

Check Multiple URLs

# Check URLs from a file (one URL per line)
linksentry check-file urls.txt

# Save results to CSV
linksentry check-file urls.txt --output results.csv

# With JSON output
linksentry check-file urls.txt --json

Train Custom Model

# Train with your own dataset
linksentry train --data your_dataset.csv

# Specify output path
linksentry train --data dataset.csv --output custom_model.pkl

Show Model Info

linksentry info
linksentry info --json

Example Output

$ linksentry check "https://secure-login.suspicious-domain.xyz/verify"

⚠️  PHISHING
URL: https://secure-login.suspicious-domain.xyz/verify
Confidence: 94.2%
P(Legitimate): 0.0583
P(Phishing): 0.9417
$ linksentry check "https://github.com/user/repo"

✅ LEGITIMATE
URL: https://github.com/user/repo
Confidence: 98.7%
P(Legitimate): 0.9871
P(Phishing): 0.0129

Exit Codes

Code Meaning
0 URL is legitimate
1 URL is phishing (or at least one phishing URL in batch)
2 Error occurred

This allows integration with shell scripts:

if linksentry check "$URL" > /dev/null 2>&1; then
    echo "URL is safe"
else
    echo "URL may be phishing!"
fi

Feature Extraction

LinkSentry extracts 111 features from URLs:

Category Features Description
URL Characters 18 Count of special characters in full URL
Domain 21 Domain length, characters, IP check
Directory 18 Path analysis
File 17 Filename analysis
Parameters 20 Query string analysis
External* 17 DNS, WHOIS, SSL, response time

*External features require --full flag and linksentry[full] installation.

Dataset Format

For training custom models, your CSV should have:

  • 111 feature columns (see feature list above)
  • 1 target column named phishing (0 = legitimate, 1 = phishing)

Python API

from linksentry import predict_url, extract_features

# Predict a URL
result = predict_url("https://example.com")
print(result['label'])  # 'legitimate' or 'phishing'
print(result['confidence'])  # 0.0 to 1.0

# Extract features only
features = extract_features("https://example.com", full=True)

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linksentry-0.1.0.tar.gz (13.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linksentry-0.1.0-py3-none-any.whl (13.7 MB view details)

Uploaded Python 3

File details

Details for the file linksentry-0.1.0.tar.gz.

File metadata

  • Download URL: linksentry-0.1.0.tar.gz
  • Upload date:
  • Size: 13.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for linksentry-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a74d09e7418eca5299ead1cc4aaa8019181bea63e0d2465938b420485cb0fd3
MD5 76717dfaa5cab2894977b0c64569074b
BLAKE2b-256 04d0844125576d984c1050492bf25a358a61edd018929595ebb08921f11b02bf

See more details on using hashes here.

File details

Details for the file linksentry-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: linksentry-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for linksentry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5b04687f8195bd049c8c0b1289a1b0c81656d44c0e25f776930e8c90928148c
MD5 ecee91bfe27567e7cd0b812386523777
BLAKE2b-256 b66146e8416f51754a6d7555f7422430f584ecd25620ab89e0febe21058698ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page