code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def __init__(
self,
target: "Target",
template: str = "",
write_configuration: Optional[str] = None,
write_default_configuration: bool = False,
save_configuration: Optional[str] = None,
no_save: bool = False,
force: bool = False,
connection: Option... |
Initialize a Template object for certificate template operations.
Args:
target: Target domain information
template: Name of the certificate template to operate on
write_configuration: Path to configuration file to apply
write_default_configuration: Wheth... | __init__ | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def connection(self) -> LDAPConnection:
"""
Lazily establish and return an LDAP connection.
Returns:
An active LDAP connection to the target domain
"""
if self._connection is not None:
return self._connection
self._connection = LDAPConnection(sel... |
Lazily establish and return an LDAP connection.
Returns:
An active LDAP connection to the target domain
| connection | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def configuration_to_json(self, configuration: Dict[str, Any]) -> str:
"""
Convert a template configuration to a JSON string.
Converts binary attribute values to their hexadecimal representation
for storage in JSON format.
Args:
configuration: Template configuration... |
Convert a template configuration to a JSON string.
Converts binary attribute values to their hexadecimal representation
for storage in JSON format.
Args:
configuration: Template configuration dictionary
Returns:
JSON string representation of the config... | configuration_to_json | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def get_configuration(self, template_name: str) -> Optional[LDAPEntry]:
"""
Retrieve the configuration for a certificate template from AD.
Searches for the template by CN or displayName and returns its configuration.
Args:
template_name: Name of the certificate template to ... |
Retrieve the configuration for a certificate template from AD.
Searches for the template by CN or displayName and returns its configuration.
Args:
template_name: Name of the certificate template to find
Returns:
LDAPEntry containing the template configuration ... | get_configuration | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def json_to_configuration(
self, configuration_json: Dict[str, Any]
) -> Dict[str, Any]:
"""
Convert a JSON configuration back to a usable LDAP configuration.
Converts hexadecimal strings back to binary data for LDAP operations.
Args:
configuration_json: Diction... |
Convert a JSON configuration back to a usable LDAP configuration.
Converts hexadecimal strings back to binary data for LDAP operations.
Args:
configuration_json: Dictionary loaded from JSON
Returns:
Configuration dictionary with binary values ready for LDAP
... | json_to_configuration | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def load_configuration(self, configuration_path: str) -> Dict[str, Any]:
"""
Load a template configuration from a JSON file.
Args:
configuration_path: Path to the configuration JSON file
Returns:
Configuration dictionary with binary values
Raises:
... |
Load a template configuration from a JSON file.
Args:
configuration_path: Path to the configuration JSON file
Returns:
Configuration dictionary with binary values
Raises:
ValueError: If the JSON file doesn't contain a dictionary
FileNot... | load_configuration | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def save_configuration(self, configuration: Optional[LDAPEntry] = None) -> None:
"""
Save the current configuration to a JSON file.
"""
# Get the current configuration
current_configuration = configuration
if current_configuration is None:
current_configuratio... |
Save the current configuration to a JSON file.
| save_configuration | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def write_configuration(self) -> bool:
"""
Apply a new configuration to a certificate template.
If no configuration file is provided, applies the default vulnerable
configuration. If save_old is True, saves the current configuration
before applying changes.
Returns:
... |
Apply a new configuration to a certificate template.
If no configuration file is provided, applies the default vulnerable
configuration. If save_old is True, saves the current configuration
before applying changes.
Returns:
True if the template was successfully upd... | write_configuration | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def _compute_changes(
self, old_configuration: LDAPEntry, new_configuration: Dict[str, Any]
) -> Dict[str, Any]:
"""
Compute the changes needed to update a template configuration.
Args:
old_configuration: Current template configuration
new_configuration: New ... |
Compute the changes needed to update a template configuration.
Args:
old_configuration: Current template configuration
new_configuration: New template configuration to apply
Returns:
Dictionary of changes to apply using LDAP modify operation
| _compute_changes | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def _apply_changes(
self, old_configuration: LDAPEntry, changes: Dict[str, Any]
) -> bool:
"""
Apply computed changes to a template configuration.
Args:
old_configuration: Current template configuration
changes: Dictionary of changes to apply
Returns... |
Apply computed changes to a template configuration.
Args:
old_configuration: Current template configuration
changes: Dictionary of changes to apply
Returns:
True if changes were applied successfully, False otherwise
| _apply_changes | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def _log_changes(self, changes: Dict[str, Any]) -> None:
"""
Log the changes to be applied, grouped by operation type.
Args:
changes: Dictionary of changes to apply
"""
# Group changes by operation (MODIFY_DELETE, MODIFY_REPLACE, MODIFY_ADD)
by_op = lambda it... |
Log the changes to be applied, grouped by operation type.
Args:
changes: Dictionary of changes to apply
| _log_changes | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def entry(options: argparse.Namespace) -> None:
"""
Entry point for the template command.
Args:
options: Command-line arguments
"""
target = Target.from_options(options, dc_as_target=True)
# Remove target from options to avoid duplicate argument
options.__delattr__("target")
t... |
Entry point for the template command.
Args:
options: Command-line arguments
| entry | python | ly4k/Certipy | certipy/commands/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the account management command subparser to the main parser.
This function creates and configures a subparser for managing Active Directory
accounts, including options for creating, reading, updat... |
Add the account management command subparser to the main parser.
This function creates and configures a subparser for managing Active Directory
accounts, including options for creating, reading, updating, and deleting
user and computer accounts.
Args:
subparsers: Parent parser to attach t... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/account.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/account.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the certificate authentication command subparser to the main parser.
This function creates and configures a subparser for authenticating with
certificates to Active Directory services, including o... |
Add the certificate authentication command subparser to the main parser.
This function creates and configures a subparser for authenticating with
certificates to Active Directory services, including options for retrieving
Kerberos tickets and establishing LDAP connections.
Args:
subparser... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/auth.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/auth.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the Certificate Authority management command subparser to the main parser.
This function creates and configures a subparser for managing Certificate
Authorities in Active Directory, including temp... |
Add the Certificate Authority management command subparser to the main parser.
This function creates and configures a subparser for managing Certificate
Authorities in Active Directory, including template management, request
processing, permission assignments, and CA backup operations.
Args:
... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/ca.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/ca.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the certificate management command subparser to the main parser.
This function creates and configures a subparser for managing certificates
and private keys, including options for importing from v... |
Add the certificate management command subparser to the main parser.
This function creates and configures a subparser for managing certificates
and private keys, including options for importing from various formats,
exporting to PFX, and manipulating certificate components.
Args:
subparse... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/cert.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/cert.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the AD CS enumeration command subparser to the main parser.
This function creates and configures a subparser for finding and analyzing
Active Directory Certificate Services components, including c... |
Add the AD CS enumeration command subparser to the main parser.
This function creates and configures a subparser for finding and analyzing
Active Directory Certificate Services components, including certificate
templates, enrollment services, and CA configurations.
Args:
subparsers: Paren... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/find.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/find.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the certificate forging command subparser to the main parser.
This function creates and configures a subparser for forging certificates
with a compromised CA certificate, allowing creation of Gold... |
Add the certificate forging command subparser to the main parser.
This function creates and configures a subparser for forging certificates
with a compromised CA certificate, allowing creation of Golden Certificates
that can be used for authentication and privilege escalation.
Args:
subpa... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/forge.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/forge.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the parse command subparser to the main parser.
This function creates and configures a subparser for analyzing AD CS certificate
templates from registry data, allowing offline enumeration of poten... |
Add the parse command subparser to the main parser.
This function creates and configures a subparser for analyzing AD CS certificate
templates from registry data, allowing offline enumeration of potentially
vulnerable templates.
Args:
subparsers: Parent parser to attach the subparser to
... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/parse.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/parse.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the NTLM relay command subparser to the main parser.
This function creates and configures a subparser for relaying NTLM authentication
to AD CS HTTP endpoints, enabling certificate theft and accou... |
Add the NTLM relay command subparser to the main parser.
This function creates and configures a subparser for relaying NTLM authentication
to AD CS HTTP endpoints, enabling certificate theft and account takeover via
certificate-based authentication.
Args:
subparsers: Parent parser to atta... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/relay.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/relay.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the certificate request command subparser to the main parser.
This function creates and configures a subparser for requesting certificates
from AD CS, including options for certificate templates, ... |
Add the certificate request command subparser to the main parser.
This function creates and configures a subparser for requesting certificates
from AD CS, including options for certificate templates, subject alternative names,
and various enrollment methods.
Args:
subparsers: Parent parse... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/req.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/req.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the shadow credentials command subparser to the main parser.
This function creates and configures a subparser for managing Shadow Credentials
(Key Credential Links) in Active Directory, including ... |
Add the shadow credentials command subparser to the main parser.
This function creates and configures a subparser for managing Shadow Credentials
(Key Credential Links) in Active Directory, including options for listing, adding,
and removing credential links for account takeover.
Args:
su... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/shadow.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/shadow.py | MIT |
def add_argument_group(
parser: argparse.ArgumentParser,
connection_options: Optional[argparse._ArgumentGroup] = None,
) -> None:
"""
Add common target, connection, and authentication arguments to a parser.
This function adds standard options for connecting to Active Directory targets,
includin... |
Add common target, connection, and authentication arguments to a parser.
This function adds standard options for connecting to Active Directory targets,
including domain controllers, authentication methods, and network settings.
Args:
parser: The parser to add argument groups to
conne... | add_argument_group | python | ly4k/Certipy | certipy/commands/parsers/target.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/target.py | MIT |
def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable]: # type: ignore
"""
Add the certificate template command subparser to the main parser.
This function creates and configures a subparser for managing certificate templates
in Active Directory, including options for viewin... |
Add the certificate template command subparser to the main parser.
This function creates and configures a subparser for managing certificate templates
in Active Directory, including options for viewing, modifying, and saving
template configurations.
Args:
subparsers: Parent parser to atta... | add_subparser | python | ly4k/Certipy | certipy/commands/parsers/template.py | https://github.com/ly4k/Certipy/blob/master/certipy/commands/parsers/template.py | MIT |
def cert_id_to_parts(
identities: List[Tuple[Optional[str], Optional[str]]],
) -> Tuple[Optional[str], Optional[str]]:
"""
Extract username and domain from certificate identities.
Args:
identities: List of (id_type, id_value) tuples from certificate
Returns:
Tuple of (username, dom... |
Extract username and domain from certificate identities.
Args:
identities: List of (id_type, id_value) tuples from certificate
Returns:
Tuple of (username, domain)
| cert_id_to_parts | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def print_certificate_authentication_information(
certificate: x509.Certificate,
) -> None:
"""
Display all authentication-related information found in a certificate.
This function extracts and prints various identity methods used in a
certificate, including Subject Alternative Names (SAN), Securit... |
Display all authentication-related information found in a certificate.
This function extracts and prints various identity methods used in a
certificate, including Subject Alternative Names (SAN), Security Identifiers (SID),
and other Microsoft-specific extensions that can be used for authentication.
... | print_certificate_authentication_information | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def print_certificate_identities(
identities: List[Tuple[str, str]],
) -> None:
"""
Print certificate identity information with appropriate formatting.
Args:
identities: List of tuples containing (identity_type, identity_value)
"""
if len(identities) > 1:
logging.info("Got certi... |
Print certificate identity information with appropriate formatting.
Args:
identities: List of tuples containing (identity_type, identity_value)
| print_certificate_identities | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def get_identities_from_certificate(
certificate: x509.Certificate,
) -> List[Tuple[str, str]]:
"""
Extract identity information from a certificate.
Args:
certificate: X.509 certificate to analyze
Returns:
List of tuples with (id_type, id_value)
"""
identities = []
try... |
Extract identity information from a certificate.
Args:
certificate: X.509 certificate to analyze
Returns:
List of tuples with (id_type, id_value)
| get_identities_from_certificate | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def get_object_sid_from_certificate_san_url(
certificate: x509.Certificate,
) -> Optional[str]:
"""
Extract a Security Identifier (SID) from a certificate's Subject Alternative Name (SAN)
URL field.
Microsoft AD CS can include SIDs in certificates as URLs with a specific format:
tag:microsoft.c... |
Extract a Security Identifier (SID) from a certificate's Subject Alternative Name (SAN)
URL field.
Microsoft AD CS can include SIDs in certificates as URLs with a specific format:
tag:microsoft.com,2022-09-14:sid:{SID}
Args:
certificate: X.509 certificate to analyze
Returns:
... | get_object_sid_from_certificate_san_url | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def get_object_sid_from_certificate_sid_extension(
certificate: x509.Certificate,
) -> Optional[str]:
"""
Extract a Security Identifier (SID) from a certificate's Microsoft-specific
NTDS_CA_SECURITY_EXT extension.
This extension is commonly used in Microsoft AD CS environments to associate
cert... |
Extract a Security Identifier (SID) from a certificate's Microsoft-specific
NTDS_CA_SECURITY_EXT extension.
This extension is commonly used in Microsoft AD CS environments to associate
certificates with specific Active Directory objects.
Args:
certificate: X.509 certificate to analyze
... | get_object_sid_from_certificate_sid_extension | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def get_object_sid_from_certificate(
certificate: x509.Certificate,
) -> Optional[str]:
"""
Extract a Security Identifier (SID) from a certificate using multiple methods.
This function attempts to find SIDs in both the Subject Alternative Name URL field
and the Microsoft-specific security extension... |
Extract a Security Identifier (SID) from a certificate using multiple methods.
This function attempts to find SIDs in both the Subject Alternative Name URL field
and the Microsoft-specific security extension. Different certificate templates may
use different approaches for storing SIDs, so both method... | get_object_sid_from_certificate | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def key_to_pem(key: PrivateKeyTypes) -> bytes:
"""
Convert private key to PEM format (PKCS#8).
Args:
key: Private key object
Returns:
PEM-encoded key as bytes
"""
return key.private_bytes(
Encoding.PEM, PrivateFormat.PKCS8, encryption_algorithm=NoEncryption()
) |
Convert private key to PEM format (PKCS#8).
Args:
key: Private key object
Returns:
PEM-encoded key as bytes
| key_to_pem | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def key_to_der(key: PrivateKeyTypes) -> bytes:
"""
Convert private key to DER format (PKCS#8).
Args:
key: Private key object
Returns:
DER-encoded key as bytes
"""
return key.private_bytes(
Encoding.DER, PrivateFormat.PKCS8, encryption_algorithm=NoEncryption()
) |
Convert private key to DER format (PKCS#8).
Args:
key: Private key object
Returns:
DER-encoded key as bytes
| key_to_der | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def der_to_pem(der: bytes, pem_type: str) -> str:
"""
Convert DER-encoded data to PEM format.
Args:
der: DER-encoded binary data
pem_type: PEM header/footer type (e.g., "CERTIFICATE")
Returns:
PEM-encoded data as string
"""
pem_type = pem_type.upper()
b64_data = bas... |
Convert DER-encoded data to PEM format.
Args:
der: DER-encoded binary data
pem_type: PEM header/footer type (e.g., "CERTIFICATE")
Returns:
PEM-encoded data as string
| der_to_pem | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def private_key_to_ms_blob(private_key: rsa.RSAPrivateKey) -> bytes:
"""
Convert RSA private key to Microsoft BLOB format.
Args:
private_key: RSA private key
Returns:
Microsoft BLOB format key data
"""
# Get key size
bitlen = private_key.key_size
private_numbers = priva... |
Convert RSA private key to Microsoft BLOB format.
Args:
private_key: RSA private key
Returns:
Microsoft BLOB format key data
| private_key_to_ms_blob | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def create_pfx(
key: PrivateKeyTypes, cert: x509.Certificate, password: Optional[str] = None
) -> bytes:
"""
Create a PKCS#12/PFX container with certificate and private key.
Args:
key: Private key object
cert: Certificate object
password: Optional encryption password
Return... |
Create a PKCS#12/PFX container with certificate and private key.
Args:
key: Private key object
cert: Certificate object
password: Optional encryption password
Returns:
PKCS#12 data as bytes
Raises:
TypeError: If key type is not supported
| create_pfx | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def load_pfx(
pfx: bytes, password: Optional[bytes] = None
) -> Tuple[Optional[PrivateKeyTypes], Optional[x509.Certificate]]:
"""
Load key and certificate from PKCS#12/PFX data.
Args:
pfx: PKCS#12 data
password: Optional decryption password
Returns:
Tuple of (private_key, c... |
Load key and certificate from PKCS#12/PFX data.
Args:
pfx: PKCS#12 data
password: Optional decryption password
Returns:
Tuple of (private_key, certificate)
| load_pfx | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def rsa_pkcs1v15_sign(
data: bytes,
key: PrivateKeyTypes,
hash_algorithm: type[hashes.HashAlgorithm] = hashes.SHA256,
) -> bytes:
"""
Sign data using RSA PKCS#1 v1.5 padding.
Args:
data: Data to sign
key: Private key for signing
hash_algorithm: Hash algorithm to use
... |
Sign data using RSA PKCS#1 v1.5 padding.
Args:
data: Data to sign
key: Private key for signing
hash_algorithm: Hash algorithm to use
Returns:
Signature bytes
Raises:
TypeError: If key is not an RSA private key
| rsa_pkcs1v15_sign | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def hash_digest(data: bytes, hash_algorithm: type[hashes.HashAlgorithm]) -> bytes:
"""
Compute hash digest of data.
Args:
data: Data to hash
hash_algorithm: Hash algorithm to use
Returns:
Hash digest as bytes
"""
digest = hashes.Hash(hash_algorithm())
digest.update(... |
Compute hash digest of data.
Args:
data: Data to hash
hash_algorithm: Hash algorithm to use
Returns:
Hash digest as bytes
| hash_digest | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def dn_to_components(dn: str) -> List[Tuple[str, str]]:
"""
Parse a Distinguished Name string into components.
Args:
dn: DN string (e.g., "CN=username,DC=domain,DC=local")
Returns:
List of (attribute_name, value) tuples
"""
components = []
component = ""
escape_sequence... |
Parse a Distinguished Name string into components.
Args:
dn: DN string (e.g., "CN=username,DC=domain,DC=local")
Returns:
List of (attribute_name, value) tuples
| dn_to_components | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def create_csr(
username: str,
alt_dns: Optional[Union[bytes, str]],
alt_upn: Optional[Union[bytes, str]],
alt_sid: Optional[Union[bytes, str]],
subject: Optional[str],
key_size: int,
application_policies: Optional[List[str]],
smime: Optional[str],
key: Optional[rsa.RSAPrivateKey] = ... |
Create a certificate signing request (CSR) with optional extensions.
Args:
username: Username for the subject
alt_dns: Alternative DNS name
alt_upn: Alternative UPN (User Principal Name)
alt_sid: Alternative SID (Security Identifier)
key: RSA private key (generated if N... | create_csr | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def create_csr_attributes(
template: str,
alt_dns: Optional[Union[bytes, str]] = None,
alt_upn: Optional[Union[bytes, str]] = None,
alt_sid: Optional[Union[bytes, str]] = None,
application_policies: Optional[List[str]] = None,
) -> List[str]:
"""
Create a list of CSR attributes based on the ... |
Create a list of CSR attributes based on the provided template and Subject Alternative Name options.
This function generates the attributes needed when requesting a certificate through Microsoft's
certificate enrollment web services. It formats the template name and any requested SAN entries
according... | create_csr_attributes | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def create_renewal(
request: bytes,
cert: x509.Certificate,
key: rsa.RSAPrivateKey,
) -> bytes:
"""
Create a certificate renewal request.
Args:
request: Original request data
cert: Certificate being renewed
key: Private key for signing
Returns:
CMC renewal r... |
Create a certificate renewal request.
Args:
request: Original request data
cert: Certificate being renewed
key: Private key for signing
Returns:
CMC renewal request as bytes
Raises:
ValueError: If signature algorithm is not set
| create_renewal | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def create_on_behalf_of(
request: bytes,
on_behalf_of: str,
cert: x509.Certificate,
key: rsa.RSAPrivateKey,
) -> bytes:
"""
Create a certificate request on behalf of another user.
Args:
request: Original request data
on_behalf_of: Username to request on behalf of
cer... |
Create a certificate request on behalf of another user.
Args:
request: Original request data
on_behalf_of: Username to request on behalf of
cert: Certificate for signing
key: Private key for signing
Returns:
CMC on-behalf-of request as bytes
Raises:
Va... | create_on_behalf_of | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def create_key_archival(
csr: x509.CertificateSigningRequest,
private_key: rsa.RSAPrivateKey,
cax_cert: x509.Certificate,
) -> bytes:
"""
Create a key archival request.
Args:
csr: Certificate signing request
private_key: Private key to be archived
cax_cert: Key archival ... |
Create a key archival request.
Args:
csr: Certificate signing request
private_key: Private key to be archived
cax_cert: Key archival agent certificate
Returns:
CMC key archival request as bytes
Raises:
ValueError: If signature algorithm is not set
Type... | create_key_archival | python | ly4k/Certipy | certipy/lib/certificate.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/certificate.py | MIT |
def get_channel_binding_data(server_cert: bytes) -> bytes:
"""
Generate channel binding token (CBT) from a server certificate.
This implements the tls-server-end-point channel binding type as described
in RFC 5929 section 4. The binding token is created by:
1. Hashing the server certificate with SH... |
Generate channel binding token (CBT) from a server certificate.
This implements the tls-server-end-point channel binding type as described
in RFC 5929 section 4. The binding token is created by:
1. Hashing the server certificate with SHA-256
2. Creating a channel binding structure with the hash
... | get_channel_binding_data | python | ly4k/Certipy | certipy/lib/channel_binding.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/channel_binding.py | MIT |
def get_channel_binding_data_from_response(response: httpx.Response) -> bytes:
"""
Extract channel binding data from an HTTPX response.
This function extracts the server certificate from an HTTPX response
and generates the channel binding token used for authentication.
Args:
response: The ... |
Extract channel binding data from an HTTPX response.
This function extracts the server certificate from an HTTPX response
and generates the channel binding token used for authentication.
Args:
response: The HTTPX response object containing TLS connection information
Returns:
The ... | get_channel_binding_data_from_response | python | ly4k/Certipy | certipy/lib/channel_binding.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/channel_binding.py | MIT |
def get_channel_binding_data_from_ssl_socket(ssl_socket: ssl.SSLSocket) -> bytes:
"""
Extract channel binding data from an SSL socket.
This function extracts the server certificate from an SSL socket
and generates the channel binding token used for authentication.
Args:
ssl_socket: The SSL... |
Extract channel binding data from an SSL socket.
This function extracts the server certificate from an SSL socket
and generates the channel binding token used for authentication.
Args:
ssl_socket: The SSL socket object containing TLS connection information
Returns:
The channel bi... | get_channel_binding_data_from_ssl_socket | python | ly4k/Certipy | certipy/lib/channel_binding.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/channel_binding.py | MIT |
def translate_error_code(error_code: int) -> str:
"""
Translate a Windows API error code to a human-readable string.
Args:
error_code: Windows API error code (HRESULT)
Returns:
Formatted error message with code, short description, and detailed explanation
Example:
>>> tran... |
Translate a Windows API error code to a human-readable string.
Args:
error_code: Windows API error code (HRESULT)
Returns:
Formatted error message with code, short description, and detailed explanation
Example:
>>> translate_error_code(0x80090311)
'code: 0x80090311 - ... | translate_error_code | python | ly4k/Certipy | certipy/lib/errors.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/errors.py | MIT |
def handle_error(is_warning: bool = False) -> None:
"""
Handle errors by printing the error message and exiting the program.
This function is a placeholder for error handling logic. It can be extended
to include logging, user notifications, or other actions as needed.
"""
if is_verbose():
... |
Handle errors by printing the error message and exiting the program.
This function is a placeholder for error handling logic. It can be extended
to include logging, user notifications, or other actions as needed.
| handle_error | python | ly4k/Certipy | certipy/lib/errors.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/errors.py | MIT |
def try_to_save_file(
data: Union[bytes, str], output_path: str, abort_on_fail: bool = False
) -> str:
"""
Try to write data to a file or stdout if file writing fails.
This function attempts to save data to the specified path. If writing fails,
it outputs to stdout instead. If the file already exis... |
Try to write data to a file or stdout if file writing fails.
This function attempts to save data to the specified path. If writing fails,
it outputs to stdout instead. If the file already exists, the user is
prompted to confirm overwriting.
Args:
data: Data to write (either binary bytes o... | try_to_save_file | python | ly4k/Certipy | certipy/lib/files.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/files.py | MIT |
def _handle_file_exists(path: str) -> str:
"""
Handle the case where a file already exists.
Prompts the user to confirm overwriting or generates a new unique filename.
If the user chooses not to overwrite, a UUID is appended to create a unique name.
Args:
path: Original file path
Retu... |
Handle the case where a file already exists.
Prompts the user to confirm overwriting or generates a new unique filename.
If the user chooses not to overwrite, a UUID is appended to create a unique name.
Args:
path: Original file path
Returns:
Final path to use (either original or... | _handle_file_exists | python | ly4k/Certipy | certipy/lib/files.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/files.py | MIT |
def _write_to_stdout(data: Union[bytes, str]) -> None:
"""
Write data to stdout, encoding binary data as base64 if needed.
Args:
data: Data to output (binary data will be base64 encoded)
"""
if isinstance(data, bytes):
print(base64.b64encode(data).decode())
else:
print(d... |
Write data to stdout, encoding binary data as base64 if needed.
Args:
data: Data to output (binary data will be base64 encoded)
| _write_to_stdout | python | ly4k/Certipy | certipy/lib/files.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/files.py | MIT |
def to_pascal_case(snake_str: str) -> str:
"""
Convert a snake_case string to PascalCase.
Args:
snake_str: String in snake_case format
Returns:
String converted to PascalCase
Example:
>>> to_pascal_case("hello_world")
"HelloWorld"
"""
components = snake_str... |
Convert a snake_case string to PascalCase.
Args:
snake_str: String in snake_case format
Returns:
String converted to PascalCase
Example:
>>> to_pascal_case("hello_world")
"HelloWorld"
| to_pascal_case | python | ly4k/Certipy | certipy/lib/formatting.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/formatting.py | MIT |
def pretty_print(
data: JsonLike, indent: int = 0, padding: int = 40, print_func: PrintFunc = print
) -> None:
"""
Pretty print a dictionary with customizable indentation and padding.
Handles nested dictionaries, lists, and various data types with appropriate formatting.
Args:
data: Dictio... |
Pretty print a dictionary with customizable indentation and padding.
Handles nested dictionaries, lists, and various data types with appropriate formatting.
Args:
data: Dictionary to print
indent: Initial indentation level
padding: Left padding for values
print_func: Funct... | pretty_print | python | ly4k/Certipy | certipy/lib/formatting.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/formatting.py | MIT |
def get_authentication_method(
authenticate_header: str,
) -> Literal["NTLM", "Negotiate"]:
"""
Get the authentication method from the WWW-Authenticate header.
Args:
authenticate_header: The WWW-Authenticate header value
Returns:
The authentication method (e.g., "NTLM", "Negotiate"... |
Get the authentication method from the WWW-Authenticate header.
Args:
authenticate_header: The WWW-Authenticate header value
Returns:
The authentication method (e.g., "NTLM", "Negotiate")
| get_authentication_method | python | ly4k/Certipy | certipy/lib/http.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/http.py | MIT |
def _convert_to_binary(data: Optional[str]) -> Optional[bytes]:
"""
Convert string hex representation to binary bytes.
Args:
data: String hex representation or None
Returns:
Bytes representation or None if input was None or empty
"""
if not data:
return None
return... |
Convert string hex representation to binary bytes.
Args:
data: String hex representation or None
Returns:
Bytes representation or None if input was None or empty
| _convert_to_binary | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def __init__(self, data: bytes, oid: bytes):
"""
Initialize a mechanism independent token.
Args:
data: Token data
oid: Object identifier for the authentication mechanism
"""
self.data = data
self.token_oid = oid |
Initialize a mechanism independent token.
Args:
data: Token data
oid: Object identifier for the authentication mechanism
| __init__ | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def from_bytes(data: bytes) -> "MechIndepToken":
"""
Parse a mechanism independent token from its binary representation.
Args:
data: Binary data to parse
Returns:
Parsed MechIndepToken object
Raises:
Exception: If the data format is invalid
... |
Parse a mechanism independent token from its binary representation.
Args:
data: Binary data to parse
Returns:
Parsed MechIndepToken object
Raises:
Exception: If the data format is invalid
| from_bytes | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def _get_length(data: bytes) -> Tuple[int, bytes]:
"""
Extract ASN.1 length from the given data.
Args:
data: Binary data containing ASN.1 length
Returns:
Tuple of (length, remaining_data)
"""
if data[0] < 128:
# Short form - length is... |
Extract ASN.1 length from the given data.
Args:
data: Binary data containing ASN.1 length
Returns:
Tuple of (length, remaining_data)
| _get_length | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def _encode_length(length: int) -> bytes:
"""
Encode a length value in ASN.1 format.
Args:
length: Length value to encode
Returns:
ASN.1 encoded length bytes
"""
if length < 128:
# Short form - single byte
return length.to... |
Encode a length value in ASN.1 format.
Args:
length: Length value to encode
Returns:
ASN.1 encoded length bytes
| _encode_length | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def to_bytes(self) -> Tuple[bytes, bytes]:
"""
Convert the token to its binary representation.
Returns:
Tuple of (header_bytes, data_bytes)
"""
complete_token = self.token_oid + self.data
# Create the ASN.1 structure
token_bytes = (
b"\x6... |
Convert the token to its binary representation.
Returns:
Tuple of (header_bytes, data_bytes)
| to_bytes | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def __init__(self, cipher: type, session_key: Key):
"""
Initialize the KerberosCipher object.
Args:
cipher: Cipher class for encryption/decryption
session_key: Session key for encryption/decryption
"""
self.cipher = create_kerberos_cipher(cipher)
... |
Initialize the KerberosCipher object.
Args:
cipher: Cipher class for encryption/decryption
session_key: Session key for encryption/decryption
| __init__ | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def encrypt(self, data: bytes, sequence_number: int) -> Tuple[bytes, bytes]:
"""
Encrypt data using the appropriate Kerberos cipher.
Automatically selects between RC4 and AES encryption based on the
cipher type.
Args:
data: Plaintext data to encrypt
sequ... |
Encrypt data using the appropriate Kerberos cipher.
Automatically selects between RC4 and AES encryption based on the
cipher type.
Args:
data: Plaintext data to encrypt
sequence_number: Message sequence number for integrity
Returns:
Tuple o... | encrypt | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def decrypt(self, data: bytes) -> bytes:
"""
Decrypt data using the appropriate Kerberos cipher.
Automatically selects between RC4 and AES decryption based on the
cipher type.
Args:
data: Encrypted data to decrypt
Returns:
Decrypted plaintext
... |
Decrypt data using the appropriate Kerberos cipher.
Automatically selects between RC4 and AES decryption based on the
cipher type.
Args:
data: Encrypted data to decrypt
Returns:
Decrypted plaintext
| decrypt | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def _encrypt_aes(self, data: bytes, sequence_number: int) -> Tuple[bytes, bytes]:
"""
Encrypt data using AES cipher.
Args:
data: Plaintext data to encrypt
sequence_number: Message sequence number for integrity
Returns:
Tuple of (cipher_text, signatur... |
Encrypt data using AES cipher.
Args:
data: Plaintext data to encrypt
sequence_number: Message sequence number for integrity
Returns:
Tuple of (cipher_text, signature)
Raises:
ValueError: If RC4 cipher is provided for AES encryption
... | _encrypt_aes | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def _decrypt_aes(self, data: bytes) -> bytes:
"""
Decrypt data using AES cipher.
Args:
data: Encrypted data to decrypt
Returns:
Decrypted plaintext
Raises:
ValueError: If RC4 cipher is provided for AES decryption
"""
if isins... |
Decrypt data using AES cipher.
Args:
data: Encrypted data to decrypt
Returns:
Decrypted plaintext
Raises:
ValueError: If RC4 cipher is provided for AES decryption
| _decrypt_aes | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def _encrypt_rc4(self, data: bytes, sequence_number: int) -> Tuple[bytes, bytes]:
"""
Encrypt data using RC4 cipher.
Args:
data: Plaintext data to encrypt
sequence_number: Message sequence number for integrity
Returns:
Tuple of (cipher_text, signatur... |
Encrypt data using RC4 cipher.
Args:
data: Plaintext data to encrypt
sequence_number: Message sequence number for integrity
Returns:
Tuple of (cipher_text, signature)
Raises:
ValueError: If AES cipher is provided for RC4 encryption
... | _encrypt_rc4 | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def _decrypt_rc4(self, data: bytes) -> bytes:
"""
Decrypt data using RC4 cipher.
Args:
data: Encrypted data to decrypt
Returns:
Decrypted plaintext
Raises:
ValueError: If AES cipher is provided for RC4 decryption
Exception: If da... |
Decrypt data using RC4 cipher.
Args:
data: Encrypted data to decrypt
Returns:
Decrypted plaintext
Raises:
ValueError: If AES cipher is provided for RC4 decryption
Exception: If data format is invalid
| _decrypt_rc4 | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def __init__(
self, target: Target, service: str = "HTTP", channel_binding: bool = True
):
"""
Initialize the Kerberos authentication handler.
Args:
target: Target object containing connection and authentication details
service: Service principal name prefix ... |
Initialize the Kerberos authentication handler.
Args:
target: Target object containing connection and authentication details
service: Service principal name prefix (default: "HTTP")
channel_binding: Whether to use channel binding for EPA compliance
| __init__ | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def auth_flow(
self, request: httpx.Request
) -> Generator[httpx.Request, httpx.Response, None]:
"""
Implement the authentication flow for HTTPX.
This generator handles the first request and delegates to retry_with_auth
if authentication is required.
Args:
... |
Implement the authentication flow for HTTPX.
This generator handles the first request and delegates to retry_with_auth
if authentication is required.
Args:
request: The HTTPX request to authenticate
Yields:
Modified requests with appropriate authentica... | auth_flow | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def retry_with_auth(
self, request: httpx.Request, response: httpx.Response
) -> Generator[httpx.Request, httpx.Response, None]:
"""
Retry the request with Kerberos authentication.
This method adds Kerberos SPNEGO authentication header to the request.
Args:
requ... |
Retry the request with Kerberos authentication.
This method adds Kerberos SPNEGO authentication header to the request.
Args:
request: The original HTTPX request
response: The HTTPX response requiring authentication
Yields:
Modified request with Ker... | retry_with_auth | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def get_kerberos_type1(
target: Target,
target_name: str = "",
service: str = "HOST",
channel_binding_data: Optional[bytes] = None,
signing: bool = False,
) -> Tuple[type, Key, bytes, str]:
"""
Generate a Kerberos Type 1 authentication message (AP_REQ).
Creates a SPNEGO token containing... |
Generate a Kerberos Type 1 authentication message (AP_REQ).
Creates a SPNEGO token containing Kerberos AP_REQ that can be used for HTTP
or other protocol authentication. Supports channel binding for EPA.
Args:
target: Target object containing authentication details
target_name: Name o... | get_kerberos_type1 | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def get_tgs(
target: Target,
target_name: str,
service: str = "HOST",
) -> Tuple[bytes, type, Key, str, str]:
"""
Obtain a Ticket Granting Service (TGS) ticket for the specified service.
This function implements a multi-step strategy for acquiring a TGS:
1. Try to use credentials from an ex... |
Obtain a Ticket Granting Service (TGS) ticket for the specified service.
This function implements a multi-step strategy for acquiring a TGS:
1. Try to use credentials from an existing Kerberos ticket cache (KRB5CCNAME)
2. Request a new TGT using provided credentials if needed
3. Use the TGT to req... | get_tgs | python | ly4k/Certipy | certipy/lib/kerberos.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/kerberos.py | MIT |
def get_account_type(entry: "LDAPEntry") -> str:
"""
Determine the type of Active Directory account based on sAMAccountType and objectClass.
Args:
entry: LDAP entry containing account attributes
Returns:
Account type as string: "Group", "Computer", "User", "TrustAccount", or "Domain"
... |
Determine the type of Active Directory account based on sAMAccountType and objectClass.
Args:
entry: LDAP entry containing account attributes
Returns:
Account type as string: "Group", "Computer", "User", "TrustAccount", or "Domain"
| get_account_type | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def get(self, key: str, default: Any = None) -> Any:
"""
Get an attribute value from the LDAP entry with support for default values.
This method provides convenient access to LDAP attributes and handles several
special cases, including missing attributes and empty lists.
Args:
... |
Get an attribute value from the LDAP entry with support for default values.
This method provides convenient access to LDAP attributes and handles several
special cases, including missing attributes and empty lists.
Args:
key: Attribute name to retrieve
default:... | get | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def get_raw(self, key: str) -> Any:
"""
Get the raw (unprocessed) attribute value from the LDAP entry.
Args:
key: Attribute name to retrieve
Returns:
Raw attribute value or None if not present
"""
if key not in self.__getitem__("raw_attributes").... |
Get the raw (unprocessed) attribute value from the LDAP entry.
Args:
key: Attribute name to retrieve
Returns:
Raw attribute value or None if not present
| get_raw | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def __init__(self, connection: "ExtendedLdapConnection") -> None:
"""
Initialize the extended strategy with a connection.
Args:
connection: The ExtendedLdapConnection to use
"""
super().__init__(connection)
self._connection = connection
# Override the... |
Initialize the extended strategy with a connection.
Args:
connection: The ExtendedLdapConnection to use
| __init__ | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def sending(self, ldap_message: Any) -> None:
"""
Send an LDAP message, optionally encrypting it first.
Args:
ldap_message: The LDAP message to send
Raises:
socket.error: If sending fails
"""
try:
encoded_message = cast(bytes, ldap3_e... |
Send an LDAP message, optionally encrypting it first.
Args:
ldap_message: The LDAP message to send
Raises:
socket.error: If sending fails
| sending | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def _receiving(self) -> List[bytes]: # type: ignore
"""
Receive data over the socket and handle message encryption/decryption.
Returns:
List of received LDAP messages
Raises:
Exception: On socket or receive errors
"""
messages = []
recei... |
Receive data over the socket and handle message encryption/decryption.
Returns:
List of received LDAP messages
Raises:
Exception: On socket or receive errors
| _receiving | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def __init__(
self, target: Target, *args: Any, channel_binding: bool = True, **kwargs: Any
) -> None:
"""
Initialize an extended LDAP connection with the specified target.
Args:
target: Target object containing connection details
channel_binding: Whether to ... |
Initialize an extended LDAP connection with the specified target.
Args:
target: Target object containing connection details
channel_binding: Whether to use channel binding (default: True)
*args: Additional positional arguments for the parent class
**kwar... | __init__ | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def _encrypt(self, data: bytes) -> bytes:
"""
Encrypt LDAP message data using the appropriate cipher.
Args:
data: Plaintext data to encrypt
Returns:
Encrypted data with appropriate headers and signatures
"""
if self.ntlm_cipher is not None:
... |
Encrypt LDAP message data using the appropriate cipher.
Args:
data: Plaintext data to encrypt
Returns:
Encrypted data with appropriate headers and signatures
| _encrypt | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def _decrypt(self, data: bytes) -> bytes:
"""
Decrypt LDAP message data using the appropriate cipher.
Args:
data: Encrypted data to decrypt
Returns:
Decrypted plaintext data
"""
if self.ntlm_cipher is not None:
# NTLM decryption
... |
Decrypt LDAP message data using the appropriate cipher.
Args:
data: Encrypted data to decrypt
Returns:
Decrypted plaintext data
| _decrypt | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def do_ntlm_bind(self, controls: Any) -> Dict[str, Any]:
"""
Perform NTLM bind operation with optional controls.
This method implements the complete NTLM authentication flow:
1. Sicily package discovery to verify NTLM support
2. NTLM negotiate message exchange
3. Challen... |
Perform NTLM bind operation with optional controls.
This method implements the complete NTLM authentication flow:
1. Sicily package discovery to verify NTLM support
2. NTLM negotiate message exchange
3. Challenge/response handling with optional channel binding
4. Sessio... | do_ntlm_bind | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def __init__(
self,
target: Target,
schannel_auth: Optional[Tuple[x509.Certificate, PrivateKeyTypes]] = None,
) -> None:
"""
Initialize an LDAP connection with the specified target.
Args:
target: Target object containing connection details
lda... |
Initialize an LDAP connection with the specified target.
Args:
target: Target object containing connection details
ldap_pfx: Optional tuple containing LDAP PFX file path and password
| __init__ | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def connect(self) -> None:
"""
Connect to the LDAP server with the specified SSL/TLS version.
This method establishes a connection to the LDAP server and handles
authentication using the credentials from the target object.
It supports multiple authentication methods:
- K... |
Connect to the LDAP server with the specified SSL/TLS version.
This method establishes a connection to the LDAP server and handles
authentication using the credentials from the target object.
It supports multiple authentication methods:
- Kerberos
- NTLM
- Simpl... | connect | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def _kerberos_login(self, connection: "ExtendedLdapConnection") -> None:
"""
Perform Kerberos authentication to LDAP server.
Args:
connection: LDAP connection object
Raises:
Exception: If Kerberos authentication fails
"""
# Ensure connection is ... |
Perform Kerberos authentication to LDAP server.
Args:
connection: LDAP connection object
Raises:
Exception: If Kerberos authentication fails
| _kerberos_login | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def _check_ldap_result(self, result: Dict[str, Any]) -> None:
"""
Handle LDAP errors based on the result dictionary.
Args:
result: Result dictionary from the LDAP bind operation
Raises:
Exception: If an error occurs during the LDAP operation
"""
... |
Handle LDAP errors based on the result dictionary.
Args:
result: Result dictionary from the LDAP bind operation
Raises:
Exception: If an error occurs during the LDAP operation
| _check_ldap_result | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def add(self, *args: Any, **kwargs: Any) -> Any:
"""
Add a new entry to the LDAP directory.
Args:
*args: Arguments to pass to the underlying LDAP add operation
**kwargs: Keyword arguments to pass to the underlying LDAP add operation
Returns:
Result o... |
Add a new entry to the LDAP directory.
Args:
*args: Arguments to pass to the underlying LDAP add operation
**kwargs: Keyword arguments to pass to the underlying LDAP add operation
Returns:
Result of the add operation
Raises:
Exception: ... | add | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def delete(self, *args: Any, **kwargs: Any) -> Any:
"""
Delete an entry from the LDAP directory.
Args:
*args: Arguments to pass to the underlying LDAP delete operation
**kwargs: Keyword arguments to pass to the underlying LDAP delete operation
Returns:
... |
Delete an entry from the LDAP directory.
Args:
*args: Arguments to pass to the underlying LDAP delete operation
**kwargs: Keyword arguments to pass to the underlying LDAP delete operation
Returns:
Result of the delete operation
Raises:
... | delete | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def modify(self, *args: Any, **kwargs: Any) -> Any:
"""
Modify an existing entry in the LDAP directory.
Args:
*args: Arguments to pass to the underlying LDAP modify operation
**kwargs: Keyword arguments to pass to the underlying LDAP modify operation
Returns:
... |
Modify an existing entry in the LDAP directory.
Args:
*args: Arguments to pass to the underlying LDAP modify operation
**kwargs: Keyword arguments to pass to the underlying LDAP modify operation
Returns:
Result of the modify operation
Raises:
... | modify | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def search(
self,
search_filter: str,
attributes: Union[str, List[str]] = ldap3.ALL_ATTRIBUTES,
search_base: Optional[str] = None,
query_sd: bool = False,
**kwargs: Any,
) -> List[LDAPEntry]:
"""
Search the LDAP directory with the given filter and retu... |
Search the LDAP directory with the given filter and return matching entries.
Args:
search_filter: LDAP search filter string
attributes: List of attributes to retrieve or ldap3.ALL_ATTRIBUTES
search_base: Base DN for the search, defaults to domain base
qu... | search | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def get_user(
self, username: str, silent: bool = False, *args: Any, **kwargs: Any
) -> Optional[LDAPEntry]:
"""
Find a user by samAccountName.
This method searches for a user by samAccountName and automatically
handles computer account naming ($) if needed.
Args:
... |
Find a user by samAccountName.
This method searches for a user by samAccountName and automatically
handles computer account naming ($) if needed.
Args:
username: Username to search for (samAccountName)
silent: Whether to suppress error logging for missing users... | get_user | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def _get_user(username: str, *args: Any, **kwargs: Any) -> Optional[LDAPEntry]:
"""Helper function to search for a user, with caching."""
sanitized_username = username.lower().strip()
# Return cached result if available
if sanitized_username in self._users:
... | Helper function to search for a user, with caching. | _get_user | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def domain_sid(self) -> Optional[str]:
"""
Get the domain's security identifier (SID).
The domain SID is the base identifier used for all domain security principals.
Returns:
Domain SID or None if not found
"""
# Return cached value if available
if s... |
Get the domain's security identifier (SID).
The domain SID is the base identifier used for all domain security principals.
Returns:
Domain SID or None if not found
| domain_sid | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def get_user_sids(
self,
username: str,
user_sid: Optional[str] = None,
user_dn: Optional[str] = None,
) -> Set[str]:
"""
Get all SIDs associated with a user, including groups.
This method collects all security identifiers (SIDs) that apply to a user,
... |
Get all SIDs associated with a user, including groups.
This method collects all security identifiers (SIDs) that apply to a user,
including the user's personal SID, well-known SIDs, primary group SID,
and all group memberships (direct and nested).
Args:
username: U... | get_user_sids | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def lookup_sid(self, sid: str) -> LDAPEntry:
"""
Look up an object by its SID.
This method finds an Active Directory object by its security identifier,
or returns a synthetic entry for well-known SIDs.
Args:
sid: Security identifier to look up
Returns:
... |
Look up an object by its SID.
This method finds an Active Directory object by its security identifier,
or returns a synthetic entry for well-known SIDs.
Args:
sid: Security identifier to look up
Returns:
LDAPEntry for the object, or a synthetic entry f... | lookup_sid | python | ly4k/Certipy | certipy/lib/ldap.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/ldap.py | MIT |
def set_verbose(is_verbose: bool) -> None:
"""
Set the verbosity level for logging.
Args:
is_verbose: Boolean indicating whether to enable verbose logging
"""
global _IS_VERBOSE
_IS_VERBOSE = is_verbose # type: ignore |
Set the verbosity level for logging.
Args:
is_verbose: Boolean indicating whether to enable verbose logging
| set_verbose | python | ly4k/Certipy | certipy/lib/logger.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/logger.py | MIT |
def format(self, record: _logging.LogRecord) -> str:
"""
Format the log record by adding an appropriate bullet point.
Args:
record: The log record to format
Returns:
Formatted log message with bullet point prefix
"""
# Add bullet point based on l... |
Format the log record by adding an appropriate bullet point.
Args:
record: The log record to format
Returns:
Formatted log message with bullet point prefix
| format | python | ly4k/Certipy | certipy/lib/logger.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/logger.py | MIT |
def init(
level: int = _logging.INFO, logger_name: str = "certipy", propagate: bool = False
) -> None:
"""
Initialize the Certipy logger with the appropriate formatter.
Args:
level: Log level to set (default: INFO)
logger_name: Name of the logger to configure (default: "certipy")
... |
Initialize the Certipy logger with the appropriate formatter.
Args:
level: Log level to set (default: INFO)
logger_name: Name of the logger to configure (default: "certipy")
propagate: Whether to propagate logs to parent loggers (default: False)
Note:
This function configu... | init | python | ly4k/Certipy | certipy/lib/logger.py | https://github.com/ly4k/Certipy/blob/master/certipy/lib/logger.py | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.