Certified HTB Walkthrough

Nov 6, 2024    #box   #htb   #medium   #windows   #ldap   #active-directory   #shadow-credentials   #kerberos   #ca   #whisker   #msds-keycredentiallink   #certificate   #dacls   #acl   #download-cradle   #esc9  

Certified Hack The Box Walkthrough/Writeup:

How I use variables & Wordlists:

1. Enumeration:

Assumed Breach Box:

NMAP:

Basic Scans:

Comprehensive Scans:

LDAP 389:

Using LDAP anonymous bind to enumerate further:

serverName:
    CN=DC01,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=certified,DC=htb

Updating ETC/HOSTS & Variables:

Syncing Clocks for Kerberos Exploitation:

DNS 53:

Kerberos 88:

Using Kerbrute to bruteforce Usernames:

Using netexec for ASReproasting:

Kerberoasting to retrieve the management_svc hash:

Trying to crack management_svc hash:

2. Foothold:

Enumerating as Judith:

Connecting as Judith to SMB:

Using smbclient:

Attempting to connect via evil-winrm:

Enumerating Users with Impacket-lookupsid:

Bloodhound collection:

Attempted Bloodhound collection using netexec:
Bloodhound collection via bloodhound-python:

Running certipy-ad to enumerate vulnerable certificates:

Discovering our user has GenericWrite privs over MANAGEMENT_SVC:

Planning our attack path:

  1. First we will make ourselves owner of the group “Management”:
    • As we have WriteOwner privileges over the group “Management” we can make ourselves the owner of the group:
  2. Second we will modify the rights to allow ourselves to add user
    • Once we are owner we will then need to modify our rights to be able to add users to the group.
  3. Third we will add ourselves to the group “Management”:
  4. Fourth we will perform shadow credentials attack on “MANAGEMENT_SVC”:
    • We can then perform a shadow credentials attack to add certificate based credentials to the user “MANAGEMENT_SVC” and then authenticate as them and request a kerberos ticket which we can then pass to be used as authentication. We can do this as we will now be part of the “Management” group and in turn have GenericWrite over the “MANAGEMENT_SVC” object.
    • +Deep Dive+: I have a deep dive on shadow credentials available here if you want to the how behind this attack vector:

Making Judith owner of the Management group & then adding her as a user:

+Note+: For some reason impacket is displaying lots of errors but we can ignore them as it’s still completing the tasks. I’ve included them here in-case you also get them.

  1. Make judith the new owner of management:

    • impacket-owneredit -action write -new-owner $user -target-sid 'S-1-5-21-729746778-2675978091-3820388244-1104' $domain/$user:$pass
  2. Grant Judith the ability to add users to the group by modifying the DACL’s:

    • impacket-dacledit -action 'write' -rights 'WriteMembers' -principal $user -target-sid 'S-1-5-21-729746778-2675978091-3820388244-1104' $domain/$user:$pass
  3. Add judith to the group:

    • net rpc group addmem "Management" $user -U $domain/$user%$pass -S $box
    • +Note+: There will be no output from this command, we need to instead verify it worked in the next command.
  4. Verify Judith is now part of the group:

    • net rpc group members "Management" -U $domain/$user%$pass -S $box

Performing the shadow credentials attack against “MANAGEMENT_SVC”:

Setting up pywhisker:

Finding a previous pywhisker commit prior to breaking changes and using that:

Using pywhisker to perform our shadow credentials attack:

Installing PKINIT:

Requesting a TGT for MANAGEMENT_SVC with PKINITtools getgtgkinit:

Requesting the MANAGEMENT_SVC user hash with PKINITtools getnthash:

Logging in as MANAGEMENT_SVC:

3. Lateral Movement:

Discovering that MANAGEMENT_SVC has GenericAll over CA_OPERATOR:

Performing the shadow credentials attack against “CA_OPERATOR”

Requesting a TGT for CA_OPERATOR with PKINITtools getgtgkinit:

Requesting the CA_OPERATOR user hash with PKINITtools getnthash:

4. Privilege Escalation:

Discovering that we can perform the ESC9 exploit chain CA vulnerability as CA_OPERATOR:

ESC9 Privilege Escalation:

Changing the UPN of the ca_operator to be administrator:

Requesting our vulnerable cert using as the ca_operator:

Reverting the ca_operator’s UPN:

Authenticating with the certificate to retrieve the NT hash of the administrator:

5. Persistence:

Dumping NTDS.dit/DC-SYNC attack:

Creating a Kerberos Golden Ticket:

Using a base64 encoded PowerShell reverse shell and download cradle to connect back to our attack host every 1 minute:

Scheduled Task Backdoor Utilizing Download Cradle Command Breakdown:

Lessons Learned:

What did I learn?

  1. I learned alot more about shadow-credential attacks and CA attacks.

  2. I really enjoyed the process of how layered and different the attack chain was for this compared to other boxes I have done.

What silly mistakes did I make?

  1. Not so many, getting better….I hope

Sign off:

Remember, folks as always: with great power comes great pwnage. Use this knowledge wisely, and always stay on the right side of the law!

Until next time, hack the planet!

– Bloodstiller

– Get in touch bloodstiller at proton dot me



Next: Aero HTB Walkthrough