Tryhackme-RootME-ctf writeup

4 min readNov 16, 2023

First of all lets ping our machine ip to check if its alive

ping 10.10.61.192
Linux Terminal

lets scan for open ports using nmap

nmap 10.10.142.185 -T4
Linux Terminal

so the target machine is basically blocking out our requests giving the results to nmap that the host machine is down but it was alive when we pinged it so we can use the Pn flag to treat the target machine as alive and scan for open ports.

nmap -Pn 10.10.64.209 -T4
Linux Terminal

so we have 2 ports open at our target machine

lets check the port 80 in more detail

so this is the website being hosted at the http service port:

Linux Terminal

we have Apache 2.4.29 version running at our target machine lets visit the hosted site first

Linux Terminal

now lets use the gobuster tool to see if there are any hidden directories:

gobuster dir -u 10.10.246.140 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
Linux Terminal

now if you let the scan complete entirely , you will find another hidden directory other then the uploads , the panel directory lets visit that panel directory in our web browser

Linux Terminal

here we get the options to uploads file probably images , lets upload a image here and capture that request in our brup suite.

our image is uploaded

Linux Terminal

this is image upload request that we are going to send to our burp suite repeater and check if can send a payload instead of uploading a normal image

Burp Suite
Burp Suite

this is our request in repeater

Burp Suite

now since we know that we have our website running on a apache server and it usually uses a php backend we can try injecting a payload for a reverse php shell , you can get that script from the below link

https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php

replace the content of the file with script and change the port + ip address from the script

NOTE: give the ip that is assigned to you by the hack the box

Burp Suite

lets change the file extension as well

Burp Suite

we will use the php5 extension , but you might wanna try different php extension and see which one works for you

https://book.hacktricks.xyz/pentesting-web/file-upload

now lets send our request from burp suite

Burp Suite

our script is uploaded now lets start a listener first on the same port number as we specified in our reverseshell script then execute our payload on the server.

our listener is started

Burp Suite

lets go to the /uploads directory of the website to execute our reverse shell script

Browser

and here we go , we got the reverse shell

Linux Terminal

using this command we can search for the user.txt

find / -type f -name user.txt 2> /dev/null
Linux Terminal

seeing the content of the file

Linux Terminal
Linux Terminal
Linux Terminal

Congratulations !!! 🥂 the box is finished ✅

--

--

Syed Abeer Ahmed
Syed Abeer Ahmed

Written by Syed Abeer Ahmed

Cybersecurity | CS Tutor | Software Engineer | Flutter Dev

No responses yet