|
12 | 12 | - [https://github.com/JaimePolop/RExpository](https://github.com/JaimePolop/RExpository) |
13 | 13 | - [https://github.com/Yelp/detect-secrets](https://github.com/Yelp/detect-secrets) |
14 | 14 | - [https://github.com/hisxo/gitGraber](https://github.com/hisxo/gitGraber) |
15 | | -- [https://github.com/eth0izzle/shhgit](https://github.com/eth0izzle/shhgit) |
| 15 | +- https://github.com/eth0izzle/shhgit (unmaintained) |
16 | 16 | - [https://github.com/techgaun/github-dorks](https://github.com/techgaun/github-dorks) |
17 | | -- [https://github.com/michenriksen/gitrob](https://github.com/michenriksen/gitrob) |
18 | | -- [https://github.com/anshumanbh/git-all-secrets](https://github.com/anshumanbh/git-all-secrets) |
| 17 | +- https://github.com/michenriksen/gitrob (archived) |
| 18 | +- https://github.com/anshumanbh/git-all-secrets (archived) |
19 | 19 | - [https://github.com/awslabs/git-secrets](https://github.com/awslabs/git-secrets) |
20 | 20 | - [https://github.com/kootenpv/gittyleaks](https://github.com/kootenpv/gittyleaks) |
21 | 21 | - [https://github.com/obheda12/GitDorker](https://github.com/obheda12/GitDorker) |
22 | 22 |
|
| 23 | +> Notes |
| 24 | +> - TruffleHog v3 can verify many credentials live and scan GitHub orgs, issues/PRs, gists, and wikis. Example: `trufflehog github --org <ORG> --results=verified`. |
| 25 | +> - Gitleaks v8 supports scanning git history, directories and archives: `gitleaks detect -v --source .` or `gitleaks detect --source <repo> --log-opts="--all"`. |
| 26 | +> - Nosey Parker focuses on high-throughput scanning with curated rules and has an Explorer UI for triage. Example: `noseyparker scan --datastore np.db <path|repo>` then `noseyparker report --datastore np.db`. |
| 27 | +> - ggshield (GitGuardian CLI) provides pre-commit/CI hooks and Docker image scanning: `ggshield secret scan repo <path-or-url>`. |
| 28 | +
|
| 29 | +### Where secrets commonly leak in GitHub |
| 30 | + |
| 31 | +- Repository files in default and non-default branches (search `repo:owner/name@branch` in the UI). |
| 32 | +- Full git history and other branches/tags (clone and scan with gitleaks/trufflehog; GitHub search focuses on indexed content). |
| 33 | +- Issues, pull requests, comments, and descriptions (TruffleHog GitHub source supports these via flags like `--issue-comments`, `--pr-comments`). |
| 34 | +- Actions logs and artifacts of public repositories (masking is best-effort; review logs/artifacts if visible). |
| 35 | +- Wikis and release assets. |
| 36 | +- Gists (search with tooling or the UI; some tools can include gists). |
| 37 | + |
| 38 | +> Gotchas |
| 39 | +> - GitHub’s REST code search API is legacy and does not support regex; prefer the Web UI for regex searches. The gh CLI uses the legacy API. |
| 40 | +> - Only files below a certain size are indexed for search. To be thorough, clone and scan locally with a secrets scanner. |
| 41 | +
|
| 42 | +### Programmatic org-wide scanning |
| 43 | + |
| 44 | +- TruffleHog (GitHub source): |
| 45 | +```bash |
| 46 | +export GITHUB_TOKEN=<token> |
| 47 | +trufflehog github --org Target --results=verified \ |
| 48 | + --include-wikis --issue-comments --pr-comments --gist-comments |
| 49 | +``` |
| 50 | +- Gitleaks over all org repos (clone shallow and scan): |
| 51 | +```bash |
| 52 | +gh repo list Target --limit 1000 --json nameWithOwner,url \ |
| 53 | +| jq -r '.[].url' | while read -r r; do |
| 54 | + tmp=$(mktemp -d); git clone --depth 1 "$r" "$tmp" && \ |
| 55 | + gitleaks detect --source "$tmp" -v || true; rm -rf "$tmp"; |
| 56 | +done |
| 57 | +``` |
| 58 | +- Nosey Parker over a mono checkout: |
| 59 | +```bash |
| 60 | +# after cloning many repos beneath ./org |
| 61 | +noseyparker scan --datastore np.db org/ && noseyparker report --datastore np.db |
| 62 | +``` |
| 63 | +- ggshield quick scans: |
| 64 | +```bash |
| 65 | +# current working tree |
| 66 | +ggshield secret scan path -r . |
| 67 | +# full git history of a repo |
| 68 | +ggshield secret scan repo <path-or-url> |
| 69 | +``` |
| 70 | + |
| 71 | +> Tip: For git history, prefer scanners that parse `git log -p --all` to catch removed secrets. |
| 72 | +
|
| 73 | +### Updated dorks for modern tokens |
| 74 | + |
| 75 | +- GitHub tokens: `ghp_` `gho_` `ghu_` `ghs_` `ghr_` `github_pat_` |
| 76 | +- Slack tokens: `xoxb-` `xoxp-` `xoxa-` `xoxs-` `xoxc-` `xoxe-` |
| 77 | +- Cloud and general: |
| 78 | + - `AWS_ACCESS_KEY_ID` `AWS_SECRET_ACCESS_KEY` `aws_session_token` |
| 79 | + - `GOOGLE_API_KEY` `AZURE_TENANT_ID` `AZURE_CLIENT_SECRET` |
| 80 | + - `OPENAI_API_KEY` `ANTHROPIC_API_KEY` |
| 81 | + |
23 | 82 | ### **Dorks** |
24 | 83 |
|
25 | 84 | ```bash |
@@ -304,7 +363,15 @@ AWS SECRET |
304 | 363 | "private" extension:pgp |
305 | 364 | ``` |
306 | 365 |
|
307 | | -{{#include ../../banners/hacktricks-training.md}} |
| 366 | +{{#ref}} |
| 367 | +wide-source-code-search.md |
| 368 | +{{#endref}} |
| 369 | + |
308 | 370 |
|
309 | 371 |
|
310 | 372 |
|
| 373 | +## References |
| 374 | + |
| 375 | +- Keeping secrets out of public repositories (GitHub Blog, Feb 29, 2024): https://github.blog/news-insights/product-news/keeping-secrets-out-of-public-repositories/ |
| 376 | +- TruffleHog v3 – Find, verify, and analyze leaked credentials: https://github.com/trufflesecurity/trufflehog |
| 377 | +{{#include ../../banners/hacktricks-training.md}} |
0 commit comments