renat0z3r0/sorcino
GitHub: renat0z3r0/sorcino
一款用于识别互联网上配置不当的 OpenClaw 实例及其他 LLM 代理暴露面的安全扫描器。
Stars: 1 | Forks: 0
# 🐭 Sorcino
用于识别配置不当的 [OpenClaw](https://github.com/openclaw/openclaw) 实例以及暴露在互联网上的其他 LLM 代理的扫描器。
## 功能
- 扫描 IPv4/IPv6 地址、CIDR 块、范围和 ASN,查找暴露的 LLM 代理
- 识别 26 种 LLM 服务器/代理类型(OpenClaw, Hermes Agent, vLLM, Ollama,
Open WebUI, LiteLLM, TGI, llama.cpp, LocalAI, MCP, SGLang, Text Embeddings
Inference, Ray Serve, BentoML, KoboldCpp 等 — 见下文)
- 并发 worker-pool 扫描(无队头阻塞),支持每台主机的并行检查
- 检测安全配置错误:
- Auth 绕过(未经身份验证的 WebSocket/HTTP endpoint,支持感知 fail-closed 机制)
- API key 泄露(响应中泄露了 Anthropic/OpenAI 密钥)
- 信息泄露(调试模式、暴露的配置、stack trace)
- 模型清单枚举(未经身份验证的 `/v1/models`、`/api/tags`)
- mDNS 信息泄露
- 检查在应答的协议方案上运行,因此涵盖由 TLS 前置(`https`/`wss`)的代理
- SPA 误报过滤(忽略敏感文件路径上的 HTML catch-all 响应)
- 证据收集(`--dump-evidence`)以保存原始文件和 WebSocket 响应
- 对扫描目标进行反向 DNS (PTR) 查找(可通过 `--rdns/--no-rdns` 配置)
- 扫描模式:`fast`、`thorough`、`stealth`,具有预设的 timeout/concurrency/delay
- 跨整个扫描的全局请求速率上限(`--rate N`),与 concurrency 无关
- 可选的主动推理探测(`--probe-inference`),用于演示消耗 token 的安全风险
- 生成 JSON、Markdown、纯文本、SARIF(CI/仪表板)和 CSV 格式的报告
- 自动生成带有时间戳的报告文件名
- 用于适配脚本的安静模式(`--quiet`)
- 用于详细探测调试的详细模式(`--verbose`)
- 严重性过滤(`--min-severity`),仅显示相关结果
## 安装说明
```
git clone https://github.com/renat0z3r0/sorcino.git
cd sorcino
pip install -e .
```
## 用法
```
# 单个 IP 扫描 (IPv4 或 IPv6)
sorcino scan 192.168.1.100
sorcino scan 2001:db8::1
# CIDR 扫描 (IPv4 或 IPv6)
sorcino scan 192.168.1.0/24
sorcino scan 2001:db8::/120
# IP 范围扫描
sorcino scan 192.168.1.1-254
sorcino scan 10.0.0.1-10.0.0.254
# 从文件扫描
sorcino scan @targets.txt
# ASN 扫描
sorcino asn AS12345
sorcino asn AS12345 --list-only
# Shodan 导入
sorcino shodan-import "port:18789" --api-key $SHODAN_KEY
sorcino shodan-import "port:18789 country:IT" --scan
# mDNS 发现 (本地网络)
sorcino mdns-scan
# 常用选项
sorcino scan 10.0.0.0/16 --ports 18789,8080 --mode fast --concurrency 50
sorcino scan targets.txt --format markdown --output report.md
# 同时扫描不常见的 LLM-server 端口 (LM Studio, Jan, Xinference, ...)
sorcino scan 192.168.1.0/24 --llm-ports
# 安静模式 (仅 CRITICAL/HIGH 发现,无进度条)
sorcino scan 192.168.1.0/24 --quiet
# 详细模式 (详细的探测输出)
sorcino scan 192.168.1.100 --verbose
# 按最低严重性过滤
sorcino scan 192.168.1.0/24 --min-severity high
# 将整个扫描限制为 20 个请求/秒 (做一个良好的网络公民)
sorcino scan 10.0.0.0/16 --rate 20
# 主动推理探测 — 证明暴露的代理将提供推理
# 未授权 (发送一个 1-token 请求)。仅供授权测试。
sorcino scan 192.168.1.100 --probe-inference
```
## 扫描模式
三种具有不同速度/隐蔽性权衡的扫描模式:
| 模式 | Timeout | Concurrency | Delay | rDNS |
|------|---------|-------------|-------|------|
| `fast` | 3s | 50 | 0ms | off |
| `thorough` | 10s | 20 | 0ms | on |
| `stealth` | 15s | 5 | 500ms | on |
```
# 快速模式 - 快速扫描,无 rDNS
sorcino scan 10.0.0.0/16 --mode fast
# 彻底模式 (默认) - 平衡
sorcino scan 192.168.1.0/24 --mode thorough
# 隐蔽模式 - 缓慢,批次间有延迟
sorcino scan 192.168.1.0/24 --mode stealth
# 使用显式选项覆盖模式默认值
sorcino scan 10.0.0.0/16 --mode fast --timeout 5 --concurrency 100
# 独立控制 rDNS
sorcino scan 192.168.1.0/24 --mode fast --rdns # fast + rDNS
sorcino scan 192.168.1.0/24 --mode thorough --no-rdns # thorough without rDNS
```
## 输出
当省略 `-o` 时,报告文件名会自动生成并带有时间戳:
```
sorcino_scan_20260203_143052.json
sorcino_scan_20260203_143052.txt
sorcino_scan_20260203_143052.md
```
```
# JSON (默认,自动命名)
sorcino scan 192.168.1.0/24
# 自定义名称的 JSON
sorcino scan 192.168.1.0/24 -o results.json
# Markdown
sorcino scan 192.168.1.0/24 -f markdown -o report.md
# 纯文本
sorcino scan 192.168.1.0/24 -f txt
# SARIF (用于 CI / 安全仪表板)
sorcino scan 192.168.1.0/24 -f sarif -o findings.sarif
# CSV (每个发现一行)
sorcino scan 192.168.1.0/24 -f csv -o findings.csv
```
## 证据收集
使用 `--dump-evidence` 保存原始证据以供取证审查:
```
sorcino scan 192.168.1.100 --dump-evidence
```
为每个目标创建一个结构化的目录:
```
evidence/
└── 20260203_143052_192.168.1.100/
├── 192.168.1.100_8080_.env # Exposed sensitive files (prefixed host_port)
├── 192.168.1.100_8080_config.json
├── websocket_responses.txt # Raw WS request/response pairs
└── manifest.json # Index of all collected evidence
```
仅保存真实文件 - 会过滤掉 SPA 的 catch-all 响应(在任何路径上提供的 HTML 页面)。
## 检测到的服务
| 服务 | 默认端口 | 备注 |
|---------|-------------|-------|
| OpenClaw | 18789 | Gateway WS+HTTP(CDP 18791,通过 mDNS 获取 `canvasPort` 的 Canvas) |
| Hermes Agent | 8642 / 9119 | NousResearch 代理 — 未经身份验证的 dashboard 可能会泄露 `.env` |
| vLLM | 8000 | 通过 `vllm:` `/metrics` 进行指纹识别 |
| Ollama | 11434 | 本地 LLM (`/api/tags`) |
| Open WebUI | 8080 / 3000 | Ollama/OpenAI 前端(`/api/config` 经常暴露) |
| LiteLLM | 4000 | 多提供商代理 |
| MCP Server | 各种 | Model Context Protocol |
| TGI / LocalAI / llama.cpp / Tabby | 3000 / 8080 | 推理与代码补全服务器 |
| Triton / LangServe | 8000 | NVIDIA Triton / LangChain 部署 |
| Dify | 80 / 443 | LLM 应用平台 |
| Flowise | 3000 | 代理构建器(经常被暴露) |
| LM Studio / Jan / GPT4All / oobabooga / Xinference / AnythingLLM | 1234 / 1337 / 4891 / 5000 / 9997 / 3001 | 桌面端及自托管服务器(使用 `--llm-ports`) |
| SGLang | 30000 | OpenAI 兼容;通过 `/get_model_info` 进行指纹识别(使用 `--llm-ports`) |
| Text Embeddings Inference | 8080 | HuggingFace TEI;`/info` 会暴露模型 ID/限制 |
| Ray Serve | 8000 / 8265 | Serve 代理 + Ray Dashboard 的 serve API(8265 需通过 `--llm-ports` 扫描) |
| BentoML / OpenLLM | 3000 | `/livez` `/readyz` + BentoML OpenAPI 文档 |
| KoboldCpp | 5001 | `/api/extra/version` 返回字面量 `KoboldCpp`(使用 `--llm-ports`) |
使用 `--llm-ports` 还可以扫描上述不常见的 LLM 服务器端口
(`1234,1337,3001,4891,5000,5001,8002,8265,9000,9997,30000`);默认扫描保持精简。
## 漏洞检查
- **Auth 绕过**(支持感知 fail-closed 机制):现代 OpenClaw 默认拒绝未经身份验证的
WebSocket 连接。Sorcino 能够区分*已暴露但正在执行身份验证*的 gateway(关闭代码 `1008` → **LOW**)与实际上在没有 token 的情况下响应 RPC 的 gateway(→ **CRITICAL**)。同时探测 `ws://`
和 `wss://`。在没有 bearer 的情况下返回 `operator.*` 权限的 HTTP endpoint(`/tools/invoke`, `/api/v1/admin/rpc`, `/v1/*`,
`/api/channels`) → **CRITICAL**。
- **受信任的代理欺骗**:可选的、数据驱动的检查,用于检测 `trusted-proxy` 认证模式下的身份标头欺骗(除非在 `config/openclaw_surface.yaml` 中配置了标头名称,否则处于禁用状态)。
- **API key 泄露**:响应中的 `sk-ant-*`、`sk-*` 模式
- **模型枚举**:未经身份验证的 `/v1/models` / `/api/tags` 列出
已提供的模型 → **LOW**(确认存在可达且可枚举的推理 API)。
- **主动推理**(可选,`--probe-inference`):向发现的模型发送一个仅包含 1 个 token 的请求;未经身份验证的完成响应 → **CRITICAL**
(演示了 token 消耗)。默认关闭 — 这是一种主动请求,而不是
被动读取。仅限授权测试。
- **信息泄露**:调试模式、版本泄露、暴露的配置(带有 SPA 误报过滤)
- **mDNS 泄露**:`cliPath`(用户名) / `sshPort` 仅在 `full` 发现
模式下泄露;通过 `discovery.mdns.mode: minimal|off` 进行修复。还会暴露
`gatewayTls`(TLS gateway → `wss://`)以及动态的 `canvasPort`。
## 环境要求
- Python 3.9+
- 依赖项:aiohttp, aiodns, typer, rich, websockets, pyyaml, zeroconf
- 开发/测试:`pip install -e .[dev]` 然后执行 `pytest`
## 免责声明 :)
```
This tool is intended exclusively for:
- Authorized (EHHHH!!) penetration testing
- Assessment of owned infrastructure or with written (of course, plz :P) authorization
- Responsible (ehm :P) security research
- BLA BLA BLA
Unauthorized use to scan systems without permission is illegal.
Renato Zero is not responsible for misuse of this tool, okkkkk?!? D'ACCCOOOORDDOOOO? (cit. Wanna Marchi)
```
## 许可证
MIT License - Copyright (c) 2026 Renato Zero
标签:Python, 安全规则引擎, 实时处理, 密码管理, 扫描器, 无后门, 聊天机器人, 资产测绘, 逆向工具