Git
Git Information Leak
If the web server leaks the .git
directory, we can download this directory recursively:
Show changes between commits, commit and working tree, etc:
With modern URL mapping (i.e. not relying on the filesystem), it's less and less common to see these types of issues, but it's always important to be on the lookout for them.
Bypass Restrictions
If directory listing is disabled, we should examine the following two files first:
.git/config
.git/HEAD
Access https://www.example.com/.git/config
:
Access https://www.example.com/.git/HEAD
:
Access https://www.example.com/.git/refs/heads/master
:
Here 53
is a directory name and 46cb2290d9918bfaad7318ebcb2498fe5ebe18
is a hash. This hash represents a commit and it can found at .git/objects/53/
. Download this commit:
The file was compressed with zlib, but there isn't a built-in tool for zlib decompression. We can decompress it with Ruby:
From there, we get a new commit that we can download, and from there, check the content by deflating it and running strings -a
on the result:
We want the hash for each file. Create our own git repo:
Copy files to it:
Retrieve hashes:
Just to save time, assume that we know the key is inside header.php
. Create a directory and download this file:
Examine source code:
GitHacker
GitHacker is a multiple threads tool to detect whether a site has the .git
folder leakage vulnerability. It is able to download the target .git
folder almost completely. This tool also works when the DirectoryListings
feature is disabled.
Installation: pip3 install GitHacker
Usage: githacker --url http://127.0.0.1/.git/ --folder result
Last updated