.git directory at a repo’s root, and that directory frequently ends up exposed on a live web server, deployed alongside the application instead of excluded from it. Anyone who can reach .git over HTTP can rebuild the full source tree offline, including anything ever committed and later “removed,” config files, old credentials, commented-out debug endpoints, all of it.
Dumping
Rebuilding a usable working copy of the repo from just the exposed
.git directory, no web shell or further access needed.Credential & Secret Hunting
Once dumped (or once you already have filesystem access to a repo during post-exploitation), mining its full history for anything a developer ever committed and later thought was gone.
Detecting an Exposed .git Directory
Dumping the Repository
- GitTools (gitdumper.sh)
- git-dumper.py
- wget mirror (directory listing enabled)
GitTools is purpose-built for exactly this,
gitdumper.sh pulls down every object it can reach without needing directory listing enabled.Reconstructing & Reviewing
GitTools’ dumper leaves raw objects behind, not a checked-out working copy,extractor.sh (also part of GitTools) rebuilds every commit it can find into browsable snapshots:
git-dumper was used instead, the dump is already a usable .git directory, standard git commands work directly against it:
Credential & Secret Extraction
Stored Remote Credentials
Searching the Full History
A secret removed in a later commit is not gone, it’s still sitting in an earlier one, searching the entire history (not just the current files) is the whole point of doing this rather than just browsing the live site.Automated Secret Scanning
Manualgrep-ing the log works but misses encoded/high-entropy secrets that don’t match an obvious keyword. These tools scan the full commit history for anything that looks like a credential, regardless of what it’s named.
Truffelhog
Malicious Git Hooks (Write Access)
.git/hooks/ scripts (post-commit, pre-push, etc.) are never transmitted by clone, pull, or push, they’re purely local. If write access to a shared repo’s working directory is already in hand (a writable deployment path, a CI checkout, an NFS-mounted repo), planting a hook there executes code the next time anyone on that same checkout commits, pushes, or merges, a quiet, easy-to-overlook persistence mechanism.
Searching Public Repos (grep.app)
grep.app regex searches the full text of every public repo on GitHub at once, useful for finding a target’s secrets leaked in someone else’s repo (a contractor’s fork, a personal dotfiles repo, e.g) that enumeration would never surface directly.Quick Reference Tools
GitTools
Dump + extract an exposed
.git directory into browsable commits.git-dumper
Single-script alternative, dumps straight into a usable
.git directory.TruffleHog
Automated secret scanning across full commit history, not just current files.
Gitleaks
Similar automated secret scanner, worth running alongside TruffleHog, each catches patterns the other misses.
HackTricks: Git
Additional tools (Git-Money, DVCS-Pillage, gitrob) and GitHub-wide secret hunting.

