THM Room CC: Pentesting
Here I solve the last part of CC: Pentesting Room from TryHackMe. All the previous part are well educated with step by step guide so I didn't add that here but the final task is an exam.
Last updated
Here I solve the last part of CC: Pentesting Room from TryHackMe. All the previous part are well educated with step by step guide so I didn't add that here but the final task is an exam.
Last updated
First export the Machine IP to a shell variable like the following so we don't need to remember it.
Nmap Scan
Now we do a Nmap scan to know which services are running to the system using the following command.
After the scan, we got the following result.
Total Open Ports
From the result, we came to know there are 2 services running on the target. ssh
and http
both are very useful. The http
service is open which means the target is hosting a website and ssh
is open it means we can remotely login into the system if we know valid credentials.
We don't have valid credentials yet so we focus on http
service first. Browse the site and there we didn't find any interesting results so we can start directory fuzzing to get any hidden directory.
Directory Scan on web server Result
We can use ffuf
tool to fuzz for the hidden directories using the following command.
-w
is used to specify a wordlist
-u
is used to specify the target site URL
-e
is used to specify the file extension to search
Using the above command we found the following Interesting Hidden Directories and file.
Hidden Directory
We also found the server has the following file extensions in use.
Common extension found
You can also use gobuster to find hidden directories using the following command
dir
is used to specify we are doing directory fuzzing
-x
is used to specify file extensions to look at
-u
is used to specify the target URL
-w
is used to specify a wordlist
so we found the secret.txt
file by gobustor
directory scan with extensions html
, php
, txt
etc we can browse to the secret.txt
file using the URL.
The secret.txt
file has the following content.
This looks like a username and password hash that we can use to connect with ssh if we crack it. we crack the hash from the crackstaion
website or we can do this with john
or hashcat
So after cracking we found that the hash is nyan
so now we have a username and password
so we ssh to the target with
So now have initial access to the target machine, we can read the user.txt
the file that is our first flag.
Now we have initial access the next step is to do privilege escalation, and it's time to do privilege escalation. when we use the following command to check if the current user has any sudo
permission.
They show we can use the su
command without a password, the su
the command is used to switch to another user. So by knowing this we can now get the root
user without any problem just by using the following command
we change our current user to root
so after becoming a root
user we can now see the content of the root.txt
file from this path /root/root.txt
.
We got both flags user.txt
and root.txt
and submit them and finish the room.