内容
# web-exposure-mcp
> 一个 **MCP 服务器**,允许 AI 代理指向 **实时部署的 URL**,并确认敏感文件是否真正被公开提供 - 暴露的 `.git`、`.env` 机密、JavaScript 源映射、备份/SQL 转储、目录列表和点文件 - 通过 **获取字节并验证内容**。其他工具为您提供一个可能的清单;本工具仅报告真正可达的内容,并附有证据。
> ⚡ **一行命令即可运行,无需安装,无需 API 密钥:**
> ```bash
> npx web-exposure-mcp # 为您的 AI 客户端提供的 MCP 服务器(stdio)
> npx -p web-exposure-mcp web-exposure-scan --url https://your-site.com # 一次性 CLI
> ```
> 🤝 **希望我们为您完成?** [固定范围的外部暴露审计 - $99 / 24 小时](https://buy.stripe.com/3cIeVdgikfj47yx9LkcAo0m):我实时验证每个发现结果,并发送一份包含确切修复和需要轮换的凭证的书面报告。
[](https://www.npmjs.com/package/web-exposure-mcp) [](https://www.npmjs.com/package/web-exposure-mcp)   
```
$ npx -p web-exposure-mcp web-exposure-scan --url https://demo.example.com
2 critical, 2 high, 1 medium — 5 CONFIRMED via anonymous fetch (39 requests)
CRITICAL /.git/config valid .git served — full source history downloadable
CRITICAL /.env 5 env vars served — API_KEY, DATABASE_URL, JWT_SECRET…
HIGH /main.js.map valid source map — 142 original sources reconstructable
HIGH /backup.sql SQL dump content served
MEDIUM /uploads/ directory listing enabled (Index of /uploads)
```
## 为什么存在
公开提供的 `.git` 和 `.env` 文件通常被认为是外部攻击面管理中最常见的高影响力发现之一 - Acunetix、Invicti 和 Legba 都配备了专门的检测功能,并且 HackerOne 报告中不断有公开的 `.git` / `.env` 被泄露的案例。2026 年 6 月,泄露的凭证转储创下了记录,其中很大一部分来自 **实时配置错误的服务器**,而非被入侵的数据库。
MCP 生态系统已经涵盖了 SSL、CORS、安全标头、SEO 审计和 **代码/提交** 机密扫描(GitHub MCP、GitGuardian)- 但 **没有 MCP 服务器探测已部署 URL 中公开提供的机密文件**。这填补了这一空白:您的代理可以审计任何部署的实时边缘,就像攻击者实际看到的那样。
难点不在于请求 `/.env` - 而在于避免误报。大多数现代网站都以 `200 OK` 和 `index.html` 响应 *每个* 未知路径(SPA 统一路由)。因此,`web-exposure-mcp` **读取字节并指纹内容**(例如,`/.git/config` 必须解析为 git 配置,`/.env` 必须包含 `KEY=VALUE` 机密行,存档必须以实际的幻数开头)- 因此它会标记事实,而不是猜测。
## 工具(MCP)
| 工具 | 功能 |
|---|---|
| `scan_web_exposure` | 探测实时 URL 并仅返回确实提供的机密文件,并附有证据。参数:`url`(必填),`only`(可选检查筛选器),`timeout_ms`。 |
| `list_exposure_checks` | 列出每个检查 ID、严重性和探测的路径 - 将 ID 输入到 `only` 中。 |
## 确认内容
| 检查 ID | 严重性 | 确认方式 |
|---|---|---|
| `git_exposed` | 关键 | `/.git/config` 解析为 git 配置,或 `/.git/HEAD` 是有效的 ref/sha |
| `env_exposed` | 关键 | dotenv 提供且包含 ≥2 `KEY=VALUE` 机密行(非 HTML) |
| `source_map` | 高 | `.js.map` 解析为具有 `sources[]` 数组的源映射 |
| `backup_artifact` | 高 | SQL 转储指纹,或正文中的 ZIP/gzip **幻数** |
| `directory_listing` | 中等 | 返回 autoindex 签名(`Index of /…`) |
| `dotfile_served` | 高 | `.htpasswd` 哈希、`.npmrc`/`.netrc` 令牌、`.aws/credentials`、`.ssh/id_rsa`、`.DS_Store`、docker 认证 |
每次检查 **最多一次**,且仅当提供的字节证明这一点时。只读:扫描器从不向目标写入任何内容,不会跟随重定向到其他主机,并且每个文件最多读取 64 KB(因此它可以指纹一个多 GB 的备份文件,而无需下载它)。
## 添加到您的 AI 客户端
Claude Desktop / Cursor / 任意 MCP 客户端 - 添加到您的 `mcpServers` 配置:
```json
{
"mcpServers": {
"web-exposure": {
"command": "npx",
"args": ["-y", "web-exposure-mcp"]
}
}
}
```
然后询问您的代理:*“扫描 https://staging.myapp.com 以查找公开暴露的机密文件。”*
## CLI 使用
```bash
# 探测实时部署
npx -p web-exposure-mcp web-exposure-scan --url https://your-site.com
# 仅运行特定检查
npx -p web-exposure-mcp web-exposure-scan --url https://your-site.com --only git_exposed,env_exposed
# 更严格的每次请求超时时间
npx -p web-exposure-mcp web-exposure-scan --url https://your-site.com --timeout 8000
```
输出是 stdout 上的 JSON(管道到 CI)和 stderr 上的单行摘要。
## 安装(可选)
```bash
npm i -g web-exposure-mcp
web-exposure-mcp # 启动 MCP 服务器(stdio)
web-exposure-scan --url https://site.com # 一次性扫描
```
零依赖,纯 Node ≥18。每个请求都直接从工具发送到您命名的目标 - 没有任何内容离开您的机器。
## 姐妹工具
相同的积极探测哲学 - 通过获取内容来确认实际问题,而不是依赖检查清单。所有 MIT:
[supabase-security](https://github.com/Perufitlife/supabase-security-skill) ·
[strapi-security](https://github.com/Perufitlife/strapi-security) ·
[pocketbase-security](https://github.com/Perufitlife/pocketbase-security-skill) ·
[firebase-security](https://github.com/Perufitlife/firebase-security-skill) ·
[appwrite-security](https://github.com/Perufitlife/appwrite-security-skill) ·
[nhost-security](https://github.com/Perufitlife/nhost-security-skill)
## 许可证
MIT © [Renzo Madueno](https://github.com/Perufitlife)
---
📚 [Awesome Backend Security Auditors](https://github.com/Perufitlife/awesome-backend-security) 的一部分 - 关键的无 API 审计员集合。