统一的安全扫描工具 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), // 可选:开启关联查询
)
defer c.Close()
// 获取引擎 — 依赖自动注入
// GoGo 自动获得 Fingers + Neutron 引擎
gogoEng, _ := c.Gogo()
results, _ := gogoEng.Scan(gogo.NewContext().SetThreads(1000), "192.168.1.0/24", "80,443")
// 关联查询 — 扫描结果直接查关联 POC
for _, r := range results {
related, _ := c.LookupByFinger(r.Frameworks.Names()...)
// related.Templates — 关联的 POC
}Client 的依赖注入关系:
GoGo → 自动注入 Fingers + Neutron
Spray → 自动注入 Fingers
如果只需要单个引擎,可以跳过 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 := range engine.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)
task := zombie.NewWeakpassTask([]zombie.Target{{IP: "192.168.1.1", Port: "22", Service: "ssh"}})
results, _ := zombieEngine.Weakpass(zombie.NewContext(), task)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)
- Index 是可选的关联查询层,通过
WithIndex开启
所有引擎支持双重加载模式:
- 本地模式: 从嵌入数据或文件系统加载
- 远程模式: 从 Cyberhub API 加载,支持过滤条件
client.WithProvider(provider) // 共享 Cyberhub 数据源
client.WithResourceProvider(rp) // 共享资源加载器
client.WithIndex(opts) // 开启关联索引(可选)
client.WithFingersConfig(cfg) // 覆盖 Fingers 配置
client.WithNeutronConfig(cfg) // 覆盖 Neutron 配置
client.WithGogoConfig(cfg) // 覆盖 GoGo 配置
client.WithSprayConfig(cfg) // 覆盖 Spray 配置
client.WithZombieConfig(cfg) // 覆盖 Zombie 配置c.Fingers() // *fingers.Engine
c.Neutron() // *neutron.Engine
c.Gogo() // *gogo.GogoEngine
c.Spray() // *spray.SprayEngine
c.Zombie() // *zombie.Enginec.Index() // 获取关联索引
c.Lookup(query) // 通用查询
c.LookupResult(result) // 从引擎结果查询关联
c.LookupByFinger("tomcat") // 按指纹名查询
c.LookupByCVE("CVE-...") // 按 CVE 查询
c.BuildIndex(ctx, opts...) // 构建独立索引// Fingers
fingers.NewConfig().
WithProvider(provider). // 远程加载
WithLocalFile("fingers.yaml"). // 或本地加载
WithMatchDetail() // 开启匹配细节
// Neutron
neutron.NewConfig().
WithProvider(provider).
WithLocalFile("./pocs").
WithCapacity(10) // 并发限制
// GoGo
gogo.NewConfig().
WithProvider(provider). // 自动加载 Fingers + Neutron
WithFingersEngine(fingersEng). // 或手动注入
WithNeutronEngine(neutronEng).
WithCapacity(5000)
// Spray
spray.NewConfig().
WithFingersEngine(fingersEng).
WithMatchDetail().
WithCapacity(3000)
// Zombie
zombie.NewConfig().
WithCapacity(500)// GoGo
gogo.NewContext().
SetThreads(1000).
SetVersionLevel(2). // 0=被动, 1=基础, 2=深度, 3=全量
SetExploit("all"). // none/all/known
SetDelay(5)
// Spray
spray.NewContext().
SetThreads(100).
SetTimeout(10).
SetCrawlPlugin(true).
SetFinger(true)
// Zombie
zombie.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 {
return f.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。
sdk/
├── client/ # 统一客户端(依赖注入、关联查询)
│ └── client.go
│
├── fingers/ # 指纹识别引擎
│ ├── engine.go # 核心引擎(Match / HTTPMatch / ServiceMatch)
│ ├── config.go # 配置与 FullFingers 类型
│ ├── types.go # Context / Task / Result 定义
│ ├── sender.go # HTTP 发送器接口
│ ├── additions.go # 动态扩展(AddFingers / AddFingersFile)
│ └── init.go
│
├── neutron/ # POC 扫描引擎
│ ├── engine.go # 核心引擎(自动编译模板)
│ ├── config.go # 配置
│ ├── types.go # Context / Task / Result 定义
│ ├── templates.go # Templates 辅助类型(Filter / Merge)
│ ├── additions.go # 动态扩展(AddPocs / AddPocsFile)
│ └── init.go
│
├── gogo/ # 端口扫描引擎
│ ├── gogo.go # 核心引擎(Scan / ScanStream / Workflow)
│ ├── types.go # Context / Config / Task 定义
│ └── init.go
│
├── spray/ # HTTP 检测引擎
│ ├── spray.go # 核心引擎(Check / Brute / BruteMany)
│ ├── types.go # Context / Config / Task 定义
│ ├── config.go # Option 默认值
│ └── init.go
│
├── zombie/ # 弱口令检测引擎
│ ├── engine.go # 核心引擎(Weakpass / WeakpassStream)
│ ├── types.go # Context / Config / Target / Task 定义
│ └── init.go
│
├── pkg/
│ ├── types/ # 核心接口与类型
│ │ ├── types.go # Engine / Context / Task / Result 接口 + 类型别名
│ │ ├── result.go # TypedResult[T] 泛型包装
│ │ ├── capacity.go # 并发容量控制
│ │ ├── registry.go # 引擎注册(供独立使用场景)
│ │ ├── stats.go # 执行统计
│ │ ├── export_filter.go # ExportFilter 导出筛选
│ │ ├── gogo.go # GogoOption 包装
│ │ └── spray.go # SprayOption 包装
│ │
│ ├── cyberhub/ # Cyberhub 远程数据源
│ │ ├── provider.go # Provider(Fingers / POCs 导出)
│ │ ├── client.go # HTTP 客户端(gzip 支持)
│ │ ├── api.go # API 响应结构
│ │ └── types.go # 类型定义
│ │
│ └── association/ # 关联索引(独立机制)
│ ├── index.go # Index 构建与实体管理
│ └── query.go # Query / Lookup / QueryFromResult
│
├── examples/ # 示例程序
│ ├── sdk_usage/ # Client 统一用法
│ ├── fingers/ # 指纹识别 CLI
│ ├── neutron/ # POC 扫描 CLI
│ ├── gogo/ # 端口扫描 CLI
│ ├── spray/ # HTTP 检测 CLI
│ ├── cyberhub/ # Cyberhub 数据加载
│ ├── association/ # 关联查询
│ ├── filter/ # 数据筛选
│ └── cases/ # 进阶用例
│
└── docs/ # 用户文档
├── quickstart.md # 快速开始
├── concepts.md # 核心概念
├── fingers.md # Fingers 引擎
├── neutron.md # Neutron 引擎
├── gogo.md # GoGo 引擎
├── spray.md # Spray 引擎
├── cyberhub.md # Cyberhub 数据源
└── association.md # 关联查询
go test ./...- 实现
pkg/types中的 Engine / Context / Task / Result 接口 - 创建引擎包(engine.go / types.go / init.go)
- 在
client/client.go中添加 ensure 方法和访问器 - 在
examples/中添加示例
MIT License