Attacking Kerberos
Kerberos
Kerberos is the default authentication service for Microsoft Windows domains. It is intended to be more "secure" than NTLM by using third party ticket authorization as well as stronger encryption. Even though NTLM has a lot more attack vectors to choose from, Kerberos still has a handful of underlying vulnerabilities just like NTLM that we can use to our advantage.
Kerbrute and Setup
Kerbrute is a popular enumeration tool used to brute-force and enumerate valid active-directory users by abusing the Kerberos pre-authentication.
For more information on enumeration using Kerbrute check out the Attacktive Directory room by Sq00ky - https://tryhackme.com/room/attacktivedirectory
You need to add the DNS domain name along with the machine IP to /etc/hosts inside of your attacker machine or these attacks will not work for you:
10.10.166.86 CONTROLLER.local
Rubeus
https://github.com/GhostPack/Rubeus
This command tells Rubeus to harvest for TGTs every 30 seconds.
Rubeus.exe harvest /interval:30
Brute-Forcing / Password-Spraying with Rubeus
Rubeus can both brute force passwords as well as password spray user accounts. When brute-forcing passwords you use a single user account and a wordlist of passwords to see which password works for that given user account. In password spraying, you give a single password such as Password1 and "spray" against all found user accounts in the domain to find which one may have that password.
This attack will take a given Kerberos-based password and spray it against all found users and give a .kirbi ticket. This ticket is a TGT that can be used in order to get service tickets from the KDC as well as to be used in attacks like the pass the ticket attack.
Before password spraying with Rubeus, you need to add the domain controller domain name to the windows host file. You can add the IP and domain name to the hosts file from the machine by using the echo command:
echo 10.10.241.48 CONTROLLER.local >> C:\Windows\System32\drivers\etc\hosts
Then spray the password. Rubeus.exe brute /password:Password1 /noticket will take a given password and "spray" it against all found users then give the .kirbi TGT for that user.
Kerberoasting with Rubeus
Rubeus.exe kerberoast will dump the Kerberos hash of any kerberoastable users.
Now crack that hash.
hashcat -m 13100 -a 0 hash.txt Pass.txt
Kerberoasting with Impacket
cd /usr/share/doc/python3-impacket/examples/ # navigate to where GetUserSPNs.py is located
sudo python3 GetUserSPNs.py controller.local/Machine1:Password1 -dc-ip 10.10.241.48 -request # this will dump the Kerberos hash for all kerberoastable accounts it can find on the target domain just like Rubeus does; however, this does not have to be on the targets machine and can be done remotely.
hashcat -m 13100 -a 0 hash.txt Pass.txt # now crack that hash
AS-REP Roasting with Rubeus
Very similar to Kerberoasting, AS-REP Roasting dumps the krbasrep5 hashes of user accounts that have Kerberos pre-authentication disabled. Unlike Kerberoasting these users do not have to be service accounts; the only requirement to be able to AS-REP roast a user is that the user must have pre-authentication disabled.
We'll continue using Rubeus same as we have with kerberoasting and harvesting, since Rubeus has a very simple and easy to understand command to AS-REP roast and attack users with Kerberos pre-authentication disabled. After dumping the hash from Rubeus we'll use hashcat in order to crack the krbasrep5 hash.
There are other tools out as well for AS-REP Roasting such as kekeo and Impacket's GetNPUsers.py. Rubeus is easier to use because it automatically finds AS-REP Roastable users whereas with GetNPUsers you have to enumerate the users beforehand and know which users may be AS-REP Roastable.
I have already compiled and put Rubeus on the machine.
AS-REP Roasting Overview
During pre-authentication, the users hash will be used to encrypt a timestamp that the domain controller will attempt to decrypt to validate that the right hash is being used and is not replaying a previous request. After validating the timestamp the KDC will then issue a TGT for the user. If pre-authentication is disabled you can request any authentication data for any user and the KDC will return an encrypted TGT that can be cracked offline because the KDC skips the step of validating that the user is really who they say that they are.
Dumping KRBASREP5 Hashes with Rubeus
cd Downloads- navigate to the directory Rubeus is inRubeus.exe asreproast- This will run the AS-REP roast command looking for vulnerable users and then dump found vulnerable user hashes.
Crack those Hashes with hashcat
- Transfer the hash from the target machine over to your attacker machine and put the hash into a txt file.
- Insert 23$ after $krb5asrep$ so that the first line will be $krb5asrep$23$User..... Use the same wordlist that you downloaded in task 4.
hashcat -m 18200 hash.txt Pass.txt- crack those hashes! Rubeus AS-REP Roasting uses hashcat mode 18200.
AS-REP Roasting Mitigations
- Have a strong password policy. With a strong password, the hashes will take longer to crack making this attack less effective.
- Don't turn off Kerberos Pre-Authentication unless it's necessary; there's almost no other way to completely mitigate this attack other than keeping Pre-Authentication on.