Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/documentation/modules/auxiliary/admin/kerberos/keytab.md
Views: 11788
Keytab
The modules/auxiliary/admin/kerberos/keytab
module provides utilities for interacting with MIT keytab files, which can store the hashed passwords of one or more principals.
Discovered keytab files can be used to generate Kerberos Ticket Granting Tickets, or bruteforced offline.
Keytab files can be also useful for decrypting Kerberos traffic using Wireshark dissectors, including the krbtgt encrypted blobs if the AES256 password hash is used - which is described in more detail below.
Actions
The following actions are supported:
LIST - List the entries in the keytab file [Default]
ADD - Add a new entry to the keytab file
EXPORT - Export known Kerberos encryption keys from the database
Scenarios
List
Add
Adding an entry using a known password hash/key which has been extracted from a Domain Controller - for instance by using the auxiliary/gather/windows_secrets_dump
module:
Adding entries using a specified password:
Export
Export Kerberos encryption keys stored in the Metasploit database to a keytab file. This functionality is useful in conjunction with secrets dump
Decrypting Kerberos traffic in wireshark
The Kerberos protocol makes use of encrypted values which will show as an opaque blob of hex characters in Wireshark. Configuring Wireshark with a Keytab file can decrypt these values automatically.
For instance in a TGS-REQ request within Wireshark, the cipher
below is encrypted using the user account's password and is not human readable:
The easiest way to decrypt these opaque blobs is to generate a Keytab file with Metasploit using the secretsdump scenario above or similar. After generating a keytab file in the Wireshark GUI go to Edit -> Preferences -> Protocols -> KRB5
and modify the following options:
Set
try to decrypt Kerberos blobs
to trueSet the
Kerebros keytab file
to the keytab file generated by your domain controller
After confirming the new settings - the previously encrypted which were signed with the user's password, and the decryptable session key should be viewable in Wireshark.
For example the previous TGS-REQ authenticator blob is now decrypted in the Wireshark UI. Wireshark on Linux may not show the decrypted packet information in the packet details pane, instead it appears as a separate tab in the packet bytes pane:
If you have exported the krbtgt
account to the keytab file - Wireshark will also decrypt the TGT ticket itself. If not - Wireshark will generate warnings about being unable to decrypt the TGT ticket which is signed using the krbtgt account.
Additional details: https://wiki.wireshark.org/Kerberos
If you are on a Windows domain controller it is possible to use the ktpass
program to generate keytab files:
It is easier to use the Metasploit module, but if you do use ktpass - be aware of the following issues:
If the password contains
$
it is easier to run thektpass
command incmd
rather thanpowershell
to avoid unexpected variable substitutionIf there is a
Missing keytype 18
warning foretype: eTYPE-AES256-CTS-HMAC-SHA1-96 (18)
in Wireshark - verify that the principal name is correct within the ktpass generation commandThis should match the initial AS-REQ KRB ERROR salt, found in
krb-error
->edata
->ETYPE-INFO2-ENTRY
->salt
Common Mistakes
Invalid REALM/PRINCIPAL/SALT
When generating a keytab with a password, a salt is generated by default from the principal and realm unless one is explicitly provided. For Windows Active Directory environments, these values are case-sensitive. The realm should be upper case, and the principal is case-sensitive.
When the SALT is not explicitly provided a salt will be generated that follows the Windows naming convention, for instance: