Bastard HTB
Last updated
Last updated
IP
Nmap
We can see the following ports are open on the machine
80:HTTP
135:RPC
49154:RPC
Let's navigate to port 80 and see what we can find
When we first land on the web server we are greeted with
Using wappalyzer we can see its using the following technologies
drupal 7
PHP
Windows system
Lets do some directory busting and see if we can find any hidden pages
Drupal 7.54
With this information we can use searchsploit and see if its vulnerable to any exploits
The section highlighted above is a great place to start, if we can get RCE on the target machine we can establish a reverse shell. Let's pull it down to our working directory.
When we bring any exploit down, checking the code is always important, we want to ensure we know what we are performing. When reviewing the code, we have noticed we have to make some slight changes.
We need to add the URL path of the target machine and the endpoint path, which we can do by navigating to the webpage and searching.
Once we have added the URL and endpoint path we use PHP to pass through system commands such as
which will run "whoami" within the target machine
First you may need to install php-curl which can be done by
Now that we have modified our script and installed php-curl let's run our exploit
Our exploit also generated two files "session.json" and "user.json" when searching through the files we find a Drupal 7 hash within the user.json file.
we could use Hashcat to crack it but this is a CTF and it was taking too long but here is the command to crack it
Let's navigate to "http://10.10.10.9/shell.php"
We have successfully passed the command "whoami" onto the target machine. Now that we know the exploit works we can start to work on establishing a reverse shell.
We need to make some minor modifications to our exploit script. Instead of
We want a way of passing commands through the URL browser bar.
now what is this PHP one-liner doing
'<?php': This indicates the start of a PHP code block
'system()': is a built-in PHP function used to execute shell commands. It takes a command as its argument and passes it through to the operating system's command-line interface. When the command is executed, any output is printed to the web page
'$REQUEST': is a superglobal array in PHP that combines the contents of $_GET, $_POST, and $_COOKIE. It holds data submitted via both GET and POST methods.
'["cmd"]': This is an array key accessed within the $_REQUEST
array. it means that the PHP code expects a parameter named "cmd" to be passed either via the URL(GET) or in the body of an HTTP POST request
Let's test our exploit
Navigating to the web page we can now pass commands through to the system
Awesome! Now let's prepare for a reverse shell
First, lets clone nc64.exe onto our system
cp nc64.exe into our working directory
Second, Let's start up a Python server to grab nc64.exe
Third, let's upload nc64.exe onto the target machine, well use curl to interact with our web shell
Fourth, lets set up a net cat listener
Fifth, Let's execute nc64 on our target machine
We now have a shell of the target system
First thing let's grab some system information and see if it is vulnerable to any exploits.
Now lets copy and paste this onto our local machine and run it through wes-ng, if you dont have wes-ng you can clone it from the following repo
Dont forget to update wes-ng in the directory you are working in
Now that we have systeminfo.txt (the system information from our target machine) we can run it through wes-ng which will see if it is vulnerable to any exploits.
We are given a long list of CVE's the target machine may be vulnerable to but one sticks out, MS10-059.
MS10-059 will allow us to establish another reverse shell with elevated privileges.
we can find MS10-059 in the following repo.
Let's set up a Python server and download the exploit, just for fun and practice let's use our web shell and curl to download the exploit onto the system.
Now that we have the MS10-059 on our target machine we can setup a netcat listener.
from our target machine let's run the exploit.
We now have a shell as nt authority\system on the target machine.
We find the which gives the accurate version of drupal