pepperonas/wp-shield

GitHub: pepperonas/wp-shield

wp-shield 是一款基于 Python 异步架构的 WordPress 黑盒安全审计扫描器,提供免费的本地 CVE 数据库与多格式报告输出,作为 WPScan 的纯净开源替代方案。

Stars: 0 | Forks: 0

# wp-shield **WordPress 安全审计扫描器** — 一款作为 [WPScan](https://wpscan.com/) 的纯净开源替代方案而构建的工具,专为对您拥有或获得授权测试的 WordPress 安装环境进行合法的黑盒安全审计而设计。

License: GPL-3.0-or-later Python 3.11+ Status: Beta Version 0.1.0 Platform: macOS · Linux · Raspberry Pi

Built with httpx Typer CLI Pydantic v2 SQLite Linter: Ruff Tests: pytest Output: SARIF 2.1.0

CI Last commit Open issues Open PRs GitHub stars GitHub forks Repo size Code size Top language Contributors PRs welcome Keep a Changelog Conventional Commits

Made for WordPress Vuln source: WPVulnerability.net Optional: Wordfence v3 OWASP-aligned Authorized-use only

``` _ _ _ _ __ ___ __ ___| |__ (_) ___| | __| | \ \ /\ / / '_ \ _____/ __| '_ \| |/ _ \ |/ _` | \ V V /| |_) |____\__ \ | | | | __/ | (_| | \_/\_/ | .__/ |___/_| |_|_|\___|_|\__,_| |_| ``` ## 功能 (v0.1) - **组件枚举** — WordPress 核心版本、插件、主题、用户 - **配置错误检测** — 暴露的 `wp-config.php` 备份、调试日志、目录列表、危险的 xmlrpc/wp-cron 暴露、缺失的安全标头、开放注册 - **CVE 匹配** — [WPVulnerability.net](https://www.wpvulnerability.net/) 数据源的本地 SQLite 缓存(免费,无需 API key,无商业费用)。如果您拥有 Bearer token,则支持将 Wordfence Intelligence v3 作为可选的数据源(其先前免费的 v1/v2 端点在 2025 年已返回 HTTP 410 Gone)。 - **多格式报告** — CLI 表格 (Rich)、JSON、独立 HTML、SARIF 2.1.0 (GitHub Code Scanning) - **默认礼貌扫描** — 遵守 `robots.txt`,进行速率限制,并标识为 `wp-shield/0.1` user-agent ## 路线图 - v0.2:Web 仪表板 (FastAPI + HTMX)、定时扫描 - v0.3:无头 Chromium 模式 (Playwright),适用于 SPA WordPress 站点 - v0.4:可选的身份验证压力模块(受限于自有域名白名单) ## 安装说明 ``` pip install wp-shield # 或用于开发: git clone https://github.com/pepperonas/wp-shield.git cd wp-shield pip install -e ".[dev]" ``` ## 快速入门 ``` # 1) 同步本地漏洞数据库(约每天一次,默认 source: WPVulnerability) wp-shield update # default: source=wpvulnerability, plugin_limit=500, theme_limit=200 # 或用于 Wordfence Intelligence(需要 Bearer token): # WORDFENCE_API_TOKEN=xxx wp-shield update --source wordfence # 2) 运行扫描 — 自动将 report.{html,json,sarif,txt} 保存到 ./out/_/ wp-shield scan https://example.com # 3) 同样的扫描,并在完成后在浏览器中打开 HTML 报告 wp-shield scan https://example.com --open # 4) 跳过磁盘 artefact(仅限 CLI) wp-shield scan https://example.com --no-save # 5) 将 JSON 流式传输到 stdout(在 pipelines 中很有用) wp-shield scan https://example.com --output json --no-save # 6) 自定义输出目录(也可通过 config.yaml 配置) wp-shield scan https://example.com --output-dir /var/lib/wp-shield/scans # 7) 数据库统计 wp-shield db stats ``` ### 自动保存布局 每次扫描都会在 `out/`(或您 配置的 `output.output_dir`)内创建一个带有时间戳的子目录: ``` out/ └── 20260529-185717_wpvulnerability.com/ ├── report.txt # ANSI-stripped Rich CLI snapshot — audit-trail friendly ├── report.html # standalone styled report (open in browser) ├── report.json # full Pydantic dump (machine-readable) └── report.sarif # SARIF 2.1.0 — upload to GitHub Code Scanning ``` `out/` 默认包含在 `.gitignore` 中,因此扫描产物永远不会被提交。 ### 单行命令:针对公共 WordPress 站点的实时演示 ``` cd /Users/martin/claude/wp-shield && source .venv/bin/activate && \ wp-shield scan https://wpvulnerability.com/ --mode mixed --rate-limit 3 --open ``` 此操作将运行礼貌的混合模式扫描,打印实时 Rich 表格,将所有 四种报告格式写入 `out/_wpvulnerability.com/`,并 在您的默认浏览器中打开 HTML 报告。 ## 检测模式 `--mode passive` — 仅分析 HTML(零“嘈杂”请求) `--mode mixed` _(默认)_ — 被动模式 + 针对性的 readme.txt / style.css 探测 `--mode aggressive` — 完整的插件/主题字典枚举(约 1–10 分钟,可能会触发 WAF) ## 配置 可以通过 `~/.config/wp-shield/config.yaml` 覆盖默认设置: ``` http: timeout: 15 max_concurrency: 10 user_agent: "wp-shield/0.1 (+https://github.com/pepperonas/wp-shield)" respect_robots_txt: true rate_limit_per_second: 5 scan: default_mode: mixed enumerate_users: true follow_redirects: true ``` ## 法律与道德 `wp-shield` **仅供授权的安全测试**使用。在您未拥有或未获得明确书面测试许可的站点上运行此工具在您的司法管辖区可能属于违法行为(例如德国的 StGB §202a/b、美国的《计算机欺诈和滥用法》、英国的《计算机滥用法》等)。 作者不对滥用行为负责。使用本软件即表示您同意: 1. 您将仅扫描您拥有或获得明确授权进行测试的系统 2. 您对运行扫描产生的任何后果承担全部责任 3. 您将遵守速率限制、`robots.txt` 以及目标系统的稳定性 暴力破解模块(计划在 v0.4 中推出)被**刻意限制**在本地 `~/.config/wp-shield/owned-domains.txt` 白名单之后,以防止意外滥用。 ## 架构 - **技术栈**:Python 3.11+、`httpx` (async)、`BeautifulSoup` + `lxml`、`typer` + `rich` (CLI)、`pydantic` (models)、`sqlite3` (vuln cache)、`jinja2` (reports/UI) - **漏洞数据源**: - **默认**:[WPVulnerability.net](https://www.wpvulnerability.net/) — 免费,无需 API key,按组件查找。我们使用内置字典中的前 N 个插件/主题 slug 对缓存进行预热。 - **可选**:[Wordfence Intelligence v3](https://www.wordfence.com/products/wordfence-intelligence/) — 由于 2025 年的 v3 迁移,现在需要免费的 Bearer token(其 v1/v2 端点现已返回 HTTP 410 Gone)。 请参阅 `docs/ARCHITECTURE.md`(计划中)。 ## 许可证 GPL-3.0-or-later — 与原始的 WPScan 和 WPVulnerability 项目使用相同的许可证。 ## 致谢 受到以下项目的启发: - [WPScan](https://github.com/wpscanteam/wpscan) (Ruby, GPL-3.0) — 参考实现 - [WPVulnerability](https://www.wpvulnerability.com/) — 开放漏洞数据库 - [Wordfence](https://www.wordfence.com/) — 提供免费且可用于商业目的的情报数据源
标签:CVE, Python, Splunk, WordPress, 安全规则引擎, 实时处理, 密码管理, 异步, 数字签名, 无后门, 运行时操纵, 逆向工具