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: str, ca: Optional[str] = None, template: Optional[str] = None, upn: Optional[str] = None, dns: Optional[str] = None, sid: Optional[str] = None, subject: Optional[str] = None, application_policies: Optional[List[str]] = N...
Initialize the NTLM relay attack. Args: target: Target AD CS server (http://server/certsrv/ or rpc://server) ca: Certificate Authority name (required for RPC) template: Certificate template to request upn: Alternative UPN (User Principal Name) ...
__init__
python
ly4k/Certipy
certipy/commands/relay.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/relay.py
MIT
def request(self) -> Request: """ Get the current request object. Returns: The current request object """ if not self._request is None: return self._request self._request = Request( Target( DnsResolver.create(), ...
Get the current request object. Returns: The current request object
request
python
ly4k/Certipy
certipy/commands/relay.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/relay.py
MIT
def start(self) -> None: """ Start the relay server and wait for connections. """ logging.info(f"Listening on {self.interface}:{self.port}") self.server.start() try: # Main loop - wait for connections while True: time.sleep(0.1) ...
Start the relay server and wait for connections.
start
python
ly4k/Certipy
certipy/commands/relay.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/relay.py
MIT
def entry(options: argparse.Namespace) -> None: """ Command-line entry point for relay functionality. Args: options: Command line arguments """ # Initialize logging from Impacket _impacket_logger.init() relay = Relay(**vars(options)) relay.start()
Command-line entry point for relay functionality. Args: options: Command line arguments
entry
python
ly4k/Certipy
certipy/commands/relay.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/relay.py
MIT
def entry(options: argparse.Namespace) -> None: """ Command-line entry point for certificate operations. Args: options: Command-line arguments """ # Create target from options target = Target.from_options(options) options.__delattr__("target") # Create request object reques...
Command-line entry point for certificate operations. Args: options: Command-line arguments
entry
python
ly4k/Certipy
certipy/commands/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/req.py
MIT
def __init__( self, target: Target, account: str, device_id: Optional[str] = None, out: Optional[str] = None, connection: Optional[LDAPConnection] = None, **kwargs, # type: ignore ): """ Initialize the Shadow Authentication module. Ar...
Initialize the Shadow Authentication module. Args: target: Target information including domain, username, and authentication details account: Account to target for Key Credential operations device_id: Device ID for operations that require targeting a specific Key Cr...
__init__
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def connection(self) -> LDAPConnection: """ Get or establish an LDAP connection to the domain. Returns: Active LDAP connection Raises: Exception: If connection fails """ if self._connection is not None: return self._connection ...
Get or establish an LDAP connection to the domain. Returns: Active LDAP connection Raises: Exception: If connection fails
connection
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def get_key_credentials( self, target_dn: str, user: LDAPEntry ) -> Optional[List[bytes]]: """ Retrieve the current Key Credentials for a user. Args: target_dn: Distinguished name of the target user user: LDAP user entry Returns: List of ...
Retrieve the current Key Credentials for a user. Args: target_dn: Distinguished name of the target user user: LDAP user entry Returns: List of Key Credential binary values or None on failure
get_key_credentials
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def set_key_credentials( self, target_dn: str, user: LDAPEntry, key_credential: List[Union[bytes, str]] ) -> bool: """ Set new Key Credentials for a user. Args: target_dn: Distinguished name of the target user user: LDAP user entry key_credential:...
Set new Key Credentials for a user. Args: target_dn: Distinguished name of the target user user: LDAP user entry key_credential: List of Key Credential binary values to set Returns: True on success, False on failure
set_key_credentials
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def generate_key_credential( self, target_dn: str, subject: str ) -> Tuple[X509Certificate2, KeyCredential, str]: """ Generate a new certificate and Key Credential object. Args: target_dn: Distinguished name of the target user subject: Certificate subject nam...
Generate a new certificate and Key Credential object. Args: target_dn: Distinguished name of the target user subject: Certificate subject name Returns: Tuple containing (certificate, key_credential, device_id)
generate_key_credential
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def add_new_key_credential( self, target_dn: str, user: LDAPEntry ) -> Optional[Tuple[X509Certificate2, List[Union[bytes, str]], List[bytes], str]]: """ Add a new Key Credential to a user. Args: target_dn: Distinguished name of the target user user: LDAP user...
Add a new Key Credential to a user. Args: target_dn: Distinguished name of the target user user: LDAP user entry Returns: Tuple containing (certificate, new_key_credential_list, saved_key_credential_list, device_id) or None on f...
add_new_key_credential
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def get_key_and_certificate( self, cert2: X509Certificate2 ) -> Tuple[PrivateKeyTypes, x509.Certificate]: """ Extract the private key and certificate from an X509Certificate2 object. Args: cert2: X509Certificate2 object Returns: Tuple containing (pri...
Extract the private key and certificate from an X509Certificate2 object. Args: cert2: X509Certificate2 object Returns: Tuple containing (private_key, certificate)
get_key_and_certificate
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def _get_target_dn(self, user: LDAPEntry) -> Optional[str]: """ Get the distinguished name from a user entry and validate it. Args: user: LDAP user entry Returns: Distinguished name string or None if invalid """ target_dn = user.get("distinguishe...
Get the distinguished name from a user entry and validate it. Args: user: LDAP user entry Returns: Distinguished name string or None if invalid
_get_target_dn
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def _get_sam_account_name(self, user: LDAPEntry) -> str: """ Get the SAM account name from a user entry. Args: user: LDAP user entry Returns: SAM account name string """ sam_account_name = user.get("sAMAccountName") if not isinstance(sam...
Get the SAM account name from a user entry. Args: user: LDAP user entry Returns: SAM account name string
_get_sam_account_name
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def auto(self) -> Optional[str]: """ Automatically add a Key Credential, authenticate, get NT hash, and restore original state. This is the most common attack scenario - adding a temporary Key Credential, using it to authenticate and get the NT hash, then cleaning up by restoring ...
Automatically add a Key Credential, authenticate, get NT hash, and restore original state. This is the most common attack scenario - adding a temporary Key Credential, using it to authenticate and get the NT hash, then cleaning up by restoring the original Key Credentials. Ret...
auto
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def add(self) -> bool: """ Add a new Key Credential to a user and save the certificate as a PFX file. Returns: True on success, False on failure """ # Get the target user user = self.connection.get_user(self.account) if user is None: retur...
Add a new Key Credential to a user and save the certificate as a PFX file. Returns: True on success, False on failure
add
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def list(self) -> bool: """ List all Key Credentials for a user. Returns: True if Key Credentials were found and listed, False otherwise """ # Get the target user user = self.connection.get_user(self.account) if user is None: return False ...
List all Key Credentials for a user. Returns: True if Key Credentials were found and listed, False otherwise
list
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def clear(self) -> bool: """ Clear all Key Credentials for a user. Returns: True on success, False on failure """ # Get the target user user = self.connection.get_user(self.account) if user is None: return False sam_account_name =...
Clear all Key Credentials for a user. Returns: True on success, False on failure
clear
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def remove(self) -> bool: """ Remove a specific Key Credential identified by its Device ID. Returns: True on success, False on failure """ # Ensure a device ID was provided if self.device_id is None: logging.error( "A device ID (-d...
Remove a specific Key Credential identified by its Device ID. Returns: True on success, False on failure
remove
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def info(self) -> bool: """ Show detailed information about a specific Key Credential. Returns: True if the Key Credential was found and info displayed, False otherwise """ # Ensure a device ID was provided if self.device_id is None: logging.error...
Show detailed information about a specific Key Credential. Returns: True if the Key Credential was found and info displayed, False otherwise
info
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def entry(options: argparse.Namespace) -> None: """ Command-line entry point for Shadow Authentication operations. Args: options: Command-line arguments """ # Create target from options target = Target.from_options(options) # Use provided account or default to the authenticated use...
Command-line entry point for Shadow Authentication operations. Args: options: Command-line arguments
entry
python
ly4k/Certipy
certipy/commands/shadow.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/shadow.py
MIT
def default_into_transformer(value: Any) -> Any: """ Default transformer function that returns the value unchanged. Args: value: The value to transform Returns: The original value """ if isinstance(value, list): return [default_into_transformer(item) for item in value] ...
Default transformer function that returns the value unchanged. Args: value: The value to transform Returns: The original value
default_into_transformer
python
ly4k/Certipy
certipy/commands/template.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py
MIT
def default_from_transformer(value: Any) -> Any: """ Default transformer function that converts a value to its original form. Args: value: The value to transform Returns: The original value """ if isinstance(value, list): return [default_from_transformer(item) for item ...
Default transformer function that converts a value to its original form. Args: value: The value to transform Returns: The original value
default_from_transformer
python
ly4k/Certipy
certipy/commands/template.py
https://github.com/ly4k/Certipy/blob/master/certipy/commands/template.py
MIT
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