THM Write-Up

Room: Funpage

Introduction

Funpage is a short, easy CTF designed to practice very basic penetration-testing skills. Let’s start the machine.

How many ports are open?

First, we begin with reconnaissance. Let’s find out which services the target is running:

sudo nmap -sS $IP

The result:

Nmap output

From the scan, we see that two ports are open: SSH and HTTP.

What is the username?

Let’s explore the target. We saw that there is an HTTP server running on it, so let’s open http://$IP/:

Main page

Nothing obvious stands out. Maybe we should inspect the page’s source code:

Main page source

Interesting. There is a huge blob of a base64-encoded image. Let’s make a note of it: maybe we should check it later for hidden information.

But first, let’s do some site discovery:

gobuster -u http://$IP/ -w SecLists/Discovery/Web-Content/common.txt dir
Gobuster output

We can see that there is an additional directory on the server: /dev

It contains a list that does not seem useful to us. But let’s check the source code:

Subpage source

We see some base64-encoded text. Let’s decode it:

echo $TEXT | base64 --decode

The result does not look usable, but it does look familiar: like words in a different language, which is typical of a Caesar cipher. Let’s decode it: shifting the letters gives a readable result with two names in it. One of them must be the username. And indeed, one of them is!

What is the user flag?

How do we access the target machine? We saw earlier that an SSH service is also running. Let’s try to get in through that! We have a username, but what about the password? Earlier we read that the user doesn’t like complicated passwords, so we should give brute force a try.

hydra -l REDACTED -P ./SecLists/Passwords/Leaked-Databases/rockyou.txt $IP ssh

Indeed, we have a password:

Hydra output

Let’s access the machine:

ssh REDACTED@$IP

And we are in. We can find the user flag in the user’s home folder.

Note: it seems the user runs a restricted shell. We can fix that easily by running bash.

What is the root flag?

We should escalate the user’s privileges. It would be a good idea to run linPEAS, but first let’s check whether we have any sudo rights:

sudo -l

And we have:

sudo rights

The user can run nano as root. Let’s check how to exploit that on GTFOBins. Following the instructions there, we can get a root shell and read the root flag in the root directory.


SiGe