1tsRajOwO/bronze-shield

GitHub: 1tsRajOwO/bronze-shield

一款零依赖的网站安全审计工具,通过检测 HTTP 标头、SSL 证书和 DNS 配置对网站进行 A+ 到 F 评级,并支持批量扫描导出线索。

Stars: 0 | Forks: 0

# 🛡️ Bronze Shield ### 网站安全健康检查审计工具 **一款零依赖的安全审计工具,能在几秒钟内评估任何网站的安全状况——并将结果转化为销售 pipeline。** [![Python](https://img.shields.io/badge/Python-3.8+-3776AB?style=flat-square&logo=python&logoColor=white)](https://python.org) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT) [![Dependencies](https://img.shields.io/badge/Dependencies-Zero-success?style=flat-square)](https://github.com/1tsRajOwO) [![COPPA](https://img.shields.io/badge/COPPA-Compliant-blue?style=flat-square)](https://en.wikipedia.org/wiki/Children%27s_Online_Privacy_Protection_Act) [![GDPR](https://img.shields.io/badge/GDPR-Compliant-blue?style=flat-square)](https://gdpr.eu/) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](CONTRIBUTING.md)
## 这是什么? Bronze Shield 会检查任何网站的**公开 HTTP 标头和 SSL 证书**,对它们进行 100 分制的评分,并给出从 **A+ 到 F** 的字母评级。它完全基于 Python 标准库运行——无需 `pip install`,无需 Docker,无需数据库。 它的存在有两个原因: 1. **审计** — 获取任何域名清晰、通俗易懂的安全报告。 2. **销售** — 批量扫描潜在客户名单,导出按最差优先排序的 CSV 文件,并使用自动生成的推销话术,向安全最薄弱的目标发送冷邮件。 ## ✨ 功能 | | 功能 | 作用 | | --- | ------------------------ | ------------------------------------------------------------------------------------------------------------- | | 🔍 | **6 项标头检查** | 检查 HSTS、CSP、X-Frame-Options、X-Content-Type-Options、Referrer-Policy、Permissions-Policy | | 🔒 | **SSL 验证** | 验证证书链、颁发者和到期剩余天数 | | 🌐 | **OSINT 信息丰富** | IP 地理定位、DNS 记录 (A/AAAA/MX/NS/TXT/CAA)、DNSSEC、注册商查询、通过 CT 日志发现子域名 | | 🧪 | **CSP AST 解析器** | 将 Content-Security-Policy 解析为指令,并标记有风险的通配符 / `unsafe-inline` | | 📊 | **分类评分** | 将分数细分为 Headers (35%)、SSL (25%)、DNS (20%)、Policy (20%) | | 📝 | **自动推销话术生成器** | 为每个扫描的域名编写通俗易懂的销售摘要 | | 🖥️ | **Web 仪表盘** | 影院级 WebGL 落地页 + 深度审计报告 UI | | ⌨️ | **CLI 扫描器** | 支持单域名和批量扫描,并可导出 CSV | | 🛡️ | **SSRF 防护** | 阻止扫描私有/内部 IP (RFC 1918、loopback、link-local) | | 🤖 | **AI 分析** | 可选的 Hugging Face 集成,用于威胁分析 | ## 🚀 快速开始 ### Web 仪表盘 ``` python3 app.py ``` 在浏览器中打开 **http://localhost:5050**。输入域名,点击扫描,即可获取评级。 ### CLI — 单个域名 ``` python3 site_security_check.py github.com ```
📄 输出示例 ``` ============================================================ SECURITY HEALTH-CHECK REPORT: github.com Scanned Date: 2026-07-31T09:00:00Z Overall Grade: A (Score: 85/100) IP Address: 140.82.121.4 Location: San Francisco, United States (GitHub, Inc.) Hosting: GitHub, Inc. / Registrar: GitHub, Inc. ============================================================ EXECUTIVE SUMMARY: I ran a security health check on github.com. The site scored Grade 'A' (85/100)... SSL/TLS CERTIFICATE: - Status: VALID - Issuer: DigiCert, Inc. - Days Until Expiry: 247 days SECURITY HEADER BREAKDOWN: [PASS] Strict-Transport-Security [PASS] Content-Security-Policy [MISSING] X-Frame-Options ... ```
### CLI — 批量扫描 + 导出 CSV ``` python3 site_security_check.py -f sample_prospects.txt -o prospect_report.csv ``` CSV 文件按**最差评级优先**排序——您最优质的潜在线索排在最前面。
⚙️ 所有 CLI 参数 | 参数 | 描述 | | --------------- | --------------------------------------------- | | `url` | 单个目标域名 (例如 `example.com`) | | `-f, --file` | 包含域名的文本文件路径 (每行一个) | | `-o, --output` | 批量扫描的 CSV 输出路径 | | `-j, --json` | 输出原始 JSON 而非文本报告 | | `-t, --timeout` | 请求超时时间(秒) (默认: `2.8`) |
## 📡 API 参考 | 方法 | 端点 | 描述 | | ------ | ------------------------ | ------------------------------------------------------------------------------------------------------------- | | `GET` | `/api/scan?url=` | 运行全面安全扫描 | | `POST` | `/api/scan` | Body: `{"url": "domain.com"}` | | `POST` | `/api/terminal` | 执行列入白名单的 OSINT 命令 (`whois`, `dig`, `nslookup`, `ping`, `curl`, `nmap`, `traceroute`, `host`) | | `POST` | `/api/analyze` | AI 驱动的威胁分析 (需要 `HF_API_TOKEN`) | | `GET` | `/api/legal` | 法律与合规元数据 | | `GET` | `/health` | 健康检查 |
📦 扫描响应 schema ``` { "target": "example.com", "score": 85, "grade": "A", "category_scores": { "headers": 90, "ssl": 100, "dns": 85, "policy": 70 }, "ip_address": "93.184.216.34", "location": { "country": "United States", "city": "Well", "isp": "EDGECAST" }, "hosting_info": { "provider": "Edgecast", "registrar": "IANA" }, "dns_records": { "A": ["..."], "MX": ["..."], "NS": ["..."], "TXT": ["..."] }, "dns_caa": { "present": true, "records": ["..."] }, "dnssec": { "enabled": true }, "ssl": { "valid": true, "issuer": "DigiCert", "days_remaining": 120 }, "headers": { "Strict-Transport-Security": { "status": "PASS", "points": 20 } }, "csp_ast": { "present": true, "risks": [], "score": 95 }, "hsts_preload": { "qualified": true, "status": "QUALIFIED" }, "security_txt": { "found": true, "contact": "mailto:security@example.com" }, "subdomains": ["www.example.com", "api.example.com"], "port_status": { "80": "open", "443": "open", "22": "closed" }, "summary_pitch": "I ran a quick security health check on...", "client_report_text": "..." } ```
## 🏗️ 架构 ``` ┌─────────────────────────────────────────────────────────┐ │ Browser (Frontend) │ │ index.html privacy.html tos.html audit.html │ │ WebGL hero Legal pages Terms Deep audit UI │ └────────────────────────┬────────────────────────────────┘ │ HTTP ┌────────────────────────▼────────────────────────────────┐ │ app.py (Port 5050) │ │ ThreadingHTTPServer + REST API │ │ /api/scan /api/terminal /api/analyze /api/legal │ └────────────────────────┬────────────────────────────────┘ │ ┌────────────────────────▼────────────────────────────────┐ │ site_security_check.py (Engine) │ │ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ Headers │ │ SSL │ │ DNS │ │ OSINT │ │ │ │ 6-check │ │ Cert+TLS │ │ DoH x2 │ │ Geo/RDAP │ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ ThreadPoolExecutor (24 workers, 2.3s budget) │ └─────────────────────────────────────────────────────────┘ ``` **关键设计选择:** - **零依赖** — 仅基于 Python 3.8+ 标准库运行。运行时无需 `requirements.txt`。 - **默认并发** — 24 个 worker 的线程池,总时长预算为 2.3 秒,确保慢速目标不会阻塞快速目标。 - **双重 DoH** — DNS 查找依次从 Google DoH 回退到 Cloudflare DoH。 - **SSRF 安全** — 每个出站连接都受到 `is_private_or_internal_ip()` 的保护。 ## 📁 项目结构 ``` . ├── app.py # Web server & REST API ├── site_security_check.py # Scanner engine & CLI ├── index.html # Landing page (WebGL hero) ├── audit.html # Deep audit dashboard ├── privacy.html # Privacy policy ├── tos.html # Terms of service ├── Procfile # Deployment config (Heroku/Railway) ├── requirements.txt # Empty — zero deps required ├── sample_prospects.txt # Example domain list ├── prospect_report.csv # Example batch output ├── tests/ # E2E test suite (Tiers 1-4) ├── LEGAL_COMPLIANCE.md # Legal framework └── run_e2e_tests.py # Test runner ``` ## 💼 商业策略手册 此工具专为安全顾问打造,可作为**线索生成引擎**。 1. **寻找潜在客户** — 从 Google Maps 或目录中收集 15–30 个本地企业 URL。 2. **批量扫描** — `python3 site_security_check.py -f prospects.txt -o leads.csv` 3. **冷邮件** — 从评级最差的域名开始。直接使用 `Summary_Pitch` 列的内容。 4. **在线演示** — 在屏幕共享通话中,通过 Web 仪表盘运行他们的域名。 5. **交付与追加销售** — 发送通俗易懂的报告。提供标头修复服务 ($300–$600) 和按月监控服务 ($20–$40/月)。 ## 🧪 测试 ``` python3 run_e2e_tests.py ``` 测试套件涵盖四个层级: | 层级 | 范围 | | ---------- | ----------------------------------------------- | | **Tier 1** | API 契约、路由、品牌推广、法律内容 | | **Tier 2** | 边界条件与输入验证 | | **Tier 3** | 跨功能集成 | | **Tier 4** | 端到端用户场景 | ## 🚢 部署 ### Railway / Heroku 包含的 `Procfile` 使部署只需一条命令: ``` # Railway railway up # Heroku heroku create my-auditor && git push heroku main ``` 服务器绑定到 `0.0.0.0` 并从环境中读取 `PORT`。 ### 本地 / 自托管 ``` python3 app.py # Binds to 0.0.0.0:5050 ``` ### 可选:AI 分析 设置 Hugging Face token 以启用 `/api/analyze`: ``` export HF_API_TOKEN=hf_your_token_here export HF_MODEL_NAME=mistralai/Mistral-7B-Instruct-v0.2 # optional ``` ## 📊 评分标准 | 评级 | 分数 | 含义 | | ------ | ------ | --------------------------------- | | **A+** | 90–100 | 标杆级的安全状况 | | **A** | 80–89 | 表现强劲,需要微调 | | **B** | 70–79 | 良好,存在一些不足 | | **C** | 55–69 | 一般,存在明显风险 | | **D** | 40–54 | 薄弱,存在多个严重不足 | | **F** | 0–39 | 极差,需要立即采取行动 | ### 评分权重 | 类别 | 权重 | 衡量内容 | | ----------- | ------ | ----------------------------------------------------- | | **Headers** | 35% | 6 个安全标头 (CSP 25, HSTS 20, X-Frame 15, ...) | | **SSL** | 25% | 有效性 + 到期剩余天数 | | **DNS** | 20% | A/AAAA/MX/NS/TXT 记录 + CAA | | **Policy** | 20% | CSP AST 评分 + HSTS preload + security.txt + DNSSEC | ## ⚖️ 法律与合规 - **符合 COPPA** — 不收集个人数据,适合所有年龄段。 - **符合 GDPR** — 零 PII,零 cookie,零追踪。 - **符合 CFAA** — 仅读取公开的 HTTP 标头,无漏洞利用。 - 请参阅 [`LEGAL_COMPLIANCE.md`](LEGAL_COMPLIANCE.md) 获取完整框架。 ## 📝 许可证 基于 MIT 许可证分发。详情请参阅 [`LICENSE`](LICENSE)。
**由 Python 打造,零依赖,并对缺失的安全标头保持高度警惕。**
标签:ESC4, HTTP安全头, OSINT, Python, SSL证书检查, 多模态安全, 实时处理, 无后门, 网站扫描, 逆向工具, 销售线索生成