How to find a specific file's code in a website with a broken git commit?

Viewed 98

For a challenge I found that I was able to download files off of /.git/ After using the tools from GitTools I soon realised that my goal was to get to read config.inc.php file. But the problem is, I got index.php extracted but not config.inc.php after extracting using GitTools. Am I missing something? Kindly please guide me in the right direction.

[EDIT: Turns out that I was stupid enough to not notice that config.inc.php was in the .gitignore file. From what I understand, I won't ever get config.inc.php but I am positive that I have some other progress I can work with.]

1 Answers

Going by the following answer you can find the blob that is linked (through a tree) to a specific filename (config.inc.php): Finding a file by its corresponding blob's hash in a git repository?

I created a repo with a file called config.inc.php (with garbage data) and pretended i only had the .git folder.

$ git rev-list --all | xargs -n1 -iX sh -c "git ls-tree -r X | grep config.inc.php"
100644 blob fa93ddba97a77274627f5a43fc2a9119ac6def66    config.inc.php

And to inspect the contents of that blob:

$ git cat-file -p fa93ddba97a77274627f5a43fc2a9119ac6def66
isidfisdifisdfisidf
Related