Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions dploot/triage/certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
PublicFormat,
load_der_private_key,
)

from pyasn1.codec.der import decoder
from pyasn1.type.char import UTF8String

Expand Down Expand Up @@ -51,10 +52,15 @@ def dump(self) -> None:
print("Valid Date (UTC):\t%s" % self.cert.not_valid_before_utc)
print("Expiry Date (UTC):\t%s" % self.cert.not_valid_after_utc)
print("Extended Key Usage:")
for i in self.cert.extensions.get_extension_for_oid(
oid=ExtensionOID.EXTENDED_KEY_USAGE
).value:
print(f"\t{i._name} ({i.dotted_string})")
try:
for i in self.cert.extensions.get_extension_for_oid(
oid=ExtensionOID.EXTENDED_KEY_USAGE
).value:
print(f"\t{i._name} ({i.dotted_string})")
except x509.ExtensionNotFound:
pass
except (x509.DuplicateExtension, x509.UnsupportedGeneralNameType) as e:
logging.debug(e)

if self.clientauth:
print("\t[!] Certificate is used for client auth!")
Expand Down Expand Up @@ -368,17 +374,23 @@ def correlate_certificates_and_privatekeys(
"@", "_"
)
clientauth = False
for i in cert.extensions.get_extension_for_oid(
oid=ExtensionOID.EXTENDED_KEY_USAGE
).value:
if i.dotted_string in [
"1.3.6.1.5.5.7.3.2", # Client Authentication
"1.3.6.1.5.2.3.4", # PKINIT Client Authentication
"1.3.6.1.4.1.311.20.2.2", # Smart Card Logon
"2.5.29.37.0", # Any Purpose
]:
clientauth = True
break
try:
ext=cert.extensions.get_extension_for_oid(oid=ExtensionOID.EXTENDED_KEY_USAGE)
for i in ext.value:
if i.dotted_string in [
"1.3.6.1.5.5.7.3.2", # Client Authentication
"1.3.6.1.5.2.3.4", # PKINIT Client Authentication
"1.3.6.1.4.1.311.20.2.2", # Smart Card Logon
"2.5.29.37.0", # Any Purpose
]:
clientauth = True
break
except x509.ExtensionNotFound:
logging.debug('no extended key usage in certificate')
except (x509.DuplicateExtension, x509.UnsupportedGeneralNameType) as e:
logging.debug(e)


cert_object = Certificate(
winuser=winuser,
cert=cert,
Expand Down