Accessing Attacktive Directory THM Write-up
Installing Impacket:
Whether you're on the Kali 2019.3 or Kali 2021.1, Impacket can be a pain to install correctly. Here's some instructions that may help you install it correctly!
First, you will need to clone the Impacket Github repo onto your box. The following command will clone Impacket into /opt/impacket:
git clone https://github.com/SecureAuthCorp/impacket.git /opt/impacket
After the repo is cloned, you will notice several install related files, requirements.txt, and setup.py. A commonly skipped file during the installation is setup.py, this actually installs Impacket onto your system so you can use it and not have to worry about any dependencies.
To install the Python requirements for Impacket:
pip3 install -r /opt/impacket/requirements.txt
Once the requirements have finished installing, we can then run the python setup install script:
cd /opt/impacket/ && python3 ./setup.py install
After that, Impacket should be correctly installed now and it should be ready to use!
If you are still having issues, you can try the following script and see if this works:
sudo git clone https://github.com/SecureAuthCorp/impacket.git /opt/impacket sudo pip3 install -r /opt/impacket/requirements.txt cd /opt/impacket/ sudo pip3 install . sudo python3 setup.py install |
Credit for proper Impacket install instructions goes to Dragonar#0923 in the THM Discord <3
Installing Bloodhound and Neo4j
Bloodhound is another tool that we'll be utilizing while attacking Attacktive Directory. We'll cover specifcs of the tool later, but for now, we need to install two packages with Apt, those being bloodhound and neo4j. You can install it with the following command:
apt install bloodhound neo4j
Now that it's done, you're ready to go!
Troubleshooting
If you are having issues installing Bloodhound and Neo4j, try issuing the following command:
apt update && apt upgrade
Enumeration with nmap and Enum4linux :
Enumeration with nmap and Enum4linux :
After the nmap scan, we see that the port 139 and 445 are open, so we can use "enum4linux" to see what domains are available.
"enum4linux -a" option does all the common options.
nmap scan result
Enumerating with Kerberos
Enumerating with Kerberos
A whole host of other services are running, including Kerberos. Kerberos is a key authentication service within Active Directory. With this port open, we can use a tool called Kerbrute (by Ronnie Flathers @ropnop) to brute force discovery of users, passwords and even password spray!
Download the older version (1.0.2) as the userenum option is available and 1.0 was not stable.
For this box, a modified User List and Password List will be used to cut down on time of enumeration of users and password hash cracking. It is NOT recommended to brute force credentials due to account lockout policies that we cannot enumerate on the domain controller.
Updated the etc/hosts with the domain name (spookysec.local)
I've specified the domain controller as it was giving me an error without it.
./kerbrute userenum -d spookysec.local --dc spookysec.local kerberoesuser.txt
Introduction
After the enumeration of user accounts is finished, we can attempt to abuse a feature within Kerberos with an attack method called ASREPRoasting. ASReproasting occurs when a user account has the privilege "Does not require Pre-Authentication" set. This means that the account does not need to provide valid identification before requesting a Kerberos Ticket on the specified user account.
Retrieving Kerberos Tickets
Impacket has a tool called "GetNPUsers.py" (located in impacket/examples/GetNPUsers.py) that will allow us to query ASReproastable accounts from the Key Distribution Center. The only thing that's necessary to query accounts is a valid set of usernames which we enumerated previously via Kerbrute.
Let's determine the hash type by visiting the hashcat wiki page.
After entering the first part of the hash, I was able to see that it's "Kerberos 5, etype 23, AS-REP" and has the 18200 hash-mode.
Create a hash file and a password list file to crack it
Cracked it!
Discovering File-shares with smbclient
Enumeration:
With a user's account credentials we now have significantly more access within the domain. We can now attempt to enumerate any shares that the domain controller may be giving out.
smbclient -L \10.10.162.190\ -U svc-admin
this will list the file shares within.
Enumerate the resulted shared folders
smbclient \\10.10.162.190\backup\ -U svc-admin
Juicy file found!
use the smb command "get" to download it to the attacker's machine.
YmFja3VwQHNwb29reXNlYy5sb2NhbDpiYWNrdXAyNTE3ODYw~zsh
This looks like base64
Decode this by typing
base64 -d backup_credentials.txt
Domain Privilege Escalation Elevating Privileges within the Domain
Now that we have new user account credentials, we may have more privileges on the system than before. The username of the account "backup" gets us thinking. What is this the backup account to?
Well, it is the backup account for the Domain Controller. This account has a unique permission that allows all Active Directory changes to be synced with this user account. This includes password hashes
Knowing this, we can use another tool within Impacket called "secretsdump.py". This will allow us to retrieve all of the password hashes that this user account (that is synced with the domain controller) has to offer. Exploiting this, we will effectively have full control over the AD Domain.
impacket-secretsdump backup@spookysec.local:backup2517860
I couldn't get this to work for a min since I was adding "%" at the end which wasn't the part of the password :(
Try the Hash the pass method to elevate the privilege!
Use a tool Evil-WinRM
This room was so much fun!!
Last updated