统一的安全扫描工具 Go SDK,提供一致的接口设计。
Chainreactors SDK 为多个安全扫描工具提供统一接口:
- Fingers: Web 指纹识别(HTTP/Socket)
- Neutron: POC/漏洞扫描
- GoGo: 集成指纹识别和 POC 检测的端口扫描
- Spray: HTTP 批量检测和路径爆破
- Zombie: 弱口令检测和未授权访问检测
- Cyberhub Provider: 统一远程数据源,导出指纹、alias 和 POC
- Association: 统一关联查询,从 finger、alias、template、CVE 等条件互相查找
详细文档见 docs/。
go get github.com/chainreactors/sdkClient 是 SDK 的统一入口,管理引擎生命周期、依赖注入和关联查询:
import (
"github.com/chainreactors/sdk/client""github.com/chainreactors/sdk/pkg/cyberhub""github.com/chainreactors/sdk/gogo"
)
// 创建 Client,共享 Provider,开启关联索引provider:=cyberhub.NewProvider("http://127.0.0.1:8080", "your_key")
c:=client.New(
client.WithProvider(provider),
client.WithIndex(nil), // 可选:开启关联查询
)
deferc.Close()
// 获取引擎 — 依赖自动注入// GoGo 自动获得 Fingers + Neutron 引擎gogoEng, _:=gogo.FromClient(c)
results, _:=gogoEng.Scan(gogo.NewContext().SetThreads(1000), "192.168.1.0/24", "80,443")
// 关联查询 — 扫描结果直接查关联 POCfor_, r:=rangeresults {
related, _:=c.LookupByFinger(r.Frameworks.Names()...)
// related.Templates — 关联的 POC
}Client 的依赖注入关系:
GoGo → 自动注入 Fingers + Neutron
Spray → 自动注入 Fingers
所有数据通过 types.Provider 接口显式加载,支持多个数据源合并:
import (
"github.com/chainreactors/sdk/pkg/cyberhub""github.com/chainreactors/sdk/pkg/provider"
)
// 内置 embed 数据provider.NewEmbedProvider()
// 本地文件或目录provider.NewFileProvider("fingers.yaml", "pocs/")
// 远程 URLprovider.NewURLProvider("https://example.com/fingers.yaml", "")
// CyberHub APIcyberhub.NewProvider(url, key)
// 多源合并:embed + CyberHubclient.New(client.WithProvider(
provider.NewEmbedProvider(),
cyberhub.NewProvider(url, key),
))如果只需要单个引擎,可以跳过 Client 直接创建:
// Fingers - 指纹识别config:=fingers.NewConfig().
WithProvider(cyberhub.NewProvider("http://127.0.0.1:8080", "your_key"))
engine, _:=fingers.NewEngine(config)
frameworks, _:=engine.Match(httpResponseBytes)
// Neutron - POC 扫描config:=neutron.NewConfig().
WithProvider(cyberhub.NewProvider("http://127.0.0.1:8080", "your_key"))
engine, _:=neutron.NewEngine(config)
for_, t:=rangeengine.Get() {
result, _:=t.Execute("http://target.com", nil)
}
// GoGo - 端口扫描(Provider 自动加载 Fingers 和 Neutron)gogoConfig:=gogo.NewConfig().
WithProvider(cyberhub.NewProvider("http://127.0.0.1:8080", "your_key"))
gogoEngine, _:=gogo.NewEngine(gogoConfig)
results, _:=gogoEngine.Scan(gogo.NewContext(), "192.168.1.0/24", "80,443")
// Spray - HTTP 检测sprayEngine, _:=spray.NewEngine(nil)
results, _:=sprayEngine.Check(spray.NewContext(), []string{"http://example.com"})
// Zombie - 弱口令检测zombieEngine, _:=zombie.NewEngine(nil)
targets:= []zombie.Target{{IP: "192.168.1.1", Port: "22", Service: "ssh"}}
results, _:=zombieEngine.Brute(zombie.NewContext(), targets, []string{"root"}, []string{"123456"})SDK 采用四组件架构,定义在 pkg/types/types.go:
| 接口 | 职责 |
|---|---|
| Engine | Execute(Context, Task) → chan Result,实现具体扫描逻辑 |
| Context | 携带运行时配置(线程、超时、代理等) |
| Task | 定义扫描目标和参数 |
| Result | 返回扫描结果,通过 TypedResult[T] 实现类型安全 |
┌──────────────────────────┐
│ Client │
│ WithProvider / WithIndex │
└────┬──────────┬──────────┘
│ │
┌─────────┤ ┌──────▼──────┐
│ │ │ Index (可选) │
│ │ └──────────────┘
┌────▼───┐ ┌───▼────┐ ┌───────┐ ┌────────┐ ┌────────┐
│ Fingers │ │ Neutron │ │ GoGo │ │ Spray │ │ Zombie │
└────────┘ └────────┘ └───────┘ └────────┘ └────────┘
- 引擎懒加载,首次访问时创建
- 依赖自动注入(GoGo ← Fingers + Neutron,Spray ← Fingers)
- 扩展引擎通过
client.Register反向注册,Client 不直接导入 L2 引擎包 - Index 是可选的关联查询层,通过
WithIndex开启
所有引擎支持双重加载模式:
- 本地模式: 从嵌入数据或文件系统加载
- 远程模式: 从 Cyberhub API 加载,支持过滤条件
client.WithProvider(provider) // 共享 Cyberhub 数据源client.WithResourceProvider(rp) // 共享资源加载器client.WithIndex(opts) // 开启关联索引(可选)client.WithFingersConfig(cfg) // 覆盖 Fingers 配置client.WithNeutronConfig(cfg) // 覆盖 Neutron 配置gogo.WithClientConfig(cfg) // 覆盖 GoGo 配置spray.WithClientConfig(cfg) // 覆盖 Spray 配置zombie.WithClientConfig(cfg) // 覆盖 Zombie 配置c.Fingers() // *fingers.Enginec.Neutron() // *neutron.Enginegogo.FromClient(c) // *gogo.Enginespray.FromClient(c) // *spray.Enginezombie.FromClient(c) // *zombie.Enginec.Engine("name") // types.Engine,用于自定义注册引擎c.Index() // 获取关联索引c.Lookup(query) // 通用查询c.LookupResult(result) // 从引擎结果查询关联c.LookupByFinger("tomcat") // 按指纹名查询c.LookupByCVE("CVE-...") // 按 CVE 查询c.BuildIndex(ctx, opts...) // 构建独立索引// Fingersfingers.NewConfig().
WithProvider(provider). // 通过 Provider 加载(CyberHub/Embed/File/URL)WithMatchDetail() // 开启匹配细节// Neutronneutron.NewConfig().
WithProvider(provider).
WithCapacity(10) // 并发限制// GoGogogo.NewConfig().
WithProvider(provider). // 自动加载 Fingers + NeutronWithFingersEngine(fingersEng). // 或手动注入WithNeutronEngine(neutronEng).
WithCapacity(5000)
// Sprayspray.NewConfig().
WithFingersEngine(fingersEng).
WithMatchDetail().
WithCapacity(3000)
// Zombiezombie.NewConfig().
WithCapacity(500)// GoGogogo.NewContext().
SetThreads(1000).
SetVersionLevel(2). // 0=被动, 1=基础, 2=深度, 3=全量SetExploit("all"). // none/all/knownSetDelay(5)
// Sprayspray.NewContext().
SetThreads(100).
SetTimeout(10).
SetCrawlPlugin(true).
SetFinger(true)
// Zombiezombie.NewContext().
SetThreads(100).
SetTimeout(5).
SetTop(10) // 使用 top N 字典// 远程筛选(减少传输量)filter:=types.NewExportFilter().
WithTags("cms", "rce").
WithSources("github").
WithSeverities("critical", "high").
WithLimit(100)
provider:=cyberhub.NewProvider(url, key).WithFilter(filter)
// 本地筛选(加载后过滤)config:=fingers.NewConfig().
WithProvider(provider).
WithFilter(func(f*fingers.FullFinger) bool {
returnf.Finger.Protocol=="http"
})examples/ 目录提供了预构建的命令行工具:
cd examples
go build -o bin/fingers ./fingers
go build -o bin/neutron ./neutron
go build -o bin/gogo ./gogo
go build -o bin/spray ./spray
go build -o bin/cyberhub ./cyberhub
go build -o bin/association ./association详细使用方法参见 examples/README.md。
client/— 统一客户端(依赖注入、关联查询)fingers/— 指纹识别引擎neutron/— POC 扫描引擎gogo/— 端口扫描引擎(独立 Go module,反向注册到 Client)spray/— HTTP 检测引擎(独立 Go module,反向注册到 Client)zombie/— 弱口令检测引擎(独立 Go module,反向注册到 Client)pkg/types/— 核心接口(Engine / Provider / Context / Task / Result)pkg/cyberhub/— CyberHub 远程数据源pkg/provider/— 内置数据源(EmbedProvider / FileProvider / URLProvider)pkg/association/— 关联索引examples/— 示例程序docs/— 用户文档 ├── quickstart.md # 快速开始 ├── concepts.md # 核心概念 ├── fingers.md # Fingers 引擎 ├── neutron.md # Neutron 引擎 ├── gogo.md # GoGo 引擎 ├── spray.md # Spray 引擎 ├── cyberhub.md # Cyberhub 数据源 └── association.md # 关联查询
## 开发
### 运行测试
```bash
go test ./...
- 实现
pkg/types中的 Engine / Context / Task / Result 接口 - 在引擎包中调用
client.Register(name, factory)反向注册 - 提供
WithClientConfig/FromClient这类类型安全的薄封装 - 在
examples/中添加示例
MIT License