trishab0807-lgtm/home-network-scanner

GitHub: trishab0807-lgtm/home-network-scanner

纯 Python 实现的家庭网络漏洞扫描器,提供主机发现、端口扫描、CVE 匹配、风险评分、持续监控和多格式报告生成。

Stars: 0 | Forks: 0

# 🏠 家庭网络漏洞扫描器 **发现 · 评估 · 监控 · 报告** ![Python](https://img.shields.io/badge/Python-3.8+-3776AB?style=flat-square&logo=python&logoColor=white) ![Platform](https://img.shields.io/badge/Platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey?style=flat-square) ![CVEs](https://img.shields.io/badge/CVEs_Covered-15+-red?style=flat-square) ![Tests](https://img.shields.io/badge/Tests-20%20Passing-brightgreen?style=flat-square) ![License](https://img.shields.io/badge/License-MIT-green?style=flat-square) ![Version](https://img.shields.io/badge/Version-2.1.0-blue?style=flat-square) **扫描您的家庭网络以查找开放端口,识别易受攻击的服务,匹配真实的 CVE 和 CVSS 评分,持续监控未经授权的设备,并生成专业的 HTML/JSON/CSV 报告 —— 所有这些均通过纯 Python 实现,核心扫描零外部依赖。**
## 📋 目录 - [概述](#-overview) - [功能](#-features) - [技术栈](#-tech-stack) - [快速开始](#-quick-start) - [用法](#-usage) - [截图](#-screenshots) - [CVE 覆盖范围](#-cve-coverage) - [项目结构](#-project-structure) - [测试](#-testing) - [输出示例](#-sample-output) - [文档](#-documentation) - [未来规划](#-future-improvements) - [免责声明](#-disclaimer) ## 🎯 概述 **家庭网络漏洞扫描器 (HNS)** 是一款专为家庭网络所有者和网络安全学生设计的 Python 安全工具。大多数家庭网络存在启用了 Telnet 的路由器、暴露出 BlueKeep/EternalBlue 漏洞的 Windows PC,以及使用默认凭据的 IoT 设备 —— 却对这些风险毫无可见性。 HNS 通过一条命令解决此问题:发现每一台设备,扫描关键端口,匹配真实的 CVE,对每台主机的风险进行评分,并生成一份任何人都能理解并据此采取行动的彩色 HTML 报告。 ## ✨ 功能 | 功能 | 描述 | |---|---| | 🔍 **主机发现** | 多线程 TCP 发现 —— 约 5 秒内完成 /24 网络扫描 | | 🚪 **端口扫描** | 每台主机 30 个关键端口 —— 30 个并发线程 | | 🔖 **Banner 抓取** | 捕获 HTTP/SSH/FTP banner 以进行服务版本检测 | | 🛡️ **CVE 匹配** | 包含来自 NVD 的 15+ 个带有 CVSS 评分的真实 CVE | | 📊 **HTML 报告** | 暗色主题可视化报告 —— 可在任何浏览器中打开 | | 📄 **JSON + CSV** | 机器可读的导出文件,用于进一步分析 | | ⚡ **风险评分** | 单主机评分 (0-100) + 严重/高/中/低级别 | | 🔔 **持续监控** | 针对新设备、端口更改、主机离线发出告警 | | 🔎 **CVE 查询工具** | 通过端口号或 CVE ID 进行 CLI 查询 | | 🧪 **单元测试** | 20 个 pytest 测试 —— 87% 的覆盖率 | ## 🛠️ 技术栈 - **语言:** Python 3.8+ —— 所有核心扫描均使用标准库 - **并发:** `concurrent.futures.ThreadPoolExecutor` - **网络:** `socket`, `ipaddress`, `subprocess` - **报告:** 自定义 HTML/CSS, `json`, `csv` - **测试:** `pytest` - **无需 Nmap** —— 纯 Python TCP 扫描 ## ⚡ 快速开始 ``` git clone https://github.com/trishab0807-lgtm/home-network-scanner.git cd home-network-scanner pip install -r requirements.txt # 查找你的网络范围:ip route | grep src (Linux) # ipconfig (Windows) python3 scripts/scanner.py --network 192.168.1.0/24 # 打开:reports/scan_report_TIMESTAMP.html ``` ## 🚀 用法 ### 主扫描器 ``` # 整个家庭网络扫描 python3 scripts/scanner.py --network 192.168.1.0/24 # 单个设备 python3 scripts/scanner.py --target 192.168.1.1 # 自定义端口 python3 scripts/scanner.py --network 192.168.1.0/24 --ports 22,80,443,445,3389 # 仅 JSON python3 scripts/scanner.py --network 192.168.1.0/24 --format json ``` ### 持续监控 ``` # 每 5 分钟监控一次 — 有新设备时发出警报 python3 scripts/network_monitor.py --network 192.168.1.0/24 # 每 60 秒检查一次 python3 scripts/network_monitor.py --network 192.168.1.0/24 --interval 60 # 实时查看警报 tail -f logs/alerts.log ``` ### CVE 查询 ``` python3 scripts/cve_lookup.py --cve CVE-2017-0144 # EternalBlue details python3 scripts/cve_lookup.py --port 445 # CVEs for SMB python3 scripts/cve_lookup.py --list # All 15 CVEs ``` ### 运行测试 ``` pytest tests/ -v ``` ## 📸 截图 ### 完整网络扫描 —— 终端输出 ![Scan Output](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/8f8ac53937014212.png) ### HTML 报告仪表板 ![HTML Report](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/69ba82e3b2014216.png) ### 持续监控 —— 新设备告警 ![Monitor](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/1046e5b198014221.png) ### CVE 查询工具 ![CVE Lookup](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/96c46883f7014227.png) ### 告警日志 + 设备调查 ![Alerts](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/a2e31207fc014232.png) ### 所有主机汇总表 ![Hosts Table](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/1fa87901c4014238.png) ### 单元测试 —— 20 个通过 ![Tests](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/8bc0b3d053014243.png) ### 报告格式 —— HTML + JSON + CSV ![Reports](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/9b393f98f8014248.png) ### 项目结构 + 帮助菜单 ![Structure](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/cb7d68c22f014254.png) ## 🚨 CVE 覆盖范围 | CVE | 服务 | 端口 | CVSS | 严重程度 | |---|---|---|---|---| | CVE-2017-0144 | EternalBlue (SMB) | 445 | 9.3 | 🔴 严重 | | CVE-2019-0708 | BlueKeep (RDP) | 3389 | 9.8 | 🔴 严重 | | CVE-2022-0543 | Redis Lua Escape | 6379 | 10.0 | 🔴 严重 | | CVE-2021-41773 | Apache Path Traversal | 80 | 9.8 | 🔴 严重 | | CVE-2020-1350 | SIGRed (DNS) | 53 | 10.0 | 🔴 严重 | | CVE-1999-0619 | Telnet Cleartext | 23 | 9.8 | 🔴 严重 | | CVE-2020-7247 | OpenSMTPD RCE | 25 | 9.8 | 🔴 严重 | | CVE-2021-34473 | ProxyShell (Exchange) | 8443 | 9.8 | 🔴 严重 | | CVE-2021-3449 | OpenSSL NULL deref | 443 | 7.4 | 🟠 高危 | | CVE-2020-12695 | UPnP CallStranger | 1900 | 7.5 | 🟠 高危 | | CVE-2019-15681 | VNC Memory Leak | 5900 | 7.5 | 🟠 高危 | | CVE-2020-9484 | Tomcat Deserial RCE | 8080 | 7.5 | 🟠 高危 | | CVE-2018-15919 | OpenSSH User Enum | 22 | 5.3 | 🟡 中危 | | CVE-2019-2389 | MongoDB Log Inject | 27017 | 6.5 | 🟡 中危 | | CVE-2013-1899 | PostgreSQL Crash | 5432 | 6.8 | 🟡 中危 | ## 📁 项目结构 ``` home-network-scanner/ │ ├── 📄 README.md ← You are here ├── 📄 requirements.txt ├── 📄 LICENSE / .gitignore ├── 📄 CHANGELOG.md / CONTRIBUTING.md / SECURITY.md │ ├── 📄 HomeNetworkScanner_Complete_Report.docx ← Full project Word document │ ├── scripts/ │ ├── 🐍 scanner.py ← Main vulnerability scanner (350 lines) │ ├── 🐍 network_monitor.py ← Continuous monitoring daemon │ └── 🐍 cve_lookup.py ← CVE lookup utility │ ├── configs/ │ └── ⚙️ scanner_config.ini ← All scanner settings │ ├── tests/ │ └── 🧪 test_scanner.py ← 20 pytest unit tests │ ├── docs/ │ ├── 📖 installation_guide.md │ ├── 📖 usage_guide.md │ └── 📖 architecture.md │ ├── screenshots/ ← 9 screenshots (PNG) │ ├── 01_scan_output.png │ ├── 02_html_report.png │ ├── 03_monitor_running.png │ ├── 04_cve_lookup.png │ ├── 05_alerts_and_investigation.png │ ├── 06_all_hosts_table.png │ ├── 07_unit_tests.png │ ├── 08_report_formats.png │ └── 09_project_structure.png │ ├── sample-outputs/ │ └── 📋 sample_scan_report.json │ └── logs/ └── 📋 alerts.log ← Sample monitoring alert log ``` ## 🧪 测试 ``` pytest tests/ -v # 预期:20 passed in ~0.3s ``` 测试类: `TestGuessService` | `TestCalculateRisk` | `TestVulnDB` | `TestCommonPorts` ## 📊 输出示例 查看 [`sample-outputs/sample_scan_report.json`](sample-outputs/sample_scan_report.json) 获取涵盖 5 个家庭网络设备的完整 JSON 扫描示例。 ## 📚 文档 | 文档 | 描述 | |---|---| | [`docs/installation_guide.md`](docs/installation_guide.md) | Windows/Linux/macOS 的逐步设置指南 | | [`docs/usage_guide.md`](docs/usage_guide.md) | 所有命令、参数和工作流 | | [`docs/architecture.md`](docs/architecture.md) | 系统设计、线程模型、数据流 | | [`HomeNetworkScanner_Complete_Report.docx`](HomeNetworkScanner_Complete_Report.docx) | 包含截图的完整 25 页项目报告 | ## 🔮 未来改进 - [ ] UDP 扫描 (DNS, SNMP, NTP) - [ ] 通过 TTL 分析进行 OS 指纹识别 - [ ] 集成 NVD API 以进行实时 CVE 查询 - [ ] 从持续监控器发送 Telegram/邮件告警 - [ ] Flask 网页仪表板 - [ ] Docker 容器部署 - [ ] 默认凭据测试模块 ## 💼 展示技能 | 技能 | 证明 | |---|---| | Python 网络 | `socket`, `ipaddress`, `subprocess` | | 多线程 | `ThreadPoolExecutor` —— 50+30 个并发工作线程 | | 安全知识 | 15 个 CVE,CVSS 评分,修复指导 | | 工具开发 | 3 个带 argparse 和配置文件的 CLI 工具 | | 报告生成 | HTML/CSS 报告,JSON,CSV | | 测试 | pytest —— 20 个测试,87% 的覆盖率 | | 文档编写 | README,架构文档,使用指南,Word 报告 | ## ⚠️ 免责声明 仅供在您个人拥有的网络上获得**授权使用**。根据 IT Act 2000(印度)、CFAA(美国)以及全球同等法律,未经授权的扫描是非法行为。
Bandari Trisha 构建 | 网络安全作品集 | ⭐ 如果有帮助请点 Star
标签:Claude, CVE检测, Facebook API, Python, 云存储安全, 安全规则引擎, 插件系统, 无后门, 服务器安全, 网络扫描, 逆向工具