Chill Hack
Task 1 Investigate!
User Flag
Let's run a simple
nmapscan against the target machine.
There are three open ports:
21
ftp
22
ssh
80
http
We can connect anonymously through FTP.
There is a
note.txtfile that we can download on our machine using thegetcommand.
Let's
catout thenote.txtfile.
So there is some page where we can input commands which are then filtered.
Let's try to find out the page where this is happening using
gobuster.
The
/secretpage looks interesting, let's visit it through our browser.

As we can see this is the page where we can input commands.
Let's pass the following command:

Looks like it worked.
Let's list out the content of the directory:

Ah so our command probably matched some black-list string and was filtered.
We can try to bypass the filter using single quotes:

There is an
index.phpfile. If we can manage to read it, we might be able to see how the black-list is implemented.Let's
catit out.

We can do the same bypass as before with single quotes:

The layout looks different. That is because the
ìndex.phpfile was read and executed.We can now check the source code using
CTRL+U.

Now we know what pattern are being filterd.
Let's set up a
nclistener.
Now we have to provide a PHP reverse shell:

Let's check back on our listener.
We can get a stable shell using the following command:
Let's chat files the
www-datauser can run usingsudo.
Let's take a better look at what the
.helpline.shfile does.
So it uses the
/bin/bashinterpreter for all of the user input. Which means we we should be able to get a shell.
Let's get the flag from
/user.txt.
Answer
Root Flag
Let's list out the contents of the directory.
We can see that there is a JPG image.
Let's set up a Python3 server so that we can get this file from our attacker machine.
On our attacker machine we have to use
wgetto download the JPG file.
Using
steghidewe can check if there is any embedded file or message and extract it.
Let's
unzipthe ZIP file.
In order to unzip it we need a password.
We can use
zip2johnto convert the ZIP file into a hash.
Now, using
johnwe can crack the hash.
Let's unzip the file using the
pass1wordpassword.
In the
source_code.phpfile we can see a message for a userAnurodhand a Base64 encoded password.Let's decode the password using
base64.
We can now login through SSH as the user
anurodhusing the!d0ntKn0wmYp@ssw0rdpassword.
Using the
idcommand we can check the groups that theanurodhuser is part of.
So the
anurodhuser is part of thedockergroup.We can find an exploit for Docker on GTFOBins.

Let's use the exploit without the
sudo.
We are now the
rootuser and can read the root flag.
Answer
Last updated
Was this helpful?