Sitemap
System Weakness

System Weakness is a publication that specialises in publishing upcoming writers in cybersecurity and ethical hacking space. Our security experts write to make the cyber universe more secure, one vulnerability at a time.

TryHackMe | CTF | WebDevelopers

--

Can you root this Wordpress style machine? This CTF is all about hacking Wordpress. Developers watch out for this one!! TryHackMe has this amazing box at : https://tryhackme.com/room/webdeveloper. You can always LogIn on TryHackMe, go to rooms → webdeveloper.

1. Enumeration
Let’s find out the open ports on the machine. Port 22 and port 80 seem to be interesting ports. When I checked out the website on port 80, Wordpress website!!

Press enter or click to view image in full size

I tried to view page source to make sure if there was anything useful, but I didn't get anything. Next, let’s start crawling using the gobuster.

Press enter or click to view image in full size

Gobuster command needed some amendments, since the usual wordlist did not suffice my needs. I had to keep on changing the wordlists to make sure that I got some useful hints. I got the directory /ipdata which was insightful.
Additionally, later you will see why wp-content directory is also useful which I found after crawling through the wordlist common.txt

Press enter or click to view image in full size

2. Brute Forcing

In this directory, I found there was a tcp dump and I downloaded it. The dump was .cap file, wireshark here we go. Therefore, I saved the .cap file on my kali linux machine.

Press enter or click to view image in full size
Press enter or click to view image in full size

After saving the .cap file, I was wondering what could I possibly find on the tcp dump? Credentials isn't it?? Someone must have logged in into something. A post request, I decided to use the filter http.request.method == “POST”

Press enter or click to view image in full size

Look what I found, credentials… I got the username and password of the login account. Username: WebDeveloper, Password:Te5eQg%264sBS%21Yr%24%29wf%25%28DcAd

Press enter or click to view image in full size

I used the cyberchef to input the encoded password that I found from the .cap file. After URL Decoding, I found the login password.

Press enter or click to view image in full size

Let’s try to put the username and password to use. Woop Woop!! Wordpress hacker in the making.

Press enter or click to view image in full size

3. Reverse Shell

After viewing the dashboard, I decided to go to the appearance section.

Press enter or click to view image in full size

After heading to the appearance section, I went to the Editor section and decided to edit the themes. I would use this editing section for php reverse shell. You can find the reverse shell here: https://github.com/pentestmonkey/php-reverse-shell

Press enter or click to view image in full size
Press enter or click to view image in full size

You need to be able to check which theme is editable and edit that particular theme. For me, twentyfifteen theme worked well. Under that section, I used the archives.php to edit the theme with the php reverse shell. After editing, got the confirmation that the php file has been successfully updated.

Press enter or click to view image in full size

Make sure that the listner is on for port 4444, since php reverse shell says so, using net cat.
Reverse shell was found by <IP Address>/wp-content/themes/twentyfifteen/archive.php

Press enter or click to view image in full size

Never disappoint a blog reader😂. Reverse shell found!!

Press enter or click to view image in full size

4. Privilege Escalation

Get Kapish Kuchroo’s stories in your inbox

Join Medium for free to get updates from this writer.

Wordpress often has a configuration file, usually it is found under /var/www/html. Configuration file is needed because I don’t have the password for the www-data user. Since I don’t have the password for that user, I can’t do sudo-l and check the privilege escalation possibility.
I found the configuration file and read the contents of the file using the cat command. I found the username and password for the mysql database.

Press enter or click to view image in full size
Press enter or click to view image in full size

I almost forgot about the port 22 and started using the new found credentials by switching the user. I was able to switch the user but it wouldn’t yield results, I will elaborate why later.

Press enter or click to view image in full size
DO NOT SWITCH USER USING su <username> command

I realised that I should use the username and password for the ssh on port 22. I did that and logged in using using the credentials for webdeveloper.

Press enter or click to view image in full size

I could now see the possibility of the privilege escalation using the sudo-l command. I found that the command tcpdump can bee used by the user webdeveloper. How cool is that?

Press enter or click to view image in full size

I went to GTFO bins for the privilege escalation and I found an insightful information on how should I use the sudo permissions and escalate my privileges on the machine.

Press enter or click to view image in full size

Here’s why I suggested not to do su <username> <password > earlier. If I want to get a reverse shell with root access, I would have to stop the shell which was currently running using the PHP reverse shell script. In doing so I would not be able to get another shell since the netcat listener wouldn’t be
able to pawn the shell on the same port 4444.

Privilege Escalation:
I made a new binary file called .batch3 in the /tmp folder.

Press enter or click to view image in full size

I echoed the path where my reverse shell php is stored. It was stored on /var/www/html/wp-content/themes/twentyfifteen/archive.php. Remember this ?? Where we edited php reverse shell and used it to get a shell initially?

Press enter or click to view image in full size

I check the contents in the /tmp folder, make sure that I can run the binary using chmod 755 on .batch3

Press enter or click to view image in full size

That’s right so the binary file that I made just now has the path of the reverse shell and I will execute it and get a root shell using the information on GTFO bins.

Press enter or click to view image in full size

Using the information on GTFO bins , I executed the binary and changed the file name as required.

Press enter or click to view image in full size

Listener should be on before you run the command on port 4444.

Press enter or click to view image in full size

WHOAMI?? ROOT ROOT ROOT!! Flag Found!!

Press enter or click to view image in full size

--

--

Kapish Kuchroo
Kapish Kuchroo

Written by Kapish Kuchroo

Receiving and Perceiving misconfigurations in the computing systems

System Weakness
System Weakness

Published in System Weakness

System Weakness is a publication that specialises in publishing upcoming writers in cybersecurity and ethical hacking space. Our security experts write to make the cyber universe more secure, one vulnerability at a time.