{"id":49278707,"url":"https://github.com/chainreactors/sdk","last_synced_at":"2026-04-25T17:31:38.557Z","repository":{"id":331852848,"uuid":"1120436002","full_name":"chainreactors/sdk","owner":"chainreactors","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-11T05:03:49.000Z","size":195,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-11T15:41:23.413Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chainreactors.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-21T07:52:27.000Z","updated_at":"2026-01-11T05:56:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/chainreactors/sdk","commit_stats":null,"previous_names":["chainreactors/sdk"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/chainreactors/sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainreactors%2Fsdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainreactors%2Fsdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainreactors%2Fsdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainreactors%2Fsdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chainreactors","download_url":"https://codeload.github.com/chainreactors/sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainreactors%2Fsdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32270658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-25T17:31:38.041Z","updated_at":"2026-04-25T17:31:38.549Z","avatar_url":"https://github.com/chainreactors.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chainreactors SDK\n\n统一的安全扫描工具 Go SDK，提供一致的接口设计。\n\n## 概述\n\nChainreactors SDK 为多个安全扫描工具提供统一接口：\n\n- **Fingers**: Web 指纹识别（HTTP/Socket）\n- **Neutron**: POC/漏洞扫描\n- **GoGo**: 集成指纹识别和 POC 检测的端口扫描\n- **Spray**: HTTP 批量检测和路径爆破\n\n## 安装\n\n```bash\ngo get github.com/chainreactors/sdk\n```\n\n## 架构设计\n\n### 核心架构\n\nSDK 采用简单的四组件架构：\n\n1. **Engine（引擎）**: 实现具体的扫描逻辑\n2. **Context（上下文）**: 携带配置和控制信息\n3. **Task（任务）**: 定义扫描目标\n4. **Result（结果）**: 返回扫描结果\n\n每个引擎可以独立使用，也可以与其他引擎集成（如 GoGo 同时集成 Fingers 和 Neutron）。\n\n### 数据源\n\n所有引擎支持双重加载模式：\n\n- **本地模式**: 从嵌入数据或文件系统加载\n- **远程模式**: 从 Cyberhub API 加载，支持 sources 过滤\n\n## 快速开始\n\n### Fingers - 指纹识别\n\n```go\nimport (\n    \"github.com/chainreactors/sdk/fingers\"\n)\n\n// 创建并加载引擎\nconfig := fingers.NewConfig()\nconfig.WithCyberhub(\"http://127.0.0.1:8080\", \"your_key\")\n\nengine, _ := fingers.NewEngine(config)\n\n// 方式一：使用 Match API 直接检测\nframeworks, _ := engine.Match(httpResponseBytes)\n\n// 方式二：使用底层 Engine\nlibEngine := engine.Get()\nframeworks, _ = libEngine.DetectContent(httpResponseBytes)\n```\n\n### Neutron - POC 扫描\n\n```go\nimport (\n    \"github.com/chainreactors/sdk/neutron\"\n)\n\n// 创建并加载引擎\nconfig := neutron.NewConfig()\nconfig.WithCyberhub(\"http://127.0.0.1:8080\", \"your_key\")\n\nengine, _ := neutron.NewEngine(config)\ntemplates := engine.Get()  // 自动编译\n\n// 执行 POC\nfor _, t := range templates {\n    result, _ := t.Execute(\"http://target.com\", nil)\n    if result.Matched {\n        // 处理漏洞\n    }\n}\n```\n\n### GoGo - 集成扫描\n\n```go\nimport (\n    \"github.com/chainreactors/sdk/gogo\"\n    \"github.com/chainreactors/sdk/fingers\"\n    \"github.com/chainreactors/sdk/neutron\"\n)\n\n// 加载指纹库\nfingersEngine, _ := fingers.NewEngine(fingersConfig)\n\n// 加载 POC\nneutronEngine, _ := neutron.NewEngine(neutronConfig)\n\n// 创建集成扫描器\ngogoConfig := gogo.NewConfig().\n    WithFingersEngine(fingersEngine).\n    WithNeutronEngine(neutronEngine)\ngogoEngine := gogo.NewEngine(gogoConfig)\ngogoEngine.Init()\n\n// 执行扫描\ngogoCtx := gogo.NewContext().\n    SetThreads(1000).\n    SetVersionLevel(2).\n    SetExploit(\"all\").\n    SetDelay(5)\ntask := gogo.NewScanTask(\"192.168.1.0/24\", \"80,443,8080\")\nresultCh, _ := gogoEngine.Execute(gogoCtx, task)\n\nfor result := range resultCh {\n    // 处理结果\n}\n```\n\n### Spray - HTTP 检测\n\n```go\nimport (\n    \"github.com/chainreactors/sdk/spray\"\n)\n\nengine := spray.NewEngine(nil)\nengine.Init()\n\nurls := []string{\"http://example.com\", \"http://target.com\"}\nsprayCtx := spray.NewContext().\n    SetThreads(100).\n    SetTimeout(10)\ntask := spray.NewCheckTask(urls)\nresultCh, _ := engine.Execute(sprayCtx, task)\n\nfor result := range resultCh {\n    sprayResult := result.(*spray.Result).SprayResult()\n    // 处理结果\n}\n```\n\n## 配置\n\n### Fingers 配置\n\n```go\nconfig := fingers.NewConfig()\nconfig.WithCyberhub(\"http://127.0.0.1:8080\", \"your_key\")\nconfig.SetSources(\"github\")       // 可选：按来源过滤\nconfig.WithLocalFile(\"fingers.yaml\") // 可选：从导出的 YAML 加载\nconfig.SetTimeout(10 * time.Second)\n```\n\n### Neutron 配置\n\n```go\nconfig := neutron.NewConfig()\nconfig.WithCyberhub(\"http://127.0.0.1:8080\", \"your_key\")\nconfig.SetSources(\"github\")       // 可选：按来源过滤\nconfig.WithLocalFile(\"./pocs\") // 可选：本地 POC 目录\nconfig.SetTimeout(10 * time.Second)\n```\n\n### GoGo 配置\n\n```go\nconfig := gogo.NewConfig().\n    WithFingersEngine(fingersEngine).\n    WithNeutronEngine(neutronEngine)\n```\n\n### GoGo 运行时上下文\n\n```go\nctx := gogo.NewContext().\n    SetThreads(1000).\n    SetVersionLevel(2).         // 指纹识别级别（见下方说明）\n    SetExploit(\"all\").          // none/all/known\n    SetDelay(5)                 // 请求超时时间\n```\n\n**指纹识别级别说明**:\n\n- **Level 0 (被动模式)**: 仅分析响应内容，不发送主动探测请求\n  - 适用场景：快速扫描、隐蔽性要求高\n  - 优点：速度快、流量小、不易被检测\n  - 缺点：识别准确度较低\n\n- **Level 1 (基础模式)**: 使用指纹级别的主动探测\n  - 发送finger-level的send_data探测请求\n  - 适用场景：常规扫描、平衡速度和准确度\n  - 优点：准确度较高、流量适中\n  - 缺点：会产生额外的探测流量\n\n- **Level 2 (全量模式)**: 使用指纹+规则级别的主动探测\n  - 发送finger-level和rule-level的send_data探测请求\n  - 适用场景：深度扫描、要求最高准确度\n  - 优点：识别最准确、覆盖最全面\n  - 缺点：速度较慢、流量较大\n\n### Spray 运行时上下文\n\n```go\nctx := spray.NewContext().\n    SetThreads(100).\n    SetTimeout(10)\n```\n\n## 命令行工具\n\n`examples/` 目录提供了预构建的命令行工具：\n\n```bash\n# 构建所有工具\ncd examples\ngo build -o fingers/fingers.exe ./fingers/main.go\ngo build -o neutron/neutron.exe ./neutron/main.go\ngo build -o gogo/gogo.exe ./gogo/main.go\ngo build -o spray/spray.exe ./spray/main.go\n```\n\n详细使用方法参见 [examples/README.md](examples/README.md)。\n\n## 项目结构\n\n```\nsdk/\n├── fingers/              # 指纹识别引擎\n│   ├── engine.go        # 核心引擎实现\n│   ├── config.go        # 配置\n│   ├── types.go         # 类型定义\n│   ├── additions.go     # 扩展方法 (AddFingers, AddFingersFile)\n│   ├── init.go          # 注册入口\n│   └── README.md        # 引擎文档\n│\n├── neutron/             # POC 扫描引擎\n│   ├── engine.go        # 核心引擎（自动编译）\n│   ├── config.go        # 配置\n│   ├── types.go         # 类型定义\n│   ├── templates.go     # Templates 辅助类型 (Filter, Merge)\n│   ├── additions.go     # 扩展方法 (AddPocs, AddPocsFile)\n│   └── README.md        # 引擎文档\n│\n├── gogo/                # 端口扫描（集成）\n│   ├── gogo.go          # 支持 Fingers/Neutron 的引擎\n│   ├── types.go         # 类型定义和配置\n│   ├── init.go          # 注册入口\n│   └── README.md        # 引擎文档\n│\n├── spray/               # HTTP 检测引擎\n│   ├── spray.go         # 核心引擎实现\n│   ├── types.go         # 类型定义和配置\n│   ├── init.go          # 注册入口\n│   └── README.md        # 引擎文档\n│\n├── pkg/\n│   ├── cyberhub/        # 统一 API 客户端\n│   │   ├── client.go    # HTTP 客户端（支持 gzip）\n│   │   ├── config.go    # 客户端配置\n│   │   └── types.go     # API 类型\n│   ├── association/     # 关联索引\n│   │   └── index.go     # 指纹-POC 关联索引\n│   └── interface.go     # 核心 SDK 接口\n│\n└── examples/            # CLI 工具实现\n    ├── fingers/\n    ├── neutron/\n    ├── gogo/\n    ├── spray/\n    └── README.md\n```\n\n## 核心特性\n\n### Cyberhub 集成\n\n所有引擎都支持从 Cyberhub 加载数据：\n- Gzip 压缩处理\n- 基于 sources 的过滤\n- API Key 认证\n\n### POC 自动编译\n\nNeutron 引擎在加载时自动编译 POC：\n- 无需手动编译\n- 编译失败的 POC 自动跳过\n- ExecuterOptions 从引擎配置生成\n\n### GoGo 集成\n\nGoGo 可以同时集成 Fingers 和 Neutron：\n- 模板按指纹、ID、标签建立索引\n- 9,444 个 POC 生成 61,267 条索引（多重索引）\n\n### 数据筛选\n\nSDK 支持两种筛选方式：\n\n#### 1. 远程筛选（请求 Cyberhub 时过滤）\n\n使用 `ExportFilter` 在请求 API 时筛选，减少传输数据量：\n\n```go\nimport (\n    \"time\"\n    \"github.com/chainreactors/sdk/fingers\"\n    \"github.com/chainreactors/sdk/neutron\"\n    \"github.com/chainreactors/sdk/pkg/cyberhub\"\n)\n\n// 指纹筛选\nfilter := cyberhub.NewExportFilter().\n    WithTags(\"cms\", \"framework\").            // 按标签筛选\n    WithSources(\"github\").                   // 按来源筛选\n    WithLimit(100).                          // 限制数量\n    WithUpdatedAfter(time.Now().AddDate(0, -1, 0)) // 最近一个月更新的\n\nconfig := fingers.NewConfig().\n    WithCyberhub(\"http://127.0.0.1:8080\", \"your_key\")\nconfig.ExportFilter = filter\n\nengine, _ := fingers.NewEngine(config)\n\n// POC 筛选\npocFilter := cyberhub.NewExportFilter().\n    WithTags(\"cve\", \"rce\").                  // 按标签筛选\n    WithSources(\"nuclei\").                   // 按来源筛选\n    WithCreatedAfter(time.Now().AddDate(-1, 0, 0)) // 最近一年创建的\n\nnConfig := neutron.NewConfig().\n    WithCyberhub(\"http://127.0.0.1:8080\", \"your_key\")\nnConfig.ExportFilter = pocFilter\n\nnEngine, _ := neutron.NewEngine(nConfig)\n```\n\n#### 2. 本地筛选（加载后在内存中过滤）\n\n使用 `FullFingers.Filter` 或 `Templates.Filter` 对已加载的数据进行二次过滤：\n\n```go\nimport (\n    \"github.com/chainreactors/sdk/fingers\"\n    \"github.com/chainreactors/sdk/neutron\"\n    neutronTemplates \"github.com/chainreactors/neutron/templates\"\n)\n\n// 加载指纹后筛选\nfConfig := fingers.NewConfig().WithCyberhub(\"http://127.0.0.1:8080\", \"your_key\")\nfEngine, _ := fingers.NewEngine(fConfig)\n\n// 获取并过滤指纹（按协议筛选）\nallFingers := fConfig.FullFingers\nhttpFingers := allFingers.Filter(func(f *fingers.FullFinger) bool {\n    return f.Finger != nil \u0026\u0026 f.Finger.Protocol == \"http\"\n})\n\n// 加载 POC 后筛选\nnConfig := neutron.NewConfig().WithCyberhub(\"http://127.0.0.1:8080\", \"your_key\")\nnEngine, _ := neutron.NewEngine(nConfig)\n\n// 使用 Templates.Filter 筛选\nallTemplates := (neutron.Templates{}).Merge(nEngine.Get())\n\n// 按严重级别筛选\nhighSeverity := allTemplates.Filter(func(t *neutronTemplates.Template) bool {\n    severity := t.Info.Severity\n    return severity == \"critical\" || severity == \"high\"\n})\n\n// 按标签筛选\nrceTemplates := allTemplates.Filter(func(t *neutronTemplates.Template) bool {\n    for _, tag := range t.GetTags() {\n        if tag == \"rce\" {\n            return true\n        }\n    }\n    return false\n})\n```\n\n### 基于指纹筛选 POC 示例\n\n下面示例演示：Fingers 命中指纹后，使用 `neutron.Templates.Filter` 从模板集中筛选相关 POC 并执行。\n\n```go\npackage main\n\nimport (\n\t\"strings\"\n\n\t\"github.com/chainreactors/sdk/fingers\"\n\t\"github.com/chainreactors/sdk/neutron\"\n\tneutronTemplates \"github.com/chainreactors/neutron/templates\"\n)\n\nfunc main() {\n\t// 1) 指纹识别\n\tfConfig := fingers.NewConfig().WithCyberhub(\"http://127.0.0.1:8080\", \"your_key\")\n\tfEngine, _ := fingers.NewEngine(fConfig)\n\n\t// 使用 Match API 直接匹配\n\tframeworks, _ := fEngine.Match([]byte(\"raw http response\"))\n\n\t// 收集指纹名称\n\tfingerNames := make(map[string]struct{})\n\tfor _, frame := range frameworks {\n\t\tfingerNames[strings.ToLower(frame.Name)] = struct{}{}\n\t}\n\n\t// 2) 加载 POC 并使用 Filter 筛选\n\tnConfig := neutron.NewConfig().WithCyberhub(\"http://127.0.0.1:8080\", \"your_key\")\n\tnEngine, _ := neutron.NewEngine(nConfig)\n\n\t// 使用 Templates.Filter 按指纹/标签筛选\n\tfiltered := (neutron.Templates{}).Merge(nEngine.Get()).Filter(func(t *neutronTemplates.Template) bool {\n\t\t// 按 Fingers 字段匹配\n\t\tfor _, finger := range t.Fingers {\n\t\t\tif _, ok := fingerNames[strings.ToLower(finger)]; ok {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\t// 按 Tags 匹配\n\t\tfor _, tag := range t.GetTags() {\n\t\t\tif _, ok := fingerNames[strings.ToLower(tag)]; ok {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t})\n\n\t// 3) 执行筛选后的 POC\n\ttask := \u0026neutron.ExecuteTask{\n\t\tTarget:    \"http://target.example\",\n\t\tTemplates: filtered.Templates(),\n\t}\n\tresultCh, _ := nEngine.Execute(neutron.NewContext(), task)\n\tfor range resultCh {\n\t\t// consume results\n\t}\n}\n```\n\n也可以使用 `pkg/association` 包中的 `FingerPOCIndex` 进行更高效的关联查询。\n\n### 动态扩展\n\n引擎支持在运行时动态添加指纹和 POC：\n\n```go\n// Fingers: 动态添加指纹\nengine.AddFingers(newFingers)           // 添加指纹切片\nengine.AddFingersFile(\"./custom.yaml\")  // 从文件/目录加载\n\n// Neutron: 动态添加 POC\nengine.AddPocs(newTemplates)            // 添加模板切片\nengine.AddPocsFile(\"./custom-pocs/\")    // 从文件/目录加载\n```\n\n## 开发\n\n### 运行测试\n\n```bash\n# 运行所有测试\ngo test ./...\n\n# 运行特定包的测试\ngo test ./fingers -v\ngo test ./neutron -v\ngo test ./gogo -v\ngo test ./spray -v\n```\n\n### 添加新引擎\n\n1. 实现 `pkg/interface.go` 中的核心接口\n2. 创建引擎包，包含 `engine.go`、`config.go`、`init.go`\n3. 在 `engine.go` 的 init 函数中注册\n4. 在 `examples/` 中添加 CLI 工具\n\n## License\n\nMIT License\n\n## 相关项目\n\n- [Fingers](https://github.com/chainreactors/fingers) - 指纹识别库\n- [Neutron](https://github.com/chainreactors/neutron) - POC 框架\n- [GoGo](https://github.com/chainreactors/gogo) - 端口扫描器\n- [Spray](https://github.com/chainreactors/spray) - HTTP 扫描器\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainreactors%2Fsdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainreactors%2Fsdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainreactors%2Fsdk/lists"}