Bankrobber,a Windows box created by HackTheBox user Gioo and Cneeliz, was an overall Insane difficulty box. The initial foothold was about finding an XXS vector and use that to leak the admin cookie and use that to access the admin panel.There we find an SQLInjection using that we can grab the source code for an backdoorchecker.php also when we try to run that we see that it can only be ran from localhost. which means we will have to use that XXS and convert that to an CSRF attack and use that to get an RCE. And we have user. Privilege Escalation on this box was like port-forwarding a filtered port to local and using the application on nc, we write an script to brute-force the pin for the application. Doing a Command Injection on that we can get a shell as Administrator.
Enumeration
nmap scan
markdown
1 2 3 4 5 6 7 8 9 10 11 12 13
Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-10 13:15 EST Nmap scan report for 10.10.10.154 Host is up (0.15s latency). Not shown: 996 filtered ports PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.39 ((Win64) OpenSSL/1.1.1b PHP/7.3.4) 443/tcp open ssl/http Apache httpd 2.4.39 ((Win64) OpenSSL/1.1.1b PHP/7.3.4) 445/tcp open microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP) 3306/tcp open mysql MariaDB (unauthorized) Service Info: Host: BANKROBBER; OS: Windows; CPE: cpe:/o:microsoft:windows
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 41.69 seconds
Looking in SMB we see we don’t have Guest login so we cann’t get anything there.
So we focus on http
User
So lets try to just register and login as that user.
Login in we see
trying that we see that has to be approved by Admin so lets try XXS that and grab the admin cookie.
if($username == "admin" && $password == "Hopelessromantic"){ if(isset($_POST['cmd'])){ // FILTER ESCAPE CHARS foreach($badas$char){ if(strpos($_POST['cmd'],$char) !== false){ die("You're not allowed to do that."); } } // CHECK IF THE FIRST 2 CHARS ARE LS if(substr($_POST['cmd'], 0,strlen($good)) != $good){ die("It's only allowed to use the $good command"); }
if($_SERVER['REMOTE_ADDR'] == "::1"){ system($_POST['cmd']); } else{ echo"It's only allowed to access this function from localhost (::1).<br> This is due to the recent hack attempts on our server."; } } } else{ echo"You are not allowed to use this function!"; } ?>
Looking in that we see that $bad = array('$(','&');$( and & is blacklisted and request from $_SERVER['REMOTE_ADDR'] == "::1" are only allowed. So we can go back the the XSS and use that to create a CSRF using