> For the complete documentation index, see [llms.txt](https://angellm.gitbook.io/hacknotes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://angellm.gitbook.io/hacknotes/htb/2022/forest.md).

# Forest

**Date**: 30/06/2022

**Difficulty**: Easy

**CTF**: <https://app.hackthebox.com/machines/Forest>

***

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

<figure><img src="/files/KuYFcWC6HYcGx7ybaBH3" alt=""><figcaption></figcaption></figure>

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:

<figure><img src="/files/daWpZv1AF9LFgEPy4Qei" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/kg4B2F7ZQyiPYYBmu3A5" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/nETXFSgqTmrDxXwoqbpJ" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/ZRLr2nwcLbAUKYSNUT6S" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/gLAJmTQROpX7NTHmLWNx" alt=""><figcaption></figcaption></figure>

Not with smbmap, let’s try it with smbclient

<figure><img src="/files/OZCg6BSoktdAGVbxGVG0" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/RCBrIm5hMSl3SET6wXmI" alt=""><figcaption></figcaption></figure>

We found some valid usernames!

Let’s create a list of valid users:

<figure><img src="/files/w6j1xYLuBVjIgsA8I7t9" alt=""><figcaption></figcaption></figure>

Any of them would be AS-Rep Roastable?

<figure><img src="/files/b8hE53WCr9qgWDv0Dyg1" alt=""><figcaption></figcaption></figure>

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:

```bash
#!/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`

<figure><img src="/files/RnSCCUdHrglceZfxBJpn" alt=""><figcaption></figcaption></figure>

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”`

<figure><img src="/files/avmYw7BVwG87r1NbWm6y" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="/files/qpSIzxbtrp4nnWCW10Q1" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/uxladHYtRL97dQV7F7OM" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/ejYj2vgAJbxrZIHZBeG1" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/bg8XqzcZPWeCNh3EScp8" alt=""><figcaption></figcaption></figure>

The object `svc-alfresco` catches my attention. Let’s google it:

[Set up authentication and sync](https://docs.alfresco.com/content-services/7.0/admin/auth-sync/)

<figure><img src="/files/kDzE5ajHXV7QmL9Bp8Bj" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/q19XT8hySeJtJIy70wI0" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/rHT0nxLXhXqGczVwYB1F" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/yY7nu6yCI01EXWUXP4x4" alt=""><figcaption></figcaption></figure>

Yes, its a valid credential.

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`:

<figure><img src="/files/i5D2SIyv3DF61xyObP5t" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/SM83BXXrLIyK4Co6d9Zm" alt=""><figcaption></figcaption></figure>

Nice.

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

<figure><img src="/files/DNKcu8d1ZncQKtuwRpjA" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/sHMDcaIBmy0lqdt1A57J" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/UConn0ilyHktefQqtzJw" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/4LiSrP374X3hesVQJZ6j" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/WABOvBNWxTYvLWRjaUMT" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/WY8ewS57FgwmxLHEpP0n" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/WrB5ZzwWWF85fysZqgl5" alt=""><figcaption></figcaption></figure>

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”

<figure><img src="/files/Yf4vt9nQKEYmqAUAs72a" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="/files/Tk5YuPZvJujZjjeGhpY1" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/AHffA5swufuTOh5IMWqD" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6tMoumD553dlYU9IkK3g" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/rHOyWfDrlrY2DlZqDfEa" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/oP3dwIzYlwuhvcAdQAqI" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/qcQ9OzhqL0ZAcornWsOT" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/epqCTOIcQINFcqpN4Nek" alt=""><figcaption></figcaption></figure>

We got the hash of the administrator account.

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

<figure><img src="/files/Iritvc00gTuPGqcMFL7b" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/VCLiAzfcKlgFWgx6tCaN" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://angellm.gitbook.io/hacknotes/htb/2022/forest.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
