• We just launched and are currently in beta. Join us as we build and grow the community.

GitRoot: 1 Vulnhub Walkthrough

Creggd1

Content Velocity Specialist
C Rep
0
0
0
Rep
0
C Vouches
0
0
0
Vouches
0
Posts
73
Likes
23
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Today we are going to solve another boot2root challenge called “GitRoot: 1”. It’s available at Vulnhub for penetration testing. This lab is an intermediate level and is based on Git. The credit for making this lab goes to RecursiveNULL. Let’s get started and learn how to successfully break it down.

Level: Intermediate

Since these labs are available on the Vulnhub website. Let’s download the lab file from here.

Penetration Testing Methodology

Reconnaissance

  • Netdiscover
  • Nmap

Enumeration

  • Gobuster
  • GitTools

Exploiting

  • Bruteforce SSH with Hydra

Privilege Escalation

  • Linpeas
  • Abuse Git Hooks
  • Abuse SUDO

Capture the flag

Walkthrough

Reconnaissance

As always we identify the host’s IP with the “Netdiscover” tool:

1.png


So, let’s start by listing all the TCP ports with nmap.

Code:
nmap -A -p- 192.168.10.162

2.png


Enumeration

We access the website, it tells us that the site is hosted in the subdomain “wp.gitroot.vuln“.

3.png


We added the subdomain to our “/etc/hosts” file.

4.png


We access the address of the subdomain and see that WordPress is displayed.

5.png


After trying to break the WP without success, I try to list more subdomains with the option “vhost” of the Gobuster tool and the “big.txt” dictionary that comes with Kali by default.

6.png


We put this subdomain in our list of hosts

7.png


We access the new subdomain and find a code storage service, so it looks great.

8.png


We will use Gobuster again, this time to merge directories and files within this subdomain.

9.png


With GitDumper from the GitTools toolkit, we extract all the contents of “/.git/” into our Kali

Code:
./gitdumper.sh http://repo.gitroot.vuln/.git/ /root/GitRoot/git-tmp/

10.png


He’ll list an assortment of files, but we’ll keep this one:

11.png


We have two interesting files, well, actually we only have one, the “pablo_HELP.txt” file has been deleted, but we will rescue it!

Contents of the new file:

12.png


Now, we’ll recover all the files with the GitTools Kit Extractor tool (including “pablo_HELP“)

13.png


Contents of the “pablo_HELP” file

14.png


Nothing useful, we continue to check the .php files, we found some credentials in the file “set.php“.

15.png


Exploiting

We used the credentials in both WordPress and SSH, but without success. Although we already know the names of the users, we carried out a brute force attack on the SSH service with the “rockyou” dictionary.

16.png


With the credentials obtained, we access through SSH with the user “pablo” and read the flag of user.txt.

17.png


Privilege Escalation (user “beth”)

We keep listing the contents of “Pablo” folder, we find a folder called “public“, inside it, we have a message inviting us to check out a new git repository.

18.png


We run “linpeas.sh” and it lists a git repository from user “beth”, so it looks like we found the new repository.

19.png


We went into the heads directory of the git logs and found a large list, but if we sort them by size we’ll see that there’s one that’s larger than the rest.

20.png


We read the file and show the content of the “
add some stuff
” commit, we’ll get “Beth” password inside the script.

21.png


Privilege Escalation (user “jen”)

We authenticate ourselves as “beth” with the previously obtained password, read the content and see that we have a message from the user “jen“. In it, he asks us to leave a .zip in the folder he indicates, this user will be responsible for decompressing it.

22.png


Well, let’s surprise him with a .zip containing a reverse shell con la ayuda de “hooks” en git.

We will create a “post-commit” file and put a reverse shell with python. We will give you all the necessary permissions, we will compress it with 7zip and copy it to the path where “jen” indicated.

23.png


In our Kali, we will maintain a connection to netcat by listening on port 9999 while waiting for the script to run.

After having a shell with the user “jen“, we will read the file “.viminfo” and we will obtain his password.

24.png


Privilege Escalation (root)

With the user’s password “jen” in our possession, we run the command “sudo -l” and see that we have permissions to the “git” binary, of which there are several methods for escalating privileges over it, we’ll use the command
“$ sudo git -p help config
”.

25.png


At the bottom, it will allow us to execute commands, type “!/bin/sh“, get the root prompt and read the flag.

26.png


Author: David UtĂłn is Penetration Tester and security auditor for Web applications, perimeter networks, internal and industrial corporate infrastructures, and wireless networksContacted on LinkedIn.
 

442,401

317,942

317,951

Top