BlackPanda999/phishing-url-detector

GitHub: BlackPanda999/phishing-url-detector

结合随机森林机器学习与规则启发式的钓鱼 URL 检测器,通过多维特征提取与风险评分帮助用户快速识别可疑链接。

Stars: 0 | Forks: 0

# 🛡️ AI 驱动的钓鱼 URL 检测器
![Python](https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white) ![AI](https://img.shields.io/badge/AI-ML-FF6F00?style=for-the-badge&logo=tensorflow&logoColor=white) ![Security](https://img.shields.io/badge/Cybersecurity-Defensive-00758F?style=for-the-badge) ![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge) **一款结合机器学习与基于规则启发式算法的 AI 增强型钓鱼 URL 检测工具**
## 📋 概述 本项目通过分析 25+ 项 URL 特征并结合两种检测方法来识别钓鱼 URL: 1. **基于规则的启发式算法** — 检查已知的钓鱼模式(可疑的 TLD、IP 地址、短网址服务、品牌冒充等) 2. **AI/ML 检测** — 基于钓鱼/合法 URL 模式训练的 Random Forest 分类器 该工具会生成一个风险评分(0.0–1.0),并将 URL 分类为 `LEGITIMATE`(合法)、`SUSPICIOUS`(可疑)或 `PHISHING`(钓鱼),同时提供详细的原因分析。 ## 🎯 功能 | 功能 | 描述 | |---------|-------------| | 🔍 **25+ 项 URL 特征** | 从 URL 中提取结构、词法和语义特征 | | 🤖 **AI 检测** | 采用 Random Forest ML 模型进行基于模式的钓鱼检测 | | 📐 **基于规则的引擎** | 包含 15+ 条针对已知钓鱼指标的启发式规则 | | 📊 **风险评分** | 结合 AI 与基于规则结果的加权综合评分 | | 📝 **详细报告** | 提供人类可读的分析结果及风险原因 | | 📦 **批量分析** | 支持一次性分析多个 URL 并生成摘要报告 | | 🔌 **双模式** | 无论是否安装 ML 库均可运行(无 ML 库时回退至规则模式) | | 🛡️ **防御工具** | 专为安全教育和防御设计,而非用于攻击 | ## 🧠 检测方法 ### 特征提取(25+ 项特征) ``` URL Structure: length, hostname, path, query lengths Character Analysis: dots, hyphens, underscores, slashes, @, ?, &, = Digit Analysis: digit count, digit-to-length ratio Network Check: IP address detection, port detection TLD Analysis: suspicious TLD detection (.tk, .ml, .cf, .xyz, etc.) Security: HTTPS/HTTP check, shortening service detection Semantic: suspicious keywords, brand name impersonation Encoding: URL-encoded characters, hex characters ``` ### AI 模型 - **算法**:Random Forest Classifier(50 棵树,最大深度 10) - **训练**:合成的钓鱼/合法 URL 模式 - **集成**:60% ML 评分 + 40% 基于规则的评分 ## 📦 安装 ``` git clone https://github.com/BlackPanda999/phishing-url-detector.git cd phishing-url-detector pip install -r requirements.txt ``` ## 🚀 用法 ### 单个 URL 分析 ``` python src/detector.py "https://suspicious-site.xyz/login?verify=123" ``` ### 多个 URL 分析 ``` python src/detector.py "https://google.com" "http://paypal-login.tk/verify" "https://github.com" ``` ### 演示模式(无参数) ``` python src/detector.py ``` ### Python API ``` from src.detector import AIPhishingDetector detector = AIPhishingDetector() result = detector.analyze("https://suspicious-site.xyz/login") print(result['verdict']) # PHISHING / SUSPICIOUS / LEGITIMATE print(result['risk_score']) # 0.0 - 1.0 print(result['reasons']) # List of risk indicators ``` ### 批量分析 ``` from src.detector import BatchAnalyzer analyzer = BatchAnalyzer(use_ai=True) report = analyzer.generate_report([ "https://google.com", "http://paypal-login.tk/verify", "https://github.com/BlackPanda999" ]) print(report) ``` ## 📊 输出示例 ``` ============================================================ AI-Powered Phishing URL Detection Report Generated: 2026-07-31T00:20:00 ============================================================ Total URLs analyzed: 6 Phishing detected: 2 Suspicious: 1 Legitimate: 3 Average risk score: 0.342 ------------------------------------------------------------ [OK] [LEGITIMATE] Risk: 0.05 - https://www.google.com/search?q=cybersecurity > No significant risk indicators found [!] [PHISHING] Risk: 0.85 - http://paypal-secure-login.xyz/account/verify?id=12345 > Uses a suspicious TLD commonly associated with phishing > Contains 3 suspicious keywords > Contains brand name in suspicious position ============================================================ ``` ## 🏗️ 项目结构 ``` phishing-url-detector/ ├── src/ │ └── detector.py # Main detection engine ├── tests/ │ └── test_detector.py # Unit tests ├── docs/ │ └── FEATURES.md # Feature documentation ├── requirements.txt # Python dependencies ├── LICENSE # MIT License └── README.md # This file ``` ## 🛡️ 安全与道德准则 本工具仅专为**防御性网络安全目的**而设计: - ✅ 教育用途 — 了解钓鱼指标 - ✅ 安全研究 — 分析 URL 模式 - ✅ 防御团队 — 在安全 pipeline 中筛查 URL - ❌ 不得用于创建钓鱼活动 - ❌ 不得用于攻击或针对个人 在生产环境中测试任何 URL 之前,请务必获取适当的授权。 ## 👨‍💻 作者 **Osama Khan** — [BlackPanda999](https://github.com/BlackPanda999) - 📧 cyberkhan554433@gmail.com - 🔗 [LinkedIn](https://linkedin.com/in/osamakhan44) - 🛡️ 持有 CompTIA Security+ | PenTest+ 认证 ## 📜 许可证 MIT 许可证 — 详情请参阅 [LICENSE](LICENSE)。
标签:Apex, URL检测, 云计算, 机器学习, 网络安全, 规则引擎, 逆向工具, 钓鱼防护, 随机森林, 隐私保护