Git-Happens

Target Details

IP Address: 10.10.49.172

Scan Services

  • Run nmap scan

$ nmap -sCV -Pn -oN nmap.txt [TARGET_IP]
$ cat nmap.txt
Nmap scan report for [TARGET_IP]
Host is up (0.40s latency).
Not shown: 999 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
80/tcp open  http    nginx 1.14.0 (Ubuntu)
|_http-title: Super Awesome Site!
|_http-server-header: nginx/1.14.0 (Ubuntu)
| http-git: 
|   [TARGET_IP]:80/.git/
|     Git repository found!
|_    Repository description: Unnamed repository; edit this file 'description' to name the...
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Fri Apr 14 22:04:47 2023 -- 1 IP address (1 host up) scanned in 118.95 seconds
  • Services

Service
PORT
Comments

HTTP

80

exposed .git directory with listing enabled

Exposed .git directory

Clone git directory to local machine

  • Install git-dumper python tool

  • Create directory for repo and change dir

  • Download git files

Looking Through commits

  • Check commit logs

  • Found commit hash when login page was created. commit hash: 395e087334d613d5e423cdf8f7be27196a360459

  • Change git HEAD to 395e087334d613d5e423cdf8f7be27196a360459 hash

  • List directory files

  • We might find hard coded passwords in html page.

  • We've found hard coded password in index.html page. Submit password as flag.

Real World Analogy

From one of the open source project. The developers mistakenly commited paid services code block on their community edition git repo. I was able to reverse engineer the code block and avail those premium services 😉 by making changes to the community edition codebase.

Conclusion

That was FUN!!

  • If you're gonna hard code credentials on client side, there is always someone who's gonna break the code.

  • .git directory shouldn't be accessible to anyone. A minor server misconfiguration will allow attacker to find attack vector and exploit your infra/apps.

Last updated

Was this helpful?