cognis-digital/toolgraph
GitHub: cognis-digital/toolgraph
一个将安全与 OSINT 工具目录建模为有向图的 CLI 注册表,支持关系遍历与失效链接审计。
Stars: 0 | Forks: 0
# toolgraph
一个被建模为有向图的安全/OSINT 工具的可查询注册表 —— 注册工具、过滤工具、遍历类型化关系,并审计它们的链接。
`toolgraph` 将安全与 OSINT 工具的目录以图的形式进行维护:每个工具都是一个
**node**(节点:名称、类别、语言、URL、标签),每个**relation**(关系)都是工具之间类型化的
**edge**(边)—— `alternative-to`、`complements` 或 `depends-on`。你可以
按类别/标签/语言查询目录,询问“nmap 的替代工具有哪些?”,
并使用 HTTP HEAD 请求审计每个 URL,以标记失效或过时的链接。
该注册表是一个单一的格式化打印 JSON 文件,你可以提交、对比差异并手动编辑它。
由 Cognis Digital 构建。仅使用标准库,无外部依赖。
仅供防御和分析用途。
## 安装
```
# 安装 CLI (Go 1.22+)
go install github.com/cognis-digital/toolgraph/cmd/toolgraph@latest
```
或者从克隆的代码库中构建:
```
git clone https://github.com/cognis-digital/toolgraph
cd toolgraph
go build ./...
go build -o toolgraph ./cmd/toolgraph
```
使用内置的初始目录开始体验:
```
cp examples/seed.json toolgraph.json
toolgraph stats
```
## 功能
- **图数据模型** —— 将工具作为节点,将类型化关系作为有向边,支持广度优先遍历。
- **`add`** —— 注册一个工具(`-name -category -lang -url -tags`)和/或将其与另一个工具建立链接(`-relation -target`)。重新添加已存在的工具时,只会更新你传入的字段。
- **`query`** —— 列出工具,支持通过 `--category`、`--tag` 和/或 `--lang` 进行过滤;使用 `--json` 获取机器可读输出。
- **`related`** —— 显示某个工具的相邻节点(直接相邻或达到指定的 `--depth`),可选择限制为某一个 `--relation` 以及指定的 `--direction`(`out`/`in`/`both`)。
- **`audit`** —— 通过 HEAD 请求检查每个工具的 URL(带有边界的 `--timeout`,并发的 `--workers`),并将其分类为 `OK` / `STALE` / `DEAD` / `SKIPPED`。当出现失效链接时以非零状态退出(便于在 CI/cron 中使用)。
- **`stats`** —— 统计工具、关系、类别、语言和标签的数量。
- 所有读取命令均支持 **JSON 或表格输出**(`--json`)。
- **原子化、格式化打印的 JSON** 持久化存储(默认为 `./toolgraph.json`)。
- 位于 `examples/seed.json` 中包含 14 个知名工具的**初始目录**。
## 用法
```
toolgraph [flags]
Commands:
add Register a tool (or add a relation to an existing one)
query List tools, optionally filtered by category/tag/language
related Show tools related to a given tool (traverses relations)
audit Check each tool URL via HTTP HEAD and flag OK/STALE/DEAD links
stats Print registry statistics
help Show this help
```
大多数命令接受 `-file `(默认为 `./toolgraph.json`)和 `-json`。
### 注册工具和关系
```
toolgraph add -name nmap -category network-scanning -lang C -url https://nmap.org -tags network,recon
toolgraph add -name masscan -category network-scanning -lang C \
-url https://github.com/robertdavidgraham/masscan \
-relation alternative-to -target nmap
```
### 按类别查询
```
$ toolgraph query -category osint
NAME CATEGORY LANG TAGS URL
amass osint Go dns,footprint,subdomains https://github.com/owasp-amass/amass
spiderfoot osint Python automation,footprint,recon https://www.spiderfoot.net
subfinder osint Go dns,passive,subdomains https://github.com/projectdiscovery/subfinder
theharvester osint Python email,footprint,recon https://github.com/laramies/theHarvester
4 tool(s)
```
### 遍历关系
```
$ toolgraph related nmap
RELATION DIR TOOL CATEGORY URL
alternative-to in masscan network-scanning https://github.com/robertdavidgraham/masscan
alternative-to in rustscan network-scanning https://github.com/RustScan/RustScan
2 relation(s) for "nmap"
```
当另一个工具指向当前工具时,`DIR` 为 `in`(这里,masscan 和 rustscan 被注册为*指向* nmap 的替代工具)。使用 `-depth 2 -direction both` 可以在图中进一步遍历。
### 审计链接
```
toolgraph audit -timeout 5s -workers 8
```
```
STATUS HTTP LATENCY NAME URL
OK 200 142ms nmap https://nmap.org
DEAD - 2.0s oldtool https://example.invalid/gone
STALE 403 88ms guarded https://example.com/protected
summary: 1 OK, 1 STALE, 1 DEAD, 1 SKIPPED (of 4)
```
`STALE` 涵盖了重定向和可访问但受保护的响应(401/403/405/429);`DEAD` 涵盖了 404/410、5xx 以及无法访问的主机;`SKIPPED` 表示没有 URL 的条目。
### 统计信息
```
$ toolgraph stats
tools: 14
relations: 11
categories:
osint 4
network-scanning 3
traffic-analysis 3
intrusion-detection 2
web-testing 2
languages:
C 6
Python 3
Go 2
C++ 1
Java 1
Rust 1
```
## 注册表格式
`toolgraph.json` 是纯粹的、格式化打印的 JSON —— 可以安全地提交和手动编辑:
```
{
"version": 1,
"tools": [
{ "name": "nmap", "category": "network-scanning", "language": "C",
"url": "https://nmap.org", "tags": ["discovery", "network", "ports", "recon"] }
],
"relations": [
{ "from": "masscan", "to": "nmap", "relation": "alternative-to" }
]
}
```
## 开发
```
go build ./...
go vet ./...
go test ./...
```
测试是无网络的:审计路径是使用 `net/http/httptest` 来执行的。
## 许可证
许可证:COCL 1.0
标签:ESC4, Go, Homebrew安装, OSINT, Ruby工具, 文档结构分析, 日志审计, 网络安全资源