go-appsec/scout
GitHub: go-appsec/scout
一个用 Go 编写的轻量级被动侦察库,通过查询多个公开数据源帮助安全测试人员快速发现目标域名的子域名和 URL。
Stars: 1 | Forks: 1
[](https://github.com/go-appsec/scout/blob/main/LICENSE)
[](https://github.com/go-appsec/scout/actions/workflows/tests-main.yml)
[-Significant%20AI%2C%20mostly%20tested-2ca02c)](https://github.com/vibesdk/vibe-scale/blob/main/README.md)
一个轻量级的 Go 库,用于对域名进行被动侦察,通过查询公共 API 发现子域名和 URL。Scout 为安全测试中的目标枚举提供了一种极简且依赖极少的方法。
## 功能特性
- 符合人体工程学的基于迭代器的 API
- 可配置并行度的并发源查询
- 跨所有源自动去重
- 支持超时的上下文感知
- 最小化依赖
## 支持的结果类型
Scout 可以发现:
| 类型 | 描述 |
|------|-------------|
| Subdomains | 目标域名的子域名(例如,`api.example.com`) |
| URLs | 目标域名下的完整 URL(例如,`https://example.com/path`) |
## 快速开始
```
go get github.com/go-appsec/scout@latest
```
```
package main
import (
"context"
"fmt"
"github.com/go-appsec/scout"
)
func main() {
ctx := context.Background()
// Query all subdomain sources for a domain
for sub, err := range scout.Subdomains(ctx, "example.com") {
if err != nil {
// Ignore or handle errors, usually rate limits
continue
}
fmt.Println(sub)
}
}
```
## 使用示例
### 查询所有来源
```
ctx := context.Background()
// Get both subdomains and URLs from all sources
for result, err := range scout.Query(ctx, "example.com") {
if err != nil {
// Ignore or handle errors, usually rate limits
continue
}
fmt.Printf("[%s] %s: %s\n", result.Source, result.Type, result.Value)
}
```
### 仅查询 URL
```
// Get only URLs from URL-yielding sources
for url, err := range scout.URLs(ctx, "example.com") {
if err == nil {
fmt.Println(url)
}
}
```
### 并发与超时
```
// Configure parallelism and timeout
for sub, err := range scout.Subdomains(ctx, "example.com",
scout.WithParallelism(4), // 4 sources at once
scout.WithTimeout(30*time.Second), // 30s per source
) {
if err == nil {
fmt.Println(sub)
}
}
```
### 速率限制
```
// Apply global and per-source rate limits
for sub, err := range scout.Subdomains(ctx, "example.com",
scout.WithGlobalRateLimit(10), // 10 req/sec globally
scout.WithSourceRateLimit("commoncrawl", 0.25), // 15 req/min for commoncrawl
) {
if err == nil {
fmt.Println(sub)
}
}
```
### 用于提升限制的 API 密钥
```
// Some sources support optional API keys for higher rate limits
for sub, err := range scout.Subdomains(ctx, "example.com",
scout.WithAPIKey("virustotal", "your-api-key"),
scout.WithAPIKey("shodan", "your-api-key"),
) {
// Process results...
}
```
## API 参考
### 函数
| 函数 | 描述 |
|----------|-------------|
| `Query(ctx, domain, ...opts)` | 查询来源并产出所有结果(子域名和 URL) |
| `Subdomains(ctx, domain, ...opts)` | 查询来源并仅产出子域名 |
| `URLs(ctx, domain, ...opts)` | 查询来源并仅产出 URL |
### 选项
| 选项 | 描述 |
|--------|-------------|
| `WithSources([]Source)` | 指定要查询的来源 |
| `WithParallelism(n)` | 设置并发查询来源的数量(默认值:NumCPU×2) |
| `WithTimeout(duration)` | 设置每个来源的超时时间(默认值:30s) |
| `WithGlobalRateLimit(rps)` | 设置全局速率限制(请求数/秒) |
| `WithSourceRateLimit(name, rps)` | 设置每个来源的速率限制 |
| `WithHTTPClient(client)` | 使用自定义 HTTP 客户端 |
| `WithAPIKey(source, key)` | 为指定来源设置 API 密钥 |
### 来源注册表
| 函数 | 描述 |
|----------|-------------|
| `sources.All()` | 获取所有已注册的来源 |
| `sources.ByName(name)` | 根据名称获取来源 |
| `sources.ByNames(...names)` | 根据多个名称获取来源 |
| `sources.ByType(type)` | 获取产生特定结果类型的来源 |
| `sources.Names()` | 获取所有已注册来源的名称 |
### 类型
```
// Result represents a discovery from a source
type Result struct {
Type ResultType // Subdomain or URL
Value string // The discovered value
Source string // Which source found it
}
// ResultType indicates the kind of result
type ResultType uint8
const (
Subdomain ResultType = 1 << iota // Subdomain result
URL // URL result
)
```
## 可用来源
### 无需 API 密钥(11 个来源)
| 来源 | 产出 | 描述 |
|--------|--------|-------------|
| `anubis` | Subdomain | Anubis 子域名数据库 |
| `crtsh` | Subdomain | 证书透明度日志 |
| `commoncrawl` | Subdomain, URL | Common Crawl 网页存档 |
| `digitorus` | Subdomain | 证书详情数据库 |
| `hudsonrock` | Subdomain, URL | 数据泄露信息 |
| `rapiddns` | Subdomain | DNS 记录聚合器 |
| `sitedossier` | Subdomain | 域名分析工具 |
| `thc` | Subdomain | THC 子域名查询 API |
| `alienvault` | URL | AlienVault OTX URL 列表 |
| `hackertarget` | Subdomain | 主机搜索(无密钥时受限) |
| `reconeer` | Subdomain | 子域名枚举(无密钥时受限) |标签:API查询, ASM, GitHub, Go语言, Red Team, URL发现, Windows内核, 域名枚举, 子域名爆破, 安全工具库, 安全检测, 并发查询, 开源库, 搜索引擎爬虫, 日志审计, 漏洞挖掘前期准备, 白帽子, 目标枚举, 程序破解, 网络安全, 被动侦察, 资产测绘, 隐私保护