
*爬取 → 发现 → 审计。15 个插件,5 种报告格式,默认遵守规范。*
[](https://github.com/lutzashl290788-cell/webscan/actions)
[](https://python.org)
[](LICENSE)
[](https://github.com/lutzashl290788-cell/webscan/stargazers)
[](https://github.com/lutzashl290788-cell/webscan/issues)
[](CONTRIBUTING.md)
## ⚡ 快速开始
```
git clone https://github.com/lutzashl290788-cell/webscan
cd webscan && pip install .
# 首次 / 站点所有者扫描推荐
webscan -t https://example.com --safe-mode
```
## 👥 为三类用户打造
### 🛡️ 站点所有者与初学者 — 安全与清晰
| 功能 | 作用 | 重要性 |
|--------|--------------|----------------|
| **安全模式** (`--safe-mode`) | 限制请求速率(约 2 req/s),使用真实的 User-Agent,降低并发,并遵守 `robots.txt` | 保护小型站点免受意外超载,保持审计的礼貌性 |
| **遵守 robots.txt** | 爬虫默认跳过禁止访问的路径 | 帮助初学者仅扫描站点所有者允许的内容 |
| **彩色结果输出** | 终端输出使用基于严重程度的颜色(严重 → 信息) | 无需阅读原始日志即可优先发现最严重的问题 |
```
webscan -t https://yoursite.com --safe-mode
```
### 🥷 Bug 搜寻者 — 隐蔽与深度
| 功能 | 作用 | 重要性 |
|--------|--------------|----------------|
| **请求抖动** (`--random-delay`) | 随机化请求之间的暂停时间(×0.5–×1.5) | 模糊自动化流量模式,以对抗基础的 WAF 规则 |
| **User-Agent 轮换** (`--random-agent`) | 轮换类似浏览器的特征(Chrome, Firefox, 移动端) | 绕过对扫描器特征的拦截;探测移动端变体 |
| **代理 / SOCKS5** (`--proxy`) | 通过 Burp、Tor 或任何 HTTP/SOCKS 代理路由所有流量 | 避免在目标日志中暴露您的真实 IP |
```
webscan -t https://target.com --proxy socks5://127.0.0.1:9050 --random-agent --random-delay
```
### 🧬 负责任的漏洞披露 — 道德与隐私
| 功能 | 作用 | 重要性 |
|--------|--------------|----------------|
| **法律免责声明** | 在交互模式下启动时打印 | 明确授权使用范围;防止滥用 |
| **报告匿名化** (`--anonymize`) | 从导出内容中剔除本地路径、主机名、用户名和私有 IP | 更安全地共享 SARIF/JSON;符合 GDPR 的数据最小化原则 |
```
webscan -t https://example.com --format sarif json -o report --anonymize
```
## 🎯 它能做什么
WebScan 可以选择**爬取**您的目标以发现 URL 和表单,然后针对它们启动每个
插件 — 所有这些都通过 `aiohttp` 并发执行。一次运行,即可获得彩色结果输出
和机器可读的报告。
```
$ webscan -t https://example.com --plugins headers cookies http_methods ssl_tls tech_fingerprint
╔══════════════════════════════════════════════════════════╗
║ WebScan — Security Auditor ║
╚══════════════════════════════════════════════════════════╝
Targets : 1
Plugins : headers, cookies, http_methods, ssl_tls, tech_fingerprint
Concurrency : 10
Timeout : 10s
[█] 1/1 — https://example.com
Scan completed 2026-06-11T11:11:51+00:00 → 2026-06-11T11:11:52+00:00
Total findings 9
• [https://example.com]
🟠 [HIGH ] Missing header: Content-Security-Policy
🟠 [HIGH ] Missing header: Strict-Transport-Security
🟡 [MEDIUM ] Missing header: X-Frame-Options
🟡 [MEDIUM ] Missing header: X-Content-Type-Options
🟡 [MEDIUM ] Missing HSTS header
🔵 [LOW ] Missing header: Referrer-Policy
🔵 [LOW ] Missing header: Permissions-Policy
🔵 [LOW ] Information disclosure: Server
⚪ [INFO ] Technologies detected: Cloudflare
```
## 🧩 插件
| 插件 | 检查内容 |
|--------|--------|
| `config_files` | 50+ 个暴露的文件:`.env`、`.git/config`、`wp-config.php`、SSH 密钥、SQL 转储 |
| `secrets` | HTML/JS 中泄露的 API 密钥:AWS、Anthropic、OpenAI、Stripe、GitHub、Slack(已脱敏) |
| `headers` | CSP, HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy |
| `directories` | `/admin`、`/backup`、`/.git/`、phpMyAdmin 和开放的目录列表 |
| `sql_injection` | 基于错误的、**布尔盲注**和**时间盲注** — MySQL / PostgreSQL / MSSQL / Oracle |
| `xss` | 查询参数中的反射型 XSS,并带有注入上下文分类 |
| `cors` | 反射型 `Origin`、通配符 `*`、凭据暴露 |
| `cookies` | 缺失 `Secure` / `HttpOnly` / `SameSite` 标志 |
| `http_methods` | 启用了危险的方法:`PUT`、`DELETE`、`TRACE`、`CONNECT`、`PATCH` |
| `path_traversal` | `../../../etc/passwd`、`windows/win.ini` 及其编码变体 |
| `open_redirect` | `?next=`、`?redirect=`、`?url=` 参数滥用 |
| `ssrf` | AWS/GCP 元数据和 localhost 探测(基于响应签名) |
| `ssl_tls` | 弱协议(SSLv2/3, TLS 1.0/1.1)、过期/即将过期的证书、缺少 HSTS |
| `tech_fingerprint` | 从 headers、cookies 和 HTML 中进行服务器/框架/CMS 检测 |
| `subdomains` | DNS 暴力破解 + Certificate Transparency 日志 (crt.sh) |
## 🚀 用法
```
# 单个 target,所有 plugins
webscan -t https://example.com
# 面向站点所有者的温和扫描(推荐默认设置)
webscan -t https://example.com --safe-mode
# 先 crawl,然后扫描每个发现的 URL
webscan -t https://example.com --crawl --depth 3
# 认证扫描(表单登录)
webscan -t https://example.com/dashboard \
--login-url https://example.com/login \
--login-data "username=admin&password=secret"
# 通过代理(例如 Burp)并使用轮换的 User-Agent 和 rate limiting
webscan -t https://example.com --proxy http://127.0.0.1:8080 --random-agent --rate-limit 5
# 仅限 high+ 的 findings,生成 HTML + SARIF 报告(匿名化以便分享)
webscan -t https://example.com --min-severity high -o ./reports/scan --format html sarif --anonymize
# 选择特定的 plugins / 从文件读取 targets
webscan -t https://example.com --plugins xss sql_injection headers
webscan -f targets.txt --format json csv
```
所有标志
```
Targets
-t URL [URL ...] Target URL(s)
-f FILE File with one URL per line (# comments allowed)
Crawler
--crawl Spider each target before scanning
--depth N Max crawl depth (default: 2)
--max-urls N Max URLs to discover per seed (default: 200)
--scope DOMAIN Restrict crawl to this host
--exclude PATTERN ... Skip URLs containing these substrings
--ignore-robots Ignore robots.txt
Authentication
--cookie STRING Raw cookie header
--header "K: V" Extra header (repeatable)
--basic-auth user:pass HTTP Basic auth
--login-url URL Form-login endpoint
--login-data STRING Form-login POST body
Network & evasion
--safe-mode Polite preset: low rate, honest UA, robots respected
--proxy URL HTTP/SOCKS proxy (e.g. http://127.0.0.1:8080)
--user-agent STRING Custom User-Agent
--random-agent Rotate through a built-in User-Agent pool
--delay SEC Delay before each target
--random-delay Randomise the delay ×0.5–×1.5
--rate-limit N Cap at N requests per second
--no-verify-ssl Skip TLS certificate verification
--no-bruteforce Disable DNS brute force (subdomains plugin)
Plugins & output
--plugins NAME [...] Plugins to run (default: all)
--list-plugins List plugins and exit
-o PATH Report base path (no extension)
--format FMT [...] json | md | html | sarif | csv (default: json md)
--min-severity LEVEL critical | high | medium | low | info
--anonymize Strip local paths, hostname and private IPs from reports
--no-color Disable ANSI colour
-v Verbose
-q Quiet
Performance
-c N Concurrent targets (default: 10)
--timeout SEC Per-request timeout (default: 10)
```
## 📊 输出格式
| 格式 | 标志 | 适用场景 |
|--------|------|----------|
| JSON | `--format json` | CI/CD、脚本编写、集成 |
| Markdown | `--format md` | 人工审查、GitHub PR |
| HTML | `--format html` | 独立的利益相关者报告 |
| SARIF | `--format sarif` | GitHub 代码扫描、VS Code |
| CSV | `--format csv` | Excel、Jira、Notion |
**CI 友好:** 当检测到任何严重或高危发现时,WebScan 会以代码 `1` 退出。
## ⚙️ CI/CD
[`.github/workflows/security-scan.yml`](.github/workflows/security-scan.yml) 中提供了一个开箱即用的工作流:
```
name: Security Scan
on: [workflow_dispatch]
permissions:
security-events: write
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with: { python-version: "3.12" }
- run: pip install .
- run: webscan -t ${{ secrets.STAGING_URL }} --min-severity high --format sarif -o report
continue-on-error: true
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: report.sarif
```
### Docker
```
docker build -t webscan .
docker run --rm webscan -t https://example.com
# Mount 一个目录以保存报告
docker run --rm -v "$(pwd)/reports:/reports" webscan \
-t https://example.com -o /reports/scan --format json html
```
## 🔌 编写插件
```
from __future__ import annotations
import aiohttp
from webscan.models import Finding, Severity
from webscan.plugins.base import BasePlugin
class MyPlugin(BasePlugin):
name = "my_plugin"
description = "What it checks in one line"
async def run(self, target: str, session: aiohttp.ClientSession) -> list[Finding]:
findings: list[Finding] = []
# ... perform checks, append Finding(...) objects ...
return findings
```
在 `webscan/cli.py` 中注册它 → `ALL_PLUGINS["my_plugin"] = MyPlugin`。搞定。
## 🏗 架构
```
webscan/
├── cli.py # Entry point, argument parsing, legal disclaimer
├── engine.py # Async scan orchestrator (concurrency, sessions)
├── crawler.py # Async breadth-first spider (links + forms)
├── auth.py # Auth: cookie, header, basic, form-based login
├── net.py # Proxy, User-Agent rotation, rate limiting
├── anonymize.py # Report scrubbing for external sharing
├── models.py # Finding, Severity, ScanReport dataclasses
├── reporter.py # JSON / MD / HTML / SARIF / CSV output
├── utils/html.py # Dependency-free HTML link & form parser
└── plugins/
├── base.py # BasePlugin ABC
├── headers.py
├── sql_injection.py
├── xss.py
└── ... # one file per plugin (14 total)
```
运行时依赖:**仅限 `aiohttp`**。其他所有内容均来自 Python 标准库。
## 📦 安装
```
# from source
git clone https://github.com/lutzashl290788-cell/webscan
cd webscan && pip install .
# 开发安装(ruff、mypy、pytest)
pip install -e ".[dev]"
```
**环境要求:** Python ≥ 3.10,`aiohttp` ≥ 3.9
## ⚖️ 法律
WebScan 仅用于**授权的安全测试**。仅限在您拥有或获得明确书面许可进行测试的系统上使用。未经授权的扫描在您所在的司法管辖区可能是违法的。您需对自己的软件使用行为负全部责任。
用 ☕ 和太多的 CVE 打造
**[⭐ 如果有用请点 Star](https://github.com/lutzashl290788-cell/webscan/stargazers)** · **[🐛 报告 Bug](https://github.com/lutzashl290788-cell/webscan/issues)** · **[💡 提出新功能](https://github.com/lutzashl290788-cell/webscan/issues)**
未来里程碑:集成基于 LLM 的审计(Claude 3.5 Sonnet),实现智能化的误报消除。