Skip to content

Repository files navigation

Chainreactors SDK

统一的安全扫描工具 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/sdk

快速开始

通过 Client 使用(推荐)

Client 是 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

数据源(Provider)

所有数据通过 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

接口职责
EngineExecute(Context, Task) → chan Result,实现具体扫描逻辑
Context携带运行时配置(线程、超时、代理等)
Task定义扫描目标和参数
Result返回扫描结果,通过 TypedResult[T] 实现类型安全

Client 架构

 ┌──────────────────────────┐
│ Client │
│ WithProvider / WithIndex │
└────┬──────────┬──────────┘
│ │
┌─────────┤ ┌──────▼──────┐
│ │ │ Index (可选) │
│ │ └──────────────┘
┌────▼───┐ ┌───▼────┐ ┌───────┐ ┌────────┐ ┌────────┐
│ Fingers │ │ Neutron │ │ GoGo │ │ Spray │ │ Zombie │
└────────┘ └────────┘ └───────┘ └────────┘ └────────┘
  • 引擎懒加载,首次访问时创建
  • 依赖自动注入(GoGo ← Fingers + Neutron,Spray ← Fingers)
  • 扩展引擎通过 client.Register 反向注册,Client 不直接导入 L2 引擎包
  • Index 是可选的关联查询层,通过 WithIndex 开启

数据源

所有引擎支持双重加载模式:

  • 本地模式: 从嵌入数据或文件系统加载
  • 远程模式: 从 Cyberhub API 加载,支持过滤条件

Client API

Option

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)

运行时 Context

// 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 ./...

添加新引擎

  1. 实现 pkg/types 中的 Engine / Context / Task / Result 接口
  2. 在引擎包中调用 client.Register(name, factory) 反向注册
  3. 提供 WithClientConfig / FromClient 这类类型安全的薄封装
  4. examples/ 中添加示例

License

MIT License

相关项目

About

No description, website, or topics provided.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages