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

Hack the Box Challenge Kotarak Walkthrough

PickleRick

Cyber Risk Analyst
P Rep
0
0
0
Rep
0
P Vouches
0
0
0
Vouches
0
Posts
180
Likes
82
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Hello friends!! Today we are going to solve another CTF challenge “Kotarak” which is available online for those who want to increase their skill in penetration testing and black box testing. Kotarak is retired vulnerable lab presented by Hack the Box for making online penetration practices according to your experience level; they have the collection of vulnerable labs as challenges from beginners to Expert level.

Level: Hard

Task: find user.txt and root.txt file on victim’s machine.

Since these labs are online available therefore they have static IP and IP of sense is 10.10.10.55 so let’s begin with nmap port enumeration.

Code:
nmap -p- -A 10.10.10.55 --open

From given below image, you can observe we found port 22, 8009, 8080, 60000 are open in victim’s network.

1.png


As port 8080 and 60000 are running HTTP, we open the IP in our browser and access the page through port 8080. As soon as we open the ip in our browser we get a tomcat authentication prompt asking for username and password.

2.png


When we access the target machine through port 60000, we find a page that is hosted on the machine can be used to access the internet.

4.png


Now we need to use the dirb tool to enumerate the directories of the target machine.

Code:
dirb http://10.10.10.55:60000/

From given below image you can observe the highlighted directory that is put up by dirb in its output result.

5.png


We now try to check if the page is vulnerable to SSRF or not by trying to access a forbidden page on the target machine.

6.png


when we open server-status through the vulnerable page, we are able to access the forbidden content. We then find that port 888 is listening locally on the target machine.

7.png


Then we opened http://localhost:888 through URL and it contains a few links to different files.

8.png


We open backup and find that it was empty.

9.png


To gain further information we used curl to access the page and find that it is an XML file that contains a username and password.

Code:
curl http://10.10.10.55:60000/url.php?path=localhost:888/?doc=backup

10.png


We use the above credentials to login into tomcat manager application that is hosted on port 8080.

11.png


As we were able the right credentials for tomcat server, we found that it was vulnerable to this exploit here. We used metasploit to exploit this vulnerability.

Code:
msf > use exploit/multi/http/tomcat_mgr_upload
msf exploit(multi/http/tomcat_mgr_upload) > set rhost 10.10.10.55
msf exploit(multi/http/tomcat_mgr_upload) > set rport 8080
msf exploit(multi/http/tomcat_mgr_upload) > set httpusername admin
msf exploit(multi/http/tomcat_mgr_upload) > set httppassword 3@g01PdhB!
msf exploit(multi/http/tomcat_mgr_upload) > exploit

Finally, we got the meterpreter session as shown in the below image

12.png


After gaining the reverse shell we start enumerating the target system. In /home/tomcat/to_archive/pentest_data we find a few interesting files.

13.png


In /home/tomcat/to_archive/Pentest_data we find a directory information tree file and binary file.

We download both the files into our system

14.png


We used impacket-secretsdump to dump hashes inside the files.

15.1.png


We were able to crack one of the hashes and find it to be f16tomcat!

15.2.png


We use this to login as atanas, we then move into /root/ folder and find a file called flag.txt. When we open it we find that it was a dummy flag file.

15.png


In the root directory, we also find a log file when we take a look at the content of the file we find that it contains log that we were created using wget. We also find that the wget version used is 1.16

16.png


Searching on the Exploit-DB site we find that this version of wget was vulnerable to remote code execution.

17.png


We follow the instructions given on exploit-db.com about how to exploit this vulnerability.

18.png


Then we had opened the wgetrc file through vim for changing the path of Post_file from /etc/shadow into /root/root.txt

19.png


We download the code of this exploit from exploit-db.com and upload it to the target machine through meterpreter.

20.png


We then give read, write and execute permission to the file.

21.png


We then use authbind to run the file, as authbind allows a program to that would normally require super user privileges to access privileged network services to run as a non-privileged user. As soon as we run the exploit we get the root flag.

25.png


Author: Sayantan Bera is a technical writer at hacking articles and cyber security enthusiast. Contact Here
 

433,979

313,163

313,172

Top