YoussefTouba/network-security-scanner

GitHub: YoussefTouba/network-security-scanner

一款基于 Python 标准库、零依赖的命令行工具,用于检查网站的 HTTP 安全标头、SSL 证书、开放端口和 DNS 信息。

Stars: 0 | Forks: 0

# 网络安全扫描器 🔒 [![Python](https://img.shields.io/badge/Python-3.8%2B-blue)](https://python.org) [![License](https://img.shields.io/badge/License-MIT-green)](LICENSE) 一款强大的 CLI 工具,可直接在终端中检查 HTTP 安全标头、SSL/TLS 证书、开放端口和 DNS 信息。 基于**零外部依赖**构建(仅使用 Python stdlib)。 ## 功能 | 功能 | 描述 | |---------|-------------| | **📋 HTTP 安全标头** | 检查 8 个关键标头:HSTS, X-Frame-Options, CSP, X-Content-Type-Options, X-XSS-Protection, Referrer-Policy, Permissions-Policy, Cache-Control | | **🔐 SSL/TLS 检查** | 验证证书:过期时间、签发者、SANs、剩余天数 | | **🚪 端口扫描** | 扫描 19 个常见端口(HTTP, SSH, MySQL, Redis 等) | | **🌐 DNS 信息** | 解析 IPv4、IPv6 和 FQDN | | **📄 多种输出格式** | 控制台(人类可读)、JSON、CSV、HTML 报告 | | **📂 批量扫描** | 从文件扫描多个 URL | | **🐍 零依赖** | 仅使用 Python 标准库 — 无需 pip install | ## 安装 ``` # Clone 该 repo git clone https://github.com/YoussefTouba/network-security-scanner.git cd network-security-scanner # 使其可执行(可选) chmod +x security_scanner.py ``` 就是这样。无需 `pip install`。无需 virtualenv。无需 requirements.txt。 ## 使用方法 ### 快速扫描(单个 URL) ``` python3 security_scanner.py yousseftouba.com ``` ### 完整扫描(SSL + 端口 + DNS) ``` python3 security_scanner.py example.com --ssl --ports --dns ``` ### 详细模式(显示标头值) ``` python3 security_scanner.py example.com --ssl --verbose ``` ### 批量扫描(从文件) ``` python3 security_scanner.py -f urls.txt --ssl --ports --dns ``` ### 导出为 JSON ``` python3 security_scanner.py example.com --ssl --json ``` ### 导出为 CSV ``` python3 security_scanner.py example.com --csv -o results.csv ``` ### 生成 HTML 报告 ``` python3 security_scanner.py example.com --ssl --ports --html ``` ### 将输出保存到文件 ``` python3 security_scanner.py example.com --json -o scan_result.json ``` ## 选项 | 标志 | 描述 | |------|-------------| | `urls` | 要扫描的目标 URL(空格分隔,默认为 yousseftouba.com) | | `-f, --file` | 从文本文件扫描 URL(每行一个,`#` 用于注释) | | `--ssl` | 检查 SSL/TLS 证书 | | `--ports` | 扫描常见的开放端口 | | `--dns` | 显示 DNS 信息 | | `-v, --verbose` | 显示详细输出(标头值、额外信息) | | `--json` | 以 JSON 格式输出结果 | | `--csv` | 以 CSV 格式输出结果 | | `--html` | 生成独立的 HTML 报告 | | `-o, --output` | 将输出保存到文件 | ## 示例输出 ``` ============================================================ NETWORK SECURITY SCANNER ============================================================ Target : https://example.com Host : example.com HTTP : 200 Time : 2026-07-04T11:30:40.258969+00:00 ============================================================ 📋 HTTP SECURITY HEADERS ------------------------------------------------------------ ✓ Present Strict-Transport-Security Forces HTTPS (HSTS) ✓ Present X-Frame-Options Clickjacking protection ✓ Present X-Content-Type-Options MIME-sniffing protection ✗ Missing Content-Security-Policy CSP header ... 🔐 SSL/TLS CERTIFICATE ------------------------------------------------------------ ✓ Valid certificate Subject : example.com Issuer : Let's Encrypt Expires : Sep 15 2026 (73 days left) 🚪 PORT SCAN (common ports) ------------------------------------------------------------ Open ports: 80 HTTP 443 HTTPS 🌐 DNS INFO ------------------------------------------------------------ IPv4 : 93.184.216.34 ``` ## 项目结构 ``` network-security-scanner/ ├── security_scanner.py # Main scanner script └── README.md # This file ``` ## 安全性 此工具执行**被动**且**非侵入性**的检查: - **标头**:仅读取 HTTP 响应标头(无 payload) - **SSL**:使用标准 Python SSL 握手 - **端口**:TCP 连接尝试(仅 SYN,不发送数据) - **DNS**:标准 DNS 解析 ⚠️ 仅扫描您拥有或已获得测试许可的网站。 ## 许可证 MIT — 随意使用。 ## 作者 **Youssef Touba** — 数字顾问 🌐 [yousseftouba.com](https://yousseftouba.com) 🐙 [GitHub](https://github.com/YoussefTouba)
标签:GraphQL安全矩阵, HTTP安全头, Python, 安全扫描器, 插件系统, 无后门, 无服务器架构, 网络安全, 逆向工具, 隐私保护