像狐狸一样狡猾地猎捕暴露的秘密!
一个轻量级、跨平台的 CLI 工具,用于扫描你的文件系统以检测暴露的秘密、API 密钥和令牌。使用 Go 构建,追求极致性能且零依赖。
# macOS Apple Silicon (M1/M2/M3)
curl -L -o kyubisweep https://github.com/tanmayshahane/kyubisweep/releases/latest/kyubisweep-darwin-arm64
chmod +x kyubisweep
# 运行!
./kyubisweep --path /path/to/your/project
# 确保已安装 Go 1.21+
go version
# 克隆并构建
git clone https://github.com/tanmayshahane/kyubisweep.git
cd kyubisweep
go build -o kyubisweep ./cmd/sweep/main.go
# 运行!
./kyubisweep --path .
用法:
kyubisweep [选项]
选项:
--path <目录> 要扫描的路径(默认:当前目录)
--verbose 启用详细输出
--all 显示所有严重级别(默认:仅 HIGH)
--all-files 扫描所有文件,而不仅仅是基于文本的文件
--ext <扩展名> 额外扫描的扩展名(逗号分隔)
--json 以 JSON 文件形式输出报告
--no-report 不保存报告文件
--quiet 最小化输出,仅显示摘要
--move-to <路径> 将包含秘密的文件移动到隔离目录
--help 显示此帮助信息
示例:
kyubisweep --path ./my-project
kyubisweep --path . --all # 显示所有严重级别
kyubisweep --path . --ext log,dat # 添加自定义扩展名
kyubisweep --path . --move-to ./vault # 隔离敏感文件
kyubisweep --path . --json # 导出为 JSON
╔══════════════════════════════════════════════════════════════════════════╗
║ 🛡️ KYUBISWEEP 安全卫生评分卡 ║
╚══════════════════════════════════════════════════════════════════════════╝
🚨 发现关键问题
📊 风险分解
─────────────────────────────────────────
🚨 严重 9 ████████████████░░░░
🔴 高 2 ███░░░░░░░░░░░░░░░░░
🟡 中 0 ░░░░░░░░░░░░░░░░░░░░
🔵 低 0 ░░░░░░░░░░░░░░░░░░░░
🔍 发现详情
─────────────────────────────────────────
风险 类型 位置
[严重] AWS 访问密钥 ID ~/project/.env:5
[严重] PostgreSQL 连接 ~/project/config.yaml:12
[高] Stripe 密钥 ~/project/payment.js:42
📁 扫描路径:~/my-project
📄 分析文件数:2.9K
⏱️ 耗时:1.2s
graph TD
subgraph "Initialization (Main Goroutine)"
A[Start CLI] --> B{Parse Flags};
B -->|--path| C[Init Walker];
B -->|--move-to| D[Init Quarantine Mgr];
C --> E[Create Jobs Channel];
E --> F[Create Results Channel];
end
subgraph "Producer (Goroutine 1)"
G[Walker] -->|Finds Files| E;
style G fill:#f9f,stroke:#333,stroke-width:2px
style E fill:#ccf,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5
end
subgraph "Worker Pool (Goroutines 2...N)"
E -->|Read File Path| H[Worker 1];
E -->|Read File Path| I[Worker 2];
E -->|Read File Path| J[Worker N];
H -->|Read Content| K{Analyzer};
I -->|Read Content| K{Analyzer};
J -->|Read Content| K{Analyzer};
K -- No Secret --> L((Discard));
K -- Secret Found --> M[Send Finding];
M --> F;
style K fill:#ff9,stroke:#333,stroke-width:2px
end
subgraph "Consumer & Wrap up (Main Goroutine)"
F -->|Collect Findings| N[Reporter / Table UI];
style F fill:#ccf,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5
N --> O{Quarantine Requested?};
O -- Yes --> P[Move Files to Vault];
O -- No --> Q[Exit];
P --> Q;
end
%% Add a WaitGroup visual helper
H -.-> WG[sync.WaitGroup];
I -.-> WG;
J -.-> WG;
WG -.->|All Done| F;
kyubisweep/
├── cmd/
│ └── sweep/
│ └── main.go # CLI 入口点 + 工作池
├── pkg/
│ ├── analyzer/
│ │ └── analyzer.go # 熵 + 正则检测
│ ├── scanner/
│ │ └── walker.go # 并发目录遍历器
│ ├── reporter/
│ │ └── reporter.go # 安全评分卡输出
│ ├── quarantine/
│ │ └── manager.go # 安全文件转移
│ └── common/
│ └── colors.go # 共享 ANSI 颜色工具
├── reports/ # 生成的扫描报告
├── build/ # 跨平台编译的二进制文件
├── go.mod # Go 模块定义
├── build.sh # 跨平台构建脚本
└── README.md
# 使构建脚本可执行
chmod +x build.sh
# 为所有平台构建
./build.sh
# 输出:
# build/kyubisweep-darwin-arm64 (macOS Apple Silicon)
# build/kyubisweep-darwin-amd64 (macOS Intel)
# build/kyubisweep-linux-amd64 (Linux 64-bit)
# build/kyubisweep-linux-arm64 (Linux ARM)
# build/kyubisweep-windows-amd64.exe (Windows 64-bit)
发现了需要立即保护起来的秘密?使用 --move-to 转移文件:
./kyubisweep --path . --move-to ./secure_vault
安全特性:
欢迎贡献!请随时提交拉取请求。
MIT 许可证 —— 欢迎在你的项目中使用!
由那些不小心提交 API 密钥太多次的开发者,用 🦊 制作。
| 类别 | 示例 |
|---|
| 云凭证 | AWS Access Keys, Google API Keys, Azure tokens |
| 支付系统 | Stripe API keys (live & test) |
| 开发者工具 | GitHub PATs, NPM tokens, Heroku API keys |
| 通信 | Slack tokens, Discord bot tokens, Twilio keys |
| 数据库 | PostgreSQL, MongoDB, MySQL connection strings |
| 加密 | RSA/SSH/PGP private keys |
| 通用 | Passwords, API keys, Bearer tokens |