SUBRAHMANYA2726/vulnerability-scanner-python

GitHub: SUBRAHMANYA2726/vulnerability-scanner-python

一款基于 Python 构建的非侵入式网络安全扫描器,通过端口扫描、安全标头检查和 SSL 证书验证生成安全评估报告。

Stars: 0 | Forks: 0

SecureScan AI Banner # SecureScan AI - 高级漏洞扫描器 **一款使用 Python 构建的专业、模块化且非侵入式的教育性网络安全工具。** [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![GitHub stars](https://img.shields.io/github/stars/SUBRAHMANYA2726/vulnerability-scanner-python.svg?style=social&label=Star)](https://github.com/SUBRAHMANYA2726/vulnerability-scanner-python) [![GitHub forks](https://img.shields.io/github/forks/SUBRAHMANYA2726/vulnerability-scanner-python.svg?style=social&label=Fork)](https://github.com/SUBRAHMANYA2726/vulnerability-scanner-python/fork) [![GitHub issues](https://img.shields.io/github/issues/SUBRAHMANYA2726/vulnerability-scanner-python.svg)](https://github.com/SUBRAHMANYA2726/vulnerability-scanner-python/issues) [![Last Commit](https://img.shields.io/github/last-commit/SUBRAHMANYA2726/vulnerability-scanner-python.svg)](https://github.com/SUBRAHMANYA2726/vulnerability-scanner-python/commits/main) [![Repo Size](https://img.shields.io/github/repo-size/SUBRAHMANYA2726/vulnerability-scanner-python.svg)](https://github.com/SUBRAHMANYA2726/vulnerability-scanner-python) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
## 📑 目录 - [项目概述](#-project-overview) - [功能](#-features) - [架构](#-architecture) - [目录结构](#-folder-structure) - [截图](#-screenshots) - [安装与依赖](#-installation) - [快速入门与使用](#-usage) - [输出示例](#-sample-outputs) - [模块说明](#-module-explanation) - [技术与性能](#-technologies--performance) - [路线图与未来改进](#-roadmap) - [社区(贡献、行为准则、安全)](#-community) - [常见问题](#-faq) - [免责声明与许可](#-disclaimer) - [作者与联系方式](#-author) ## 🔎 项目概述 **SecureScan AI** 是一款专为教育性安全评估设计的生产级开源漏洞扫描器。它完全基于**防御性和非侵入式**设计,可以分析 Web 服务器、评估 SSL/TLS 配置、枚举开放的 TCP 端口,并验证关键的 HTTP 安全标头,而绝不会发送恶意 payload 或对目标进行 exploit。 它基于智能风险分类引擎计算自动化的**安全评分(0-100)**,并生成高度精美且专业的报告仪表板。 ## ✨ 功能 - **多线程 TCP 端口扫描器**:由 Python 的 `ThreadPoolExecutor` 驱动的高度并发扫描引擎。 - **Banner 抓取**:安全地从开放端口提取服务标识 banner。 - **Web 安全分析器**:审查 8 种以上的现代安全标头(CSP、HSTS、XFO 等)。 - **SSL/TLS 验证**:直接通过 socket 提取 X.509 证书数据,包括精确的有效期和颁发者。 - **DNS 枚举**:自动检索 IPv4、IPv6 和反向 DNS (PTR) 记录。 - **丰富的报告导出**:生成视觉效果出色的 HTML 仪表板,以及 CSV、JSON 和 TXT 数据工件。 - **规则与评分引擎**:按严重程度(从信息到严重)动态分类漏洞。 ## 🏗 架构 ``` graph TD A[CLI Input / User] --> B(scanner.py - Orchestrator) B --> C[modules/dns_lookup.py] B --> D[modules/port_scanner.py] B --> E[modules/ssl_checker.py] B --> F[modules/headers.py] D --> G[modules/banner.py] C --> H((Aggregated Data)) D --> H E --> H F --> H H --> I[modules/scoring.py] I --> J[modules/reporting.py] J --> K{Final Reports: HTML, JSON, TXT, CSV} ``` ## 📁 目录结构 ``` SecureScan/ │ ├── scanner.py # Main CLI application ├── requirements.txt # Python dependencies ├── README.md # Project documentation ├── LICENSE # MIT License ├── CONTRIBUTING.md # Guidelines for open-source contributors ├── CODE_OF_CONDUCT.md # Community behavioral guidelines ├── SECURITY.md # Vulnerability disclosure policies ├── CHANGELOG.md # Version history │ ├── modules/ # Core Python Logic │ ├── banner.py │ ├── dns_lookup.py │ ├── headers.py │ ├── logger.py │ ├── port_scanner.py │ ├── reporting.py │ ├── scoring.py │ └── ssl_checker.py │ ├── .github/ # GitHub Actions and Templates │ ├── workflows/python.yml │ ├── ISSUE_TEMPLATE/ │ └── pull_request_template.md │ ├── tests/ # Automated Unit Tests ├── reports/ # Generated artifacts (HTML, CSV, etc.) └── docs/images/ # Markdown visual assets ``` ## 📸 截图 ### 项目仪表板 (HTML 报告) ![HTML 报告](https://raw.githubusercontent.com/SUBRAHMANYA2726/vulnerability-scanner-python/main/docs/images/html-report.png) ### CLI 执行 ![CLI 扫描](https://raw.githubusercontent.com/SUBRAHMANYA2726/vulnerability-scanner-python/main/docs/images/scan.png) ### 端口扫描与标头分析 ![端口扫描](https://raw.githubusercontent.com/SUBRAHMANYA2726/vulnerability-scanner-python/main/docs/images/port-scan.png) ## 🚀 安装 ### 依赖要求 - **Python 3.8+** - Git ### 快速入门 1. **克隆仓库:** git clone https://github.com/SUBRAHMANYA2726/vulnerability-scanner-python.git cd vulnerability-scanner-python/SecureScan 2. **安装依赖:** pip install -r requirements.txt 3. **运行你的第一次扫描:** python scanner.py --target example.com ## 💻 使用方法 ### CLI 参数 | 参数 | 类型 | 默认值 | 描述 | |----------|------|---------|-------------| | `--target` | `str` | `example.com` | 要扫描的域名或 IP 地址。 | | `--ports` | `str` | `常用端口` | 逗号分隔的端口或范围列表(例如:`80,443,1-1000`)。 | | `--timeout` | `float`| `2.0` | 连接超时时间(秒)。 | | `--threads` | `int` | `50` | 用于扫描的并发线程数。 | | `--output` | `str` | `reports/report`| 生成文件的输出前缀。 | ### CLI 示例 **基础扫描(默认扫描常用端口):** ``` python scanner.py --target scanme.nmap.org ``` **激进快速扫描(高线程数,低超时):** ``` python scanner.py --target example.com --ports 1-1000 --threads 100 --timeout 1.0 ``` ## 📄 输出示例 ### HTML 报告预览 生成的 `report.html` 使用内嵌的 CSS 来生成美观、响应式的暗色模式仪表板,突出显示满分 100 分的安全评分,并以颜色编码的表格展示漏洞。 ### TXT 报告示例 ``` SecureScan AI - Advanced Vulnerability Scanner Report ============================================================ Target: example.com Date: 2024-05-15 10:00:00 Overall Security Score: 52/100 ============================================================ FINDINGS: ------------------------------------------------------------ [HIGH] Missing Security Header: Content-Security-Policy Description: The HTTP response does not contain the 'content-security-policy' header. Remediation: Configure the web server to include the header in all responses. ``` ### JSON 报告示例 ``` { "target": "example.com", "score": 52, "findings": [ { "Title": "Missing Security Header: content-security-policy", "Severity": "High", "Description": "The HTTP response does not contain the header.", "Remediation": "Configure the web server to include the header." } ] } ``` ### CSV 报告示例 ``` Target,Title,Severity,Description,Remediation example.com,Missing Security Header: content-security-policy,High,The HTTP response does not contain the header.,Configure the web server to include the header. ``` ## 🛡 安全评分与风险等级 智能的 `scoring.py` 引擎会将基准分设为 100,并根据扫描结果扣分: - 🔴 **严重(-30 分)**:严重的配置错误(例如,极易受攻击且未打补丁的软件)。 - 🟠 **高危(-15 分)**:缺少主要安全标头(CSP、HSTS)或不安全的开放端口(Telnet/FTP)。 - 🟡 **中危(-5 分)**:缺少次要标头或即将过期的 SSL 证书。 - 🔵 **低危(-2 分)**:缺少信息性策略标头。 - 🟢 **信息(0 分)**:一般系统数据(例如,开放的标​​准 Web 端口)。 ## 🧩 模块说明 - **`scanner.py`**:CLI 编排器,通过 `tqdm` 处理参数解析和多线程进度,并通过 `colorama` 提供彩色终端用户体验。 - **`dns_lookup.py`**:与 Python 内置的 `socket` 和 `dnspython` 交互,以查询 A、AAAA 和 PTR 记录。 - **`ssl_checker.py`**:使用 Python 原生的 `ssl` 库封装标准 socket,并提取 X.509 字节数据进行验证。 - **`port_scanner.py`**:生成一个 socket 连接器的线程池,通过高效超时来确定端口的开放/关闭/过滤状态。 - **`headers.py`**:使用 `requests` 发起 HTTP `OPTIONS` 和 `GET` 请求,并解析字典以查找符合最佳实践的标头键。 ## ⚡ 使用的技术 - **语言**:Python 3.8+ - **核心库**:`socket`、`ssl`、`concurrent.futures`、`json`、`csv`、`argparse` - **外部依赖**:`requests`、`tqdm`、`colorama`、`dnspython` ## 📊 性能与限制 - **性能**:在使用 100 个并发线程的情况下,能够在 10 秒内扫描 1,000 个 TCP 端口。 - **限制**:作为一款非侵入式的教育工具,它*不会*发送 exploit 的 payload,也不会扫描深层的 CVE(例如 SQLi 或 XSS payload)。它完全依赖于被动的 banner 抓取和配置检查。 ## 🗺 路线图与未来改进 - [ ] 集成 **NIST NVD API**,基于抓取到的 banner 自动查找 CVE。 - [ ] 使用 `pdfkit` 添加 PDF 导出功能。 - [ ] 利用证书透明度日志进行子域名枚举。 - [ ] 支持认证扫描(提供 cookie/session token)。 ## ❓ 常见问题 **问:我可以使用这个工具攻击网站吗?** 答:不可以。SecureScan AI 严格作为审计和教育工具。它不具备任何攻击性 payload 功能。 **问:为什么我的端口扫描需要这么长时间?** 答:某些防火墙会静默丢弃数据包而不是拒绝它们,从而导致 socket 超时。如果你怀疑有严格的过滤规则,可以将 `--timeout` 调低至 `0.5` 或 `1.0`。 ## ⚠️ 免责声明 **仅供教育目的。** 本工具严格设计用于在你拥有明确授权的网络上进行安全、非侵入式的安全评估。开发者不承担任何责任,也不对因本程序造成的任何滥用或损坏负责。 ## 📜 许可证 本项目基于 MIT 许可证授权 - 有关详细信息,请参阅 [LICENSE](LICENSE) 文件。 ## 👤 作者 **Subrahmanya Manjunatha Bhat** *高级开源维护者与安全爱好者* **联系方式:** - GitHub: [@SUBRAHMANYA2726](https://github.com/SUBRAHMANYA2726) ### 致谢 - 感谢开源 Python 社区维护了为本工具提供动力的出色标准库。 - 感谢 Shields.io 提供的精美动态仓库徽章。 - 感谢 Contributor Covenant 制定了规范的社区准则。
标签:HTTP安全, Python, 加密, 域名侦查, 实时处理, 插件系统, 数据统计, 无后门, 服务器安全, 漏洞扫描器, 端口扫描, 逆向工具