Date: 30/06/2022

Difficulty: Easy

CTF: https://app.hackthebox.com/machines/Forest


Enumeration

Let’s start testing the connection with the target machine by sending a ping:

Untitled

The ttl confirms that we are against a Windows Machine. Let’s move to the nmap scan to see if there are any TCP port open:

Untitled

There are many ports open! Let’s do a detailed scan to these ports:

Untitled
Untitled

Let’s start with the SMB (port 445). I’ll use crackmapexec to gather more info:

Untitled

Let’s see if we can see something inside the SMB without credentials:

Untitled

Not with smbmap, let’s try it with smbclient

Untitled

Ok, apparently we cannot access to the SMB… let’s try to find some usernames using kerbrute:

Untitled

We found some valid usernames!

Let’s create a list of valid users:

Untitled

Any of them would be AS-Rep Roastable?

Untitled

None of the discovered user has the UF_DONT_REQUIRE_PREAUTH set, so no AS-Rrep Roast available.

Maybe is not the best idea, but let’s try to obtain a password of a discovered user using Kerbrute:

#!/bin/bash 
File="validusers"
Lines=$(cat $File) 
for Line in $Lines do 
    /opt/kerbrute/kerbrute bruteuser --dc 10.10.10.161 -d htb.local -t 200 /usr/share/seclists/Passwords/xato-net-10-million-passwords-10000.txt $Line 
done

or do it with a one liner:

cat validusers | while read LINE; do /opt/kerbrute/kerbrute bruteuser --dc 10.10.10.161 -d htb.local -t 200 /usr/share/seclists/Passwords/xato-net-10-million-passwords-10000.txt $LINE; done

Untitled

But nah, no password has been discovered using this usernames and the password dictionary…

Let’s take a look to the ldap.

First of all, let’s see if it allows anonymous binds. To do so I can use ldapsearch tool:

ldapsearch -H ldap://10.10.10.161:389 -x -b "dc=htb,dc=local”

Untitled

The -x flag is used to specify anonymous authentication, while the -b flag denotes the base dn to start from. We were able to query the domain without credentials, which means null bind is enabled. Now we can use windapsearch to obtain more info from the domain:

/home/angellm/repos/windapsearch/windapsearch.py -d htb.local --dc-ip 10.10.10.161 -U

  • -U : Enumerate all users, i.e. objects with objectCategory set to user.
Untitled
Untitled

These users are the ones that we previously had… let’s try to obtain even more info using the flag --custom "objectClass=*" in order to obtain all the objects in the domain

Untitled
Untitled

The object svc-alfresco catches my attention. Let’s google it: Set up authentication and sync

Untitled

So… this account seems to not require Kerberos preauthentication so… maybe we can get a valid TGT form it via AS-REP Roast:

Untitled

Yeah, we got a NTLM hash of the user svc-alfresco. Let’s try to crack it using john:

Untitled

Yeah, we have a password. Let’s see if it is valid using crackmapexec:

Untitled

Yes, its a valid credential: svc-alfresco:s3rvice

As we have a valid credential and there is a winrm service active in the port 47001, maybe we can try to gain access to target machine using evilwinrm:

Untitled

Yeah, we obtained a PowerShell. Let’s look for the user flag:

Untitled

Nice.

Privilege Escalation

Now is time to escalate privileges. Let’s see which privileges this user has:

Untitled

And let’s see also the groups this account is in

Untitled
Untitled

I see nothing to use. But let’s use Bloodhound to see it more clearly:

Untitled

When imported into BloodHound it I searched SVC-ALFRESCO user and marked as OWNED.

Untitled

Double clicking on this user I see that it’s included in 9 groups:

Untitled

So, I click on the number 9 to display them:

Untitled

Mmmm… That group called ACCOUNT OPERATORS looks interesting. Apparently, members of this group are allowed create and modify users and add them to non-protected groups. So maybe we can use that.

Let’s go to the Analysis “Shortest Paths to High Value Targets”

Untitled

Is a little bit messy. One of the paths shows that the Exchange Windows Permissions group has WriteDacl privileges on the Domain. The WriteDACL privilege gives a user the ability to add ACLs to an object. This means that we can add a user to this group and give them DCSync privileges.

Untitled
Untitled
Untitled
Untitled
Untitled
Untitled

And now we can use secrets-dump to see the hashes!

Untitled

This is the hash of the administrator account: 32693b11e6aa90eb43d32c72a07ceea6

We can perform a pass the hash attack to log in as the administrator:

Untitled

Yeah, we are logged as Administrator. Now is time to search the root flag:

Untitled