Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subject in generated certificate of shadow credentials #248

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

martanne
Copy link

I had a recent engagement where shadow credentials were registered with a command like:

$ certipy shadow add -dc-ip 10.5.10.11 -scheme ldaps -u [email protected] -p password -account domainuser

However, authentication attempts over PKINIT would fail with (this is not the case in the Ludus environment):

[-] Name mismatch between certificate and user 'domainuser'

While investigating the generated certificate, it was noticed that the Subject contained a double CN=CN=.
This is due to the fact that the underlying pydsinternals library, internally assigns the CN property (not the whole subject).

$ openssl x509 -in domainuser.pfx -text | grep CN=CN=
        Issuer: CN=CN=domainuser
        Subject: CN=CN=domainuser

After applying the proposed changes, the certificate looks like this:

$ openssl x509 -in domainuser.pfx -text | grep CN=
        Issuer: CN=domainuser
        Subject: CN=domainuser

This matches the behavior of e.g. pywhisker (and impacket's ldap-shell, ntlmrelayx, ...):

$ pywhisker --dc-ip 10.5.10.11 -d ludus.domain -u domainadmin -p password --target domainuser --action add --filename pywhisker -P ''

Whose generated certificate looks like this:

$ openssl x509 -in pywhisker.pfx -text | grep CN=
        Issuer: CN=domainuser
        Subject: CN=domainuser

Authentication using PKINIT was tested and worked as expected with a command like:

$ certipy auth -dc-ip 10.5.10.11 -pfx domainuser.pfx -username domainuser -domain ludus.domain -no-hash

Previously the generated certificate contained CN=CN= in the subject.
@zimedev
Copy link

zimedev commented Jan 27, 2025

thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants