ExploitCraft/envleaks

GitHub: ExploitCraft/envleaks

一个用于扫描代码库、Git历史和Docker镜像中意外暴露的密钥和凭据的安全工具。

Stars: 16 | Forks: 1

# 🐾 envleaks [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/6811d9c931041702.svg)](https://github.com/ExploitCraft/envleaks/actions) [![PyPI](https://img.shields.io/pypi/v/envleaks)](https://pypi.org/project/envleaks/) [![Python](https://img.shields.io/pypi/pyversions/envleaks)](https://pypi.org/project/envleaks/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) ## 功能特性 - 🔍 **100+ 检测模式** — 覆盖 AWS、GitHub、OpenAI、Stripe、Slack、Twilio、GCP、Azure 等 - 📜 **Git 历史扫描** — 在历史提交记录中查找密钥,而不仅仅是当前状态 - 🐳 **Docker 就绪** — 可在容器和 CI/CD 管道中运行 - 📊 **多种输出格式** — 终端 (Rich)、JSON 和 SARIF (GitHub 高级安全) - ⚙️ **CI 模式** — 若发现密钥则以退出码 `1` 退出,阻止管道运行 - 🎯 **严重性过滤** — 仅关注 `critical` 和 `high`,跳过无关信息 - ⚡ **快速** — 自动跳过二进制文件、大文件和 `node_modules` ## 安装说明 ``` pip install envleaks ``` 或从源代码安装: ``` git clone https://github.com/ExploitCraft/envleaks cd envleaks pip install -e . ``` ## 快速开始 ``` # 扫描当前目录 envleaks scan . # 扫描特定项目 envleaks scan /path/to/project # 扫描单个文件 envleaks scan config.py # 仅显示关键和高风险发现 envleaks scan . --severity critical,high # 同时扫描所有过往 git 提交 envleaks scan . --git-history # 以 JSON 格式输出 envleaks scan . --format json --output report.json # CI 模式 — 若存在发现则退出码为 1,为 GitHub 输出 SARIF 格式 envleaks scan . --ci --format sarif --output envleaks.sarif ``` ## 示例输出 ``` ╭─ envleaks — secret & credential scanner ─╮ 📄 config/settings.py LINE SEVERITY RULE NAME MATCH 12 💀 CRITICAL AWS001 AWS Access Key ID AKIA...MPLE 18 🔴 HIGH GH001 GitHub Personal Access... ghp_...9012 34 🟡 MEDIUM GEN001 Generic Secret Assignment secr...word 📄 .env.backup 1 💀 CRITICAL DB001 Database connection URL post...b" ╭─ Scan Summary ──────────────────╮ Files scanned 47 Files skipped 12 Total findings 4 Critical 2 High 1 Medium 1 ╰─────────────────────────────────╯ ``` ## GitHub Actions 集成 将此步骤添加到你的工作流中,以阻止引入密钥的 PR: ``` - name: Scan for secrets run: | pip install envleaks envleaks scan . --ci --severity critical,high ``` 要将 SARIF 完全集成到 GitHub 的安全选项卡中: ``` - name: Scan for secrets (SARIF) run: | pip install envleaks envleaks scan . --format sarif --output envleaks.sarif - name: Upload to GitHub Security tab uses: github/codeql-action/upload-sarif@v3 with: sarif_file: envleaks.sarif ``` ## 检测规则 | 类别 | 规则数 | 示例 | |------|--------|------| | AWS | 3 | 访问密钥、秘密密钥、会话令牌 | | GitHub | 5 | PAT、OAuth、精细权限 PAT | | Google / GCP | 3 | API 密钥、服务账户 | | OpenAI | 2 | API 密钥、组织 ID | | Stripe | 4 | Live/测试密钥、Webhook | | Slack | 4 | Bot Token、Webhook URL | | 数据库 URL | 2 | PostgreSQL、MongoDB Atlas | | 私钥 | 5 | RSA、EC、OpenSSH、PGP | | 通用类型 | 3 | Bearer 令牌、URL 中的基本认证 | | + 其他 | 70+ | Twilio、Discord、Firebase、Azure... | 查看所有规则: ``` envleaks list-rules envleaks list-rules --severity critical ``` ## CLI 参考 ``` Usage: envleaks [OPTIONS] COMMAND [ARGS]... Commands: scan Scan PATH for secrets and credentials list-rules List all built-in detection rules Options for scan: --format terminal | json | sarif (default: terminal) --output, -o Write to file --severity critical,high,medium,low (comma-separated) --git-history Also scan all past git commits --max-commits Limit commits scanned with --git-history --ci Exit code 1 on findings (for pipelines) --include Glob pattern to include --exclude Glob pattern to exclude ``` ## HackerInc/ExploitCraft 生态系统的一部分 | 工具 | 描述 | |------|------| | **envleaks** | 代码库与 Git 历史扫描器(本仓库) | | [gitdork](https://github.com/ExploitCraft/gitdork) | Google/Shodan dork 生成器 | | [wifi-passview](https://github.com/ExploitCraft/wifi-passview) | 跨平台 WiFi 凭据转储工具 | | [ReconNinja](https://github.com/ExploitCraft/ReconNinja) | ReconNinja v6 — 21 阶段侦察框架 | | [VaultHound](https://github.com/ExploitCraft/VaultHound) | 密钥与凭据扫描器 | ## 许可证 MIT © [ExploitCraft](https://github.com/ExploitCraft)
标签:DevOps安全, DevSecOps, Docker安全, Git历史扫描, JSON报告, Linux安全, SARIF输出, Web截图, 上游代理, 严重性过滤, 代码安全扫描, 凭证扫描, 历史提交分析, 容器安全, 环境变量扫描, 秘密泄露检测, 网络安全研究, 请求拦截, 输出格式支持, 逆向工具