# Active

This is an easy Windows box which involved accessing an open SMB share, decrypting a Group Policy Preference password found on the share to obtain svc\_tgs user's password and then request a kerberos ticket on behalf of the Administrator and then crack it offline to obtain the administrator's password to authenticate to the machine as SYSTEM.

<div align="left"><figure><img src="/files/yH1Ex5TdHgmAyz59CLFu" alt=""><figcaption></figcaption></figure></div>

## <mark style="color:red;">Reconnaisance :</mark> &#x20;

### <mark style="color:blue;">nmap</mark>

As usual starting by scanning all the open ports and running services using nmap

<div align="left"><figure><img src="/files/daBstTfIGQnohEKdBTBO" alt=""><figcaption></figcaption></figure></div>

* **-sC**: run default nmap scripts

* **-O**: detect OS

* **-sV**: detect service version

* **-oA**: output all formats and store in file *initial*

* **Port 53:** running DNS 6.1.7601

* **Port 88:** running Kerberos

* **Ports 135, 593, 49152, 49153, 49154, 49155, 49157, 49158:** running msrpc

* **Ports 139 & 445:** running SMB

* **Port 389 & 3268:** running Active Directory LDAP

* **Port 464:** running kpasswd5. This port is used for changing/setting passwords against Active Directory

## <mark style="color:red;">Enumeration</mark>

### <mark style="color:blue;">Enumerating SMB Shares :</mark>&#x20;

Using the `SMBClient` utility to enumerate open shares in the machine:

<div align="left"><figure><img src="/files/Ie3faXIVLgvmu6eYiqIB" alt=""><figcaption></figcaption></figure></div>

The Replication share has READ ONLY permission on it. Let’s try to login anonymously to view the files of the Replication share.

<div align="left"><figure><img src="/files/1K5K2QyoThR5ohW8yWnM" alt=""><figcaption></figcaption></figure></div>

After looking through all the files on this share, I found a Groups.xml file which often contains Active Directory credentials in the following directory :&#x20;

```python
cd active.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\MACHINE\Preferences\Groups\
```

<div align="left"><figure><img src="/files/N6Y5vRV2sQlTU8eTj8B6" alt=""><figcaption></figcaption></figure></div>

this is the content of Groups.xml file which contains a cpassword for the user SVC\_TGS and it's encrypted

<div align="left"><figure><img src="/files/5Rtdhn03WkqF1bm25NFz" alt=""><figcaption></figcaption></figure></div>

## <mark style="color:red;">Gain an Initial Foothold</mark>

using `gpp-decrypt` tool which can be used to decrypt the cpassword attribute stored in the Group Policy Preferences XML file.

<div align="left"><figure><img src="/files/U2pfWWUXESBvylhqEYvi" alt=""><figcaption></figcaption></figure></div>

The domain account `SVC_TGS` has the password `GPPstillStandingStrong2k18`

accessing the USERS share using the username and password found using smbclient ($ADMIN share is not accessible using domain user account)

```python
smbclient //10.10.10.100/Users -U active.htb\\SVC_TGS%GPPstillStandingStrong2k18
```

<div align="left"><figure><img src="/files/vM2nxwh9sU6BgYVIDYHu" alt=""><figcaption></figcaption></figure></div>

get the flag in `/Users/SVG_TGS/Desktop/user.txt`

## <mark style="color:red;">Privilege Escalation</mark>

### <mark style="color:blue;">kerberoasting :</mark>&#x20;

Since we’re working with Active Directory and using Kerberos as an authentication protocol, let’s try a technique known as Kerberoasting. To understand how this attack works, you need to understand how the Kerberos authentication protocol works.

<div align="left"><figure><img src="/files/Uf8FujEIs62QrzPt8pCR" alt=""><figcaption></figcaption></figure></div>

If you compromise a user that has a valid kerberos ticket-granting ticket (TGT), then you can request one or more ticket-granting service (TGS) service tickets for any Service Principal Name (SPN) from a domain controller. An example SPN would be the Application Server shown in the above figure.

A portion of the TGS ticket is encrypted with the hash of the service account associated with the SPN. Therefore, you can run an offline brute force attack on the encrypted portion to reveal the service account password. Therefore, if you request an administrator account TGS ticket and the administrator is using a weak password, we’ll be able to crack it!

Kerberos authentication uses Service Principal Names (SPNs) to identify the account associated with a particular service instance

`Impacket’s GetUserSPNs` can be used to identify accounts that are configured with SPNs and is also able to request the TGS and extract the hash for offline cracking.

```python
impacket-GetUserSPNs -dc-ip 10.10.10.100 -request active.htb/SVC_TGS
```

<div align="left"><figure><img src="/files/EUU8L75r9H1q4H8fG7b0" alt=""><figcaption></figcaption></figure></div>

* **target:** domain/username:password
* **-dc-ip**: IP address of the domain controller
* **-request**: Requests TGS for users and outputs them in JtR/hashcat format

We were able to request a TGS from an Administrator SPN. If we can crack the TGS, we’ll be able to escalate privileges!

let's crack it using john the ripper

i copied the TGS to a file called hashes.kerberoast

```bash
john --format=krb5tgs --wordlist=/usr/share/wordlists/rockyou.txt hashes.kerberoast
```

<div align="left"><figure><img src="/files/kQoheO5Eowi3vLAQyLJg" alt=""><figcaption></figcaption></figure></div>

the password is `Ticketmaster1968`

To login as the administrator, we’ll use another Impacket script known as psexec since as administrator we have write permissions over the smb shares

<div align="left"><figure><img src="/files/393z8wP8vweeJWoZfmKn" alt=""><figcaption></figcaption></figure></div>

we can also use smbclient

<div align="left"><figure><img src="/files/VPrsClplal99oVSrgKA9" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="/files/vRS6y4tJmrtcUkKmSfNx" alt=""><figcaption></figcaption></figure></div>

hope you found this walkthrough easy to understand and follow

Greeting From [<mark style="color:red;">**Sayonara**</mark>](https://github.com/ismail-arame)


---

# 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://sayonara.gitbook.io/writeups/hackthebox/machines/active.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.
