Optimum
Reconnaissance:
WAPP http://10.10.10.8/
Security: Basic
CDN: Google Hosted Libraries
JavaScript libraries: jQuery 1.4.4
Retire.js
jquery 1.4.4
All 1000 scanned ports on 10.10.10.8 are in ignored states.
Our initial recon shows that our only point of entry is through exploiting the HTTP File Server.
Enumeration:
Browse to the HTTP File server. It seems to be a server that allows you to remotely access your files over the network. There’s a login page that might be using default credentials. This could potentially allow us to gain an initial foothold. Let’s google the server name and version to learn more about it.
The first two google entries are publicly disclosed exploits that would give us remote code execution on the box! Click on the first entry and view the compile instructions.
To compile the exploit, we need to perform a few tasks:
Host a web server on our attack machine (kali) on port 80 in a directory that has the netcat executable file.
Start a netcat listener on the attack machine.
Download the exploit and change the ip_addr & local_port variables in the script to match the ip address of the attack machine and the port that netcat is listening on.
Run the script using python as stated in the Usage comment.
Before we do that, let’s try and understand what the script is doing.
Everything in yellow (in double quotes) is URL encoded. Let’s decode it using an
Three functions are being called:
script_create(): creates a script (script.vbs) that when run downloads the nc.exe from our attack machine and saves it to the C:\Users\Public\ location on the target machine.
execute_script(): uses the csscript.exe (command-line version of the Windows Script Host that provides command-line options for setting script properties) to run script.vbs.
nc_run(): runs the the netcat executable and sends a reverse shell back to our attack machine.
Now that we understand what the script is doing, what remains to be answered is why was remote code execution allowed. Further googling tells us
The findMacroMarker function in parserLib.pas in Rejetto HTTP File Server (aks HFS or HttpFileServer) 2.3x before 2.3c allows remote attackers to execute arbitrary programs via a %00 sequence in a search action. This makes sense. In the exploit, every time a search is done to run arbitrary code, the %00 sequence is used.
Foothold:
Now that we understand the exploit, let’s run it. In the instructions, the first step is to host a web server on our attack machine (kali) on port 80 in a directory that has the netcat executable file. Locate the Windows netcat executable file in the kali vm.
Start the HTTP server.
The second step is to start a netcat listener on the attack machine.
The third step is to download the exploit and change the ip_addr & local_port variables in the script to match the ip address of the attack machine and the port that netcat is listening on.
The fourth step is to run the exploit.
We get a non-privileged shell back!
Grab the user flag.
We don’t have system privileges, so we’ll need to find a way to escalate privileges.
Privilege Escalation:
WinPEAS I started with WinPEAS to look for escalation paths. I cloned a copy of the repo to my host, started an SMB server in the path with the Windows exe with sudo smbserver.py share . -smb2support, and copied it to Optimum:
Now I’ll run it with .\winPEAS.exe. Scanning through the output, there were a few interesting things. The box is Windows Server 2012 R2, and 64-bit:
A bunch of services were called out as potentially interesting, but nothing in there really panned out.
Watson/Sherlock One thing I noticed was not in the winPEAS output was Watson results. Watson is a quick checker for CVEs this Windows host might be vulnerable to, and in the original HTB days, that was a common escalation technique (in fact, it is the intended path on this host). My best guess as to why it didn’t run is the .NET version required by Watson in winPEAS is 4.5, and this host only has up to 4.0:
If I want to run Watson, I think I could get it to work by downloading it and compiling it to match one of the .NET versions on the box, but I wasn’t able to get it working quickly. Instead, because this box is so old, I went to Watson’s predecessor, Sherlock.
Sherlock is a PowerShell script. I’ll download a copy, and see that it defines a bunch of functions, but doesn’t call any. I’ll add a line at the end to call Find-AllVulns. Then I’ll use a Python HTTP server to host a copy, and execute it the same way I got a shell:
There are three that show “Appears Vulnerable”, MS16-032, MS16-034, and MS16-135.
MS16-098:
Lets see the system information by running:
Okay now we know the OS and the version, After using this information and perform a deep google search i found an exploit called MS16–098, All we need to do is download the exe file and upload it to the target machine, first download the exe file:
Put it on you desktop, we already have a python server running there on port 80, all we need now is uploading bfill.exe to the target machine, make sure you use Downloads directory:
now lets navigate to our downloads directory:
We will find our bfill.exe file there, all we need is to execute it
That's it, we are system! grab you flags here:
Last updated