Loading...
Master the Art of Finding API Keys, Credentials and Sensitive Data in Public Repositories
Reconnaissance is the foundation of any successful bug bounty journey and one of the most overlooked goldmines is GitHub. Developers often unknowingly push sensitive data into public repositories, giving ethical hackers a powerful vector to uncover secrets, tokens, credentials and much more.
In this article, I'll walk you through manual and automated techniques to extract valuable data from GitHub. We'll use filters, dorks and tools — everything you need to perform impactful recon using only open-source intelligence (OSINT).
Start by heading over to GitHub.com and typing your target domain along with a sensitive keyword in the search bar.
"example.com" passwordTo make the results more relevant, format your keyword like a JSON key-value pair. Why? Because secrets stored in JSON often follow a predictable key-value pattern. This helps filter out noise and lets you focus on the juicy stuff — credentials, API keys and access tokens.
"example.com" "password":
You'll immediately notice a smaller set of results but each is more precise, containing values like:
"username": "admin",
"password": "supersecret123"If your target has a public GitHub organization use the org: filter.
org:example 'password':To save time use a custom GitHub dork with logical operators: AND, OR
"domain" AND ("api_key" OR "secret" OR "password" OR "access_token" OR "client_secret" OR "private_key" OR "AWS_SECRET_ACCESS_KEY" OR "DB_PASSWORD" OR "slack_token" OR "github_token" OR "BEGIN RSA PRIVATE KEY")During reconnaissance, filtering by path, language and file type helps narrow down valuable targets. Below are some common filters to use:
filename: Search by specific file names (e.g. filename:.env)
extension: Filter by file type (e.g. extension:json)
path: Search within specific directories (e.g. path:/config)
org: Limit results to an organization (e.g. org:my-company)
repo: Focus on a specific repository (e.g. repo:my-project)
filename:.env "DB_PASSWORD"extension:json "access_token"path:/config filename:database.phppath:/wp-config.phppath:/src/secretspath:/settingspath:/.sshpath:/.gitpath:**/.env
repo:vercel/next.js filename:config.jsFind files that contain both “password” and “domain” keywords anywhere within a specific language, such as .php, .jsp or .asp.
"domain" language:PHP passwordNote: Many of these credentials are committed by random developers. It's crucial to confirm if they belong to your target's assets before reporting.
Don't just search for “password.” Try variations like:
You can explore more powerful keyword combinations in my GitHub repository here:
coffinxp/payloads — github-dork.txtTo verify whether exposed API keys are working use the Keyhacks repository. It includes all commands and testing methods for over 50+ types of API keys.
streaak/keyhacksManual recon is great, but for mass scale use GitGraber tool.
python3 gitGraber.py -k wordlists/keywords.txt -q nasa.gov -spython3 gitGraber.py -k wordlists/keywords.txt -q "nasa.gov" -s
TruffleHog is another powerful tool for hunting secrets in code repositories. Here's how to use it:
trufflehog git file:///home/user/my-repotrufflehog git https://github.com/username/repo.gittrufflehog git https://github.com/trufflesecurity/test_keys --results=verified,unknowntrufflehog git https://github.com/trufflesecurity/test_keys --results=verified,unknown --json | jqtrufflehog github --repo=https://github.com/trufflesecurity/test_keys --issue-comments --pr-commentstrufflehog github --org=nasa --token=yourgithubtokentrufflehog github --repo=https://github.com/username/repo

These TruffleHog commands help detect exposed secrets (like API keys, credentials, tokens) in Git repositories. You can scan local repos, GitHub repositories or entire organizations. Additional flags allow filtering results, parsing JSON and scanning comments in issues and PRs for deeper coverage.
.git directories on public websites are another goldmine. Why? Because they store the entire source code history, including deleted but restorable files.
cat domains.txt | nuclei -t gitExposed.yaml
httpx-toolkit -l subs.txt -path /.git/ -mc 200cat domains.txt | httpx-toolkit -sc -server -cl -path "/.git/" -mc 200 -location -ms "Index of" -probecat domains.txt | grep "SUCCESS" | gf urls | httpx-toolkit -sc -server -cl -path "/.git/" -mc 200 -location -ms "Index of" -probe
Install the .git browser extension. It automatically alerts you if any site exposes its Git repository, helping you quickly spot misconfigurations and potential attack surfaces during recon.

Tip: Even if a site returns a 403 Forbidden for /.git/, don't give up — some Git files might still be accessible. Use tools like GitDumper to attempt extraction and reconstruction of the repository.
Once you've identified a valid .git/ folder using the methods above, it's time to dump the repository contents. Use tools like GitTools, git-dumper or git-extractor to recover exposed files and inspect the source code.
./gitdumper.sh https://domain.com/.git/ outputdirgit-dumper https://domain.com/.git/ outputdir
After dumping the .git folder the next step is to rebuild the full file structure. This helps uncover deleted files, sensitive data and historical changes that may still exist in the Git history.
cd output_dir
git status
git restore .
git checkout .You can also watch this video where I showed the complete practical of this method:
Watch Practical DemoGitHub recon and .git hunting — double trouble for insecure developers. With the right keywords, tools and validation strategies, you can uncover serious vulnerabilities often before anyone else leading to high-impact findings and well-paid bounties.