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, 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
def compute_response( server_challenge: bytes, client_challenge: bytes, target_info: bytes, domain: str, user: str, password: str, nt_hash: str = "", channel_binding_data: Optional[bytes] = None, service: str = "HOST", ) -> Tuple[bytes, bytes, bytes, bytes]: """ Compute NTLMv...
Compute NTLMv2 response based on the provided parameters. Args: server_challenge: Challenge received from the server client_challenge: Client-generated random challenge target_info: Target information provided by the server domain: Domain name for authentication user: U...
compute_response
python
ly4k/Certipy
certipy/lib/ntlm.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/ntlm.py
MIT
def ntlm_negotiate( signing_required: bool = False, use_ntlmv2: bool = True, version: Optional[bytes] = None, ) -> NTLMAuthNegotiate: """ Generate an NTLMSSP Type 1 negotiation message. Args: signing_required: Whether signing is required for the connection use_ntlmv2: Whether to...
Generate an NTLMSSP Type 1 negotiation message. Args: signing_required: Whether signing is required for the connection use_ntlmv2: Whether to use NTLMv2 (should be True for modern systems) version: OS version to include in the message Returns: NTLMAuthNegotiate object repr...
ntlm_negotiate
python
ly4k/Certipy
certipy/lib/ntlm.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/ntlm.py
MIT
def ntlm_authenticate( type1: NTLMAuthNegotiate, challenge: NTLMAuthChallenge, user: str, password: str, domain: str, nt_hash: str = "", channel_binding_data: Optional[bytes] = None, service: str = "HOST", version: Optional[bytes] = None, ) -> Tuple[NTLMAuthChallengeResponse, bytes, ...
Generate an NTLMSSP Type 3 authentication message in response to a server challenge. Args: type1: The Type 1 negotiate message that was sent challenge: The Type 2 challenge message received from the server user: Username for authentication password: Password for authentication ...
ntlm_authenticate
python
ly4k/Certipy
certipy/lib/ntlm.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/ntlm.py
MIT
def __init__( self, target: Target, service: str = DEFAULT_SERVICE, channel_binding: bool = False, ): """ Initialize the NTLM authentication handler. Args: target: Target object containing connection and authentication details service:...
Initialize the NTLM authentication handler. Args: target: Target object containing connection and authentication details service: Service principal name prefix to use (default: "HTTP") channel_binding: Whether to use channel binding for EPA compliance
__init__
python
ly4k/Certipy
certipy/lib/ntlm.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/ntlm.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 NTLM authentication protocol flow by: 1. Sending the initial request 2. If authentication is r...
Implement the authentication flow for HTTPX. This generator handles the NTLM authentication protocol flow by: 1. Sending the initial request 2. If authentication is required, starting the NTLM flow 3. Completing the NTLM handshake Args: request: The HTTPX r...
auth_flow
python
ly4k/Certipy
certipy/lib/ntlm.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/ntlm.py
MIT
def retry_with_auth( self, request: httpx.Request, response: httpx.Response ) -> Generator[httpx.Request, httpx.Response, None]: """ Retry the request with NTLM authentication. Implements the complete NTLM authentication flow: 1. Send Type 1 (Negotiate) message 2. Pr...
Retry the request with NTLM authentication. Implements the complete NTLM authentication flow: 1. Send Type 1 (Negotiate) message 2. Process Type 2 (Challenge) message from server 3. Send Type 3 (Authenticate) message Args: request: The original HTTPX reques...
retry_with_auth
python
ly4k/Certipy
certipy/lib/ntlm.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/ntlm.py
MIT
def __init__(self, p: int, g: int): """Initialize a new DH instance with random private key.""" self.p = p self.g = g self.private_key = os.urandom(32) self.private_key_int = int.from_bytes(self.private_key, byteorder="big") self.dh_nonce = os.urandom(32)
Initialize a new DH instance with random private key.
__init__
python
ly4k/Certipy
certipy/lib/pkinit.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/pkinit.py
MIT
def get_public_key(self) -> int: """ Calculate the public key. Returns: Public key value (g^x mod p) Raises: ValueError: If p and g are not set """ # y = g^x mod p return pow(self.g, self.private_key_int, self.p)
Calculate the public key. Returns: Public key value (g^x mod p) Raises: ValueError: If p and g are not set
get_public_key
python
ly4k/Certipy
certipy/lib/pkinit.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/pkinit.py
MIT
def exchange(self, peer_public_key: int) -> bytes: """ Perform key exchange with peer's public key. Args: peer_public_key: Peer's public key value Returns: The shared secret as bytes """ shared_key_int = pow(peer_public_key, self.private_key_int,...
Perform key exchange with peer's public key. Args: peer_public_key: Peer's public key value Returns: The shared secret as bytes
exchange
python
ly4k/Certipy
certipy/lib/pkinit.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/pkinit.py
MIT
def sign_authpack( data: bytes, key: rsa.RSAPrivateKey, cert: Union[x509.Certificate, asn1x509.Certificate], ) -> bytes: """ Create a signed CMS structure containing the AuthPack. Args: data: The AuthPack data to sign key: RSA private key for signing cert: Certificate to...
Create a signed CMS structure containing the AuthPack. Args: data: The AuthPack data to sign key: RSA private key for signing cert: Certificate to include in the signed data Returns: ASN.1 DER encoded CMS signed data
sign_authpack
python
ly4k/Certipy
certipy/lib/pkinit.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/pkinit.py
MIT
def build_pkinit_as_req( username: str, domain: str, key: rsa.RSAPrivateKey, cert: x509.Certificate ) -> Tuple[bytes, DirtyDH]: """ Build a PKINIT AS-REQ message. Args: username: Client username domain: Domain/realm name key: RSA private key for signing cert: Client cert...
Build a PKINIT AS-REQ message. Args: username: Client username domain: Domain/realm name key: RSA private key for signing cert: Client certificate Returns: A tuple containing: - The encoded AS-REQ message - The DirtyDH object for later key exchange ...
build_pkinit_as_req
python
ly4k/Certipy
certipy/lib/pkinit.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/pkinit.py
MIT
def __init__(self, *args, **kwargs) -> None: # type: ignore """ Initialize a registry entry. Args: **kwargs: Key-value pairs to initialize the entry with """ super().__init__(self, *args, **kwargs) if "attributes" not in self: self["attributes"] ...
Initialize a registry entry. Args: **kwargs: Key-value pairs to initialize the entry with
__init__
python
ly4k/Certipy
certipy/lib/registry.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/registry.py
MIT
def get_raw(self, key: str) -> Union[bytes, List[bytes], None]: """ Get a raw (bytes) representation of an attribute value. Args: key: The attribute name to retrieve Returns: Raw data as bytes, list of bytes, or None if not found Notes: - St...
Get a raw (bytes) representation of an attribute value. Args: key: The attribute name to retrieve Returns: Raw data as bytes, list of bytes, or None if not found Notes: - String values are encoded to bytes - List values have each item e...
get_raw
python
ly4k/Certipy
certipy/lib/registry.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/registry.py
MIT
def __init__(self, domain: str, sids: List[str], scheme: str = "file") -> None: """ Initialize a registry connection. Args: domain: Domain name for the connection sids: List of security identifiers to track scheme: Connection scheme, defaults to "file" ...
Initialize a registry connection. Args: domain: Domain name for the connection sids: List of security identifiers to track scheme: Connection scheme, defaults to "file"
__init__
python
ly4k/Certipy
certipy/lib/registry.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/registry.py
MIT
def get_user_sids( self, _username: str, _user_sid: Optional[str] = None, _user_dn: Optional[str] = None, ) -> List[str]: """ Get user security identifiers. Args: _username: Username (not used in this implementation) _user_sid: User's ...
Get user security identifiers. Args: _username: Username (not used in this implementation) _user_sid: User's primary SID (not used in this implementation) _user_dn: User's distinguished name (not used in this implementation) Returns: List of SID...
get_user_sids
python
ly4k/Certipy
certipy/lib/registry.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/registry.py
MIT
def lookup_sid(self, sid: str) -> RegEntry: """ Look up a security identifier and return corresponding registry entry. Args: sid: Security identifier to look up Returns: RegEntry object representing the SID Notes: - Checks cached entries fir...
Look up a security identifier and return corresponding registry entry. Args: sid: Security identifier to look up Returns: RegEntry object representing the SID Notes: - Checks cached entries first - Then checks well-known SIDs ...
lookup_sid
python
ly4k/Certipy
certipy/lib/registry.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/registry.py
MIT
def __init__(self, interface: IRemUnknown2): """ Initialize the ICertRequestD interface. Args: interface: IRemUnknown2 interface from DCOM connection """ super().__init__(interface) self._iid = IID_ICertRequestD
Initialize the ICertRequestD interface. Args: interface: IRemUnknown2 interface from DCOM connection
__init__
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def __init__( self, error_string: Any = None, error_code: Any = None, packet: Any = None ): """ Initialize the DCERPCSessionError. Args: error_string: Error description error_code: Numeric error code packet: The RPC packet that caused the error ...
Initialize the DCERPCSessionError. Args: error_string: Error description error_code: Numeric error code packet: The RPC packet that caused the error
__init__
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def __str__(self) -> str: """ Format the error message with translated error code. Returns: Human-readable error message """ self.error_code &= 0xFFFFFFFF # type: ignore error_msg = translate_error_code(self.error_code) return f"RequestSessionError: ...
Format the error message with translated error code. Returns: Human-readable error message
__str__
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def handle_rpc_retrieve_response( response: Dict[str, Any], ) -> Optional[x509.Certificate]: """ Process the RPC certificate retrieval response. Args: response: The RPC response dictionary Returns: Certificate object if successful, None otherwise """ error_code = response["...
Process the RPC certificate retrieval response. Args: response: The RPC response dictionary Returns: Certificate object if successful, None otherwise
handle_rpc_retrieve_response
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def handle_rpc_request_response( response: Dict[str, Any], ) -> Union[x509.Certificate, int]: """ Process the RPC certificate request response. Args: response: The RPC response dictionary Returns: Certificate object if immediately successful, or request ID if pending/failed """...
Process the RPC certificate request response. Args: response: The RPC response dictionary Returns: Certificate object if immediately successful, or request ID if pending/failed
handle_rpc_request_response
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def handle_request_response( cert: x509.Certificate, key: PrivateKeyTypes, username: str, subject: Optional[str] = None, alt_sid: Optional[str] = None, out: Optional[str] = None, pfx_password: Optional[str] = None, ) -> Tuple[bytes, str]: """ Process a successful certificate request ...
Process a successful certificate request by saving the certificate and private key. Args: cert: The issued certificate key: The private key username: The username associated with the certificate subject: Optional subject name alt_sid: Optional alternate SID out:...
handle_request_response
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def handle_retrieve( cert: x509.Certificate, request_id: int, username: str, out: Optional[str] = None, pfx_password: Optional[str] = None, ) -> bool: """ Process a retrieved certificate by saving it with the private key if available. Args: cert: The retrieved certificate ...
Process a retrieved certificate by saving it with the private key if available. Args: cert: The retrieved certificate request_id: The certificate request ID username: The username associated with the certificate out: Optional output filename pfx_password: Optional PFX p...
handle_retrieve
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def handle_pending_key_save( request_id: int, key: PrivateKeyTypes, out: Optional[str] = None ) -> None: """ Offer to save the private key for pending certificate requests. Args: request_id: The certificate request ID key: The private key to save out: Optional output filename fo...
Offer to save the private key for pending certificate requests. Args: request_id: The certificate request ID key: The private key to save out: Optional output filename for the private key
handle_pending_key_save
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def web_request( session: httpx.Client, username: str, csr: Union[str, bytes, x509.CertificateSigningRequest], attributes_list: List[str], template: str, key: PrivateKeyTypes, out: Optional[str] = None, ) -> Optional[x509.Certificate]: """ Request a certificate via the web enrollment...
Request a certificate via the web enrollment interface. Args: session: HTTP session client username: Username for the certificate csr: Certificate signing request (bytes or object) attributes_list: List of certificate attributes template: Certificate template name ...
web_request
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def web_retrieve( session: httpx.Client, request_id: int, ) -> Optional[x509.Certificate]: """ Retrieve a certificate via the web enrollment interface. Args: session: HTTP session client request_id: The certificate request ID Returns: Certificate if successfully retriev...
Retrieve a certificate via the web enrollment interface. Args: session: HTTP session client request_id: The certificate request ID Returns: Certificate if successfully retrieved, None otherwise
web_retrieve
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def _determine_output_filename( out: Optional[str], identities: List[Tuple[str, str]], username: str ) -> str: """ Determine the output filename to use for saving certificates/keys. Args: out: User-specified output name (if any) identities: List of certificate identities usernam...
Determine the output filename to use for saving certificates/keys. Args: out: User-specified output name (if any) identities: List of certificate identities username: The username associated with the certificate Returns: The output filename (without extension)
_determine_output_filename
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def _handle_policy_denial(session: httpx.Client, request_id: int) -> None: """ Handle certificate request denied by policy. Args: session: HTTP session client request_id: The certificate request ID """ try: res = session.get("/certsrv/certnew.cer", params={"ReqID": request_i...
Handle certificate request denied by policy. Args: session: HTTP session client request_id: The certificate request ID
_handle_policy_denial
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def _handle_other_errors(content: str) -> None: """ Handle other certificate request errors. Args: content: Response content """ error_code_matches = re.findall( r"Denied by Policy Module (0x[0-9a-fA-F]+),", content ) try: if error_code_matches: error_c...
Handle other certificate request errors. Args: content: Response content
_handle_other_errors
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def _log_response_if_verbose(content: str) -> None: """ Log response content if verbose logging is enabled. Args: content: Response content to log """ if is_verbose(): print(content) else: logging.warning("Use -debug to print the response")
Log response content if verbose logging is enabled. Args: content: Response content to log
_log_response_if_verbose
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def __init__(self, parent: "Request"): """ Initialize the DCOM request interface. Args: parent: The parent Request object """ self.parent = parent self._dcom: Optional[DCOMConnection] = None
Initialize the DCOM request interface. Args: parent: The parent Request object
__init__
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def dcom(self) -> DCOMConnection: """ Get or establish a DCOM connection to the certificate authority. Returns: Active DCOM connection Raises: Exception: If target is not set or connection fails """ if self._dcom is not None: return s...
Get or establish a DCOM connection to the certificate authority. Returns: Active DCOM connection Raises: Exception: If target is not set or connection fails
dcom
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def retrieve(self, request_id: int) -> Optional[x509.Certificate]: """ Retrieve a certificate by request ID via DCOM. Args: request_id: The request ID to retrieve Returns: Certificate object if successful, None on failure """ # Prepare empty blob...
Retrieve a certificate by request ID via DCOM. Args: request_id: The request ID to retrieve Returns: Certificate object if successful, None on failure
retrieve
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def __init__(self, parent: "Request"): """ Initialize the RPC request interface. Args: parent: The parent Request object """ self.parent = parent self._dce = None
Initialize the RPC request interface. Args: parent: The parent Request object
__init__
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def dce(self) -> Optional[rpcrt.DCERPC_v5]: """ Get or establish an RPC connection to the certificate authority. Returns: Active RPC connection Raises: Exception: If target is not set or connection fails """ if self._dce is not None: ...
Get or establish an RPC connection to the certificate authority. Returns: Active RPC connection Raises: Exception: If target is not set or connection fails
dce
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def dce_request(self, request: NDRCALL) -> Dict[str, Any]: """ Send a DCE RPC request and handle the response. This wrapper method properly handles the DCE RPC request to ensure static code analysis tools correctly understand the return value. The underlying impacket.dcerpc.v5.r...
Send a DCE RPC request and handle the response. This wrapper method properly handles the DCE RPC request to ensure static code analysis tools correctly understand the return value. The underlying impacket.dcerpc.v5.rpcrt.DCERPC_v5.request method has type annotation issues that ...
dce_request
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def retrieve(self, request_id: int) -> Optional[x509.Certificate]: """ Retrieve a certificate by request ID via RPC. Args: request_id: The request ID to retrieve Returns: Certificate object if successful, False on failure """ # Prepare empty blob...
Retrieve a certificate by request ID via RPC. Args: request_id: The request ID to retrieve Returns: Certificate object if successful, False on failure
retrieve
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def __init__(self, parent: "Request"): """ Initialize the Web Enrollment request interface. Args: parent: The parent Request object """ self.parent = parent self.target = self.parent.target self._session = None self.base_url = ""
Initialize the Web Enrollment request interface. Args: parent: The parent Request object
__init__
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def session(self) -> Optional[httpx.Client]: """ Get or establish an HTTP session to the certificate authority. Returns: Active HTTP session, or None if connection failed Raises: Exception: If target is not set or connection fails """ if self._se...
Get or establish an HTTP session to the certificate authority. Returns: Active HTTP session, or None if connection failed Raises: Exception: If target is not set or connection fails
session
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def _try_connection(self, session: httpx.Client) -> bool: """ Try to connect to the Web Enrollment interface. Args: session: HTTP session to use base_url: Base URL to connect to Returns: True if connection was successful, False otherwise """ ...
Try to connect to the Web Enrollment interface. Args: session: HTTP session to use base_url: Base URL to connect to Returns: True if connection was successful, False otherwise
_try_connection
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def retrieve(self, request_id: int) -> Optional[x509.Certificate]: """ Retrieve a certificate by request ID via Web Enrollment. Args: request_id: The request ID to retrieve Returns: Certificate object if successful, None on failure """ if self.se...
Retrieve a certificate by request ID via Web Enrollment. Args: request_id: The request ID to retrieve Returns: Certificate object if successful, None on failure
retrieve
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def __init__( self, target: Target, ca: Optional[str] = None, template: str = "User", upn: Optional[str] = None, dns: Optional[str] = None, sid: Optional[str] = None, subject: Optional[str] = None, application_policies: Optional[List[str]] = None, ...
Initialize a certificate request object. Args: target: Target information including host and authentication ca: Certificate Authority name template: Certificate template name upn: Alternative UPN (User Principal Name) dns: Alternative DNS nam...
__init__
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def interface(self) -> RequestInterface: """ Get the appropriate request interface based on configuration. Returns: Configured request interface instance """ if self._interface is not None: return self._interface # Select interface based on confi...
Get the appropriate request interface based on configuration. Returns: Configured request interface instance
interface
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def retrieve(self) -> bool: """ Retrieve a certificate by request ID. Returns: True if successful, False otherwise """ if self.request_id is None: logging.error("No request ID specified") return False request_id = int(self.request_id)...
Retrieve a certificate by request ID. Returns: True if successful, False otherwise
retrieve
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def request(self) -> Union[bool, Tuple[bytes, str]]: """ Request a new certificate from AD CS. Returns: PFX data and filename if successful, False otherwise """ # Determine username for certificate username = self.target.username # Validate request o...
Request a new certificate from AD CS. Returns: PFX data and filename if successful, False otherwise
request
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def get_cax(self) -> Union[bool, bytes]: """ Retrieve the CAX (Exchange) certificate. Returns: CAX certificate in DER format if successful, False otherwise """ ca = CA(self.target, self.ca) logging.info("Trying to retrieve CAX certificate") cax_cert =...
Retrieve the CAX (Exchange) certificate. Returns: CAX certificate in DER format if successful, False otherwise
get_cax
python
ly4k/Certipy
certipy/lib/req.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/req.py
MIT
def get_dcom_connection(target: Target) -> DCOMConnection: """ Establish a DCOM connection to the target. Args: target: Target object containing connection parameters Returns: DCOMConnection object for the target Notes: Uses Kerberos authentication if target.do_kerberos is...
Establish a DCOM connection to the target. Args: target: Target object containing connection parameters Returns: DCOMConnection object for the target Notes: Uses Kerberos authentication if target.do_kerberos is True
get_dcom_connection
python
ly4k/Certipy
certipy/lib/rpc.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/rpc.py
MIT
def get_dce_rpc_from_string_binding( string_binding: str, target: Target, timeout: int = 5, target_ip: Optional[str] = None, remote_name: Optional[str] = None, auth_level: int = rpcrt.RPC_C_AUTHN_LEVEL_PKT_PRIVACY, ) -> rpcrt.DCERPC_v5: """ Create a DCE RPC connection from a string bindi...
Create a DCE RPC connection from a string binding. Args: string_binding: The RPC string binding (e.g., "ncacn_np:server[pipe]") target: Target object containing authentication parameters timeout: Connection timeout in seconds target_ip: Override target IP address (uses target.t...
get_dce_rpc_from_string_binding
python
ly4k/Certipy
certipy/lib/rpc.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/rpc.py
MIT
def get_dynamic_endpoint( interface: bytes, target: str, timeout: int = 5 ) -> Optional[str]: """ Resolve a dynamic endpoint for an RPC interface. Args: interface: RPC interface identifier (UUID) target: Target hostname or IP address timeout: Connection timeout in seconds R...
Resolve a dynamic endpoint for an RPC interface. Args: interface: RPC interface identifier (UUID) target: Target hostname or IP address timeout: Connection timeout in seconds Returns: Resolved endpoint string or None if resolution fails Notes: Uses the endpoin...
get_dynamic_endpoint
python
ly4k/Certipy
certipy/lib/rpc.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/rpc.py
MIT
def get_dce_rpc( interface: bytes, named_pipe: str, target: Target, timeout: int = 5, dynamic: bool = False, auth_level_np: int = rpcrt.RPC_C_AUTHN_LEVEL_PKT_PRIVACY, auth_level_dyn: int = rpcrt.RPC_C_AUTHN_LEVEL_PKT_PRIVACY, ) -> Optional[rpcrt.DCERPC_v5]: """ Get a connected DCE RP...
Get a connected DCE RPC interface. This function attempts to connect to an RPC interface using either named pipes or dynamic endpoints. It will try multiple methods if the first fails. Args: interface: RPC interface identifier (UUID) named_pipe: Named pipe path to connect to t...
get_dce_rpc
python
ly4k/Certipy
certipy/lib/rpc.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/rpc.py
MIT
def _try_binding(string_binding: str, auth_level: int) -> Optional[rpcrt.DCERPC_v5]: """Try to connect to a specific string binding.""" dce = get_dce_rpc_from_string_binding( string_binding, target, timeout, auth_level=auth_level ) logging.debug(f"Trying to connect to endpoi...
Try to connect to a specific string binding.
_try_binding
python
ly4k/Certipy
certipy/lib/rpc.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/rpc.py
MIT
def __init__(self, security_descriptor: bytes): """ Initialize a security descriptor parser. Args: security_descriptor: Binary representation of a security descriptor """ if self.RIGHTS_TYPE is None: raise NotImplementedError("Subclasses must define RIGHT...
Initialize a security descriptor parser. Args: security_descriptor: Binary representation of a security descriptor
__init__
python
ly4k/Certipy
certipy/lib/security.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/security.py
MIT
def _parse_aces(self) -> None: """ Parse the access control entries from the security descriptor. This method extracts both standard rights and extended rights. """ aces = self.sd["Dacl"]["Data"] # TODO: Handle DENIED ACEs for ace in aces: sid = for...
Parse the access control entries from the security descriptor. This method extracts both standard rights and extended rights.
_parse_aces
python
ly4k/Certipy
certipy/lib/security.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/security.py
MIT
def _parse_aces(self) -> None: """ Parse the access control entries from the security descriptor. CA security descriptors have a simpler structure than AD security descriptors. """ aces = self.sd["Dacl"]["Data"] for ace in aces: sid = format_sid(ace["Ace"]["...
Parse the access control entries from the security descriptor. CA security descriptors have a simpler structure than AD security descriptors.
_parse_aces
python
ly4k/Certipy
certipy/lib/security.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/security.py
MIT
def is_admin_sid(sid: str) -> bool: """ Check if a security identifier (SID) belongs to an administrative group. This function identifies built-in administrator accounts and groups by their well-known SIDs. Args: sid: The security identifier to check Returns: True if the SID belon...
Check if a security identifier (SID) belongs to an administrative group. This function identifies built-in administrator accounts and groups by their well-known SIDs. Args: sid: The security identifier to check Returns: True if the SID belongs to an administrative group, False otherw...
is_admin_sid
python
ly4k/Certipy
certipy/lib/security.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/security.py
MIT
def create_authenticated_users_sd() -> ldaptypes.SR_SECURITY_DESCRIPTOR: """ Create a security descriptor for the "Authenticated Users" group. This security descriptor grants the "Authenticated Users" group the right to read the object and its properties. """ sd = ldaptypes.SR_SECURITY_DESCRIPTO...
Create a security descriptor for the "Authenticated Users" group. This security descriptor grants the "Authenticated Users" group the right to read the object and its properties.
create_authenticated_users_sd
python
ly4k/Certipy
certipy/lib/security.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/security.py
MIT
def to_list(self) -> List["IntFlag"]: """ Decompose flag into list of individual flags. Returns: List of individual flag members """ if not self._value_: return [] # Get all individual flags that make up this value return [ fl...
Decompose flag into list of individual flags. Returns: List of individual flag members
to_list
python
ly4k/Certipy
certipy/lib/structs.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/structs.py
MIT
def to_str_list(self) -> List[str]: """ Return list of flag names. Returns: List of flag names """ return [ to_pascal_case(flag.name) for flag in self.to_list() if flag.name is not None ]
Return list of flag names. Returns: List of flag names
to_str_list
python
ly4k/Certipy
certipy/lib/structs.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/structs.py
MIT
def __str__(self) -> str: """ Smart string representation that handles combinations gracefully. Returns: Human-readable string representation of the flag(s) """ # Handle named values if self.name is not None: return to_pascal_case(self.name) ...
Smart string representation that handles combinations gracefully. Returns: Human-readable string representation of the flag(s)
__str__
python
ly4k/Certipy
certipy/lib/structs.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/structs.py
MIT
def to_list(self) -> List["Flag"]: """ Decompose flag into list of individual flags. Returns: List of individual flag members """ if not self._value_: return [] # Get all individual flags that make up this value return [ flag ...
Decompose flag into list of individual flags. Returns: List of individual flag members
to_list
python
ly4k/Certipy
certipy/lib/structs.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/structs.py
MIT
def to_str_list(self) -> List[str]: """ Return list of flag names. Returns: List of flag names """ return [ to_pascal_case(flag.name) for flag in self.to_list() if flag.name is not None ]
Return list of flag names. Returns: List of flag names
to_str_list
python
ly4k/Certipy
certipy/lib/structs.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/structs.py
MIT
def __str__(self) -> str: """ Smart string representation that handles combinations gracefully. Returns: Human-readable string representation of the flag(s) """ # Handle named values if self.name is not None: return to_pascal_case(self.name) ...
Smart string representation that handles combinations gracefully. Returns: Human-readable string representation of the flag(s)
__str__
python
ly4k/Certipy
certipy/lib/structs.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/structs.py
MIT
def __init__( self, resolver: "DnsResolver", domain: str = "", username: str = "", password: Optional[str] = None, remote_name: str = "", hashes: Optional[str] = None, lmhash: str = "", nthash: str = "", do_kerberos: bool = False, d...
Initialize a Target with the specified connection parameters. Args: resolver: DNS resolver for hostname resolution domain: Domain name (empty string if not specified) username: Username (empty string if not specified) password: Password (None if not spec...
__init__
python
ly4k/Certipy
certipy/lib/target.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/target.py
MIT
def from_options( options: argparse.Namespace, dc_as_target: bool = False, require_username: bool = True, ) -> "Target": """ Create a Target from command line options. Args: options: Command line options dc_as_target: Whether to use DC as targ...
Create a Target from command line options. Args: options: Command line options dc_as_target: Whether to use DC as target Returns: Target: Configured target object Raises: Exception: If no target can be determined
from_options
python
ly4k/Certipy
certipy/lib/target.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/target.py
MIT
def __init__(self) -> None: """Initialize a new DNS resolver with default settings.""" self.resolver: Resolver = Resolver() self.use_tcp: bool = False self.mappings: Dict[str, str] = {}
Initialize a new DNS resolver with default settings.
__init__
python
ly4k/Certipy
certipy/lib/target.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/target.py
MIT
def from_options(options: argparse.Namespace, target: "Target") -> "DnsResolver": """ Create a DnsResolver from command line options. Args: options: The command line options target: The Target object Returns: DnsResolver: A configured DNS resolver ...
Create a DnsResolver from command line options. Args: options: The command line options target: The Target object Returns: DnsResolver: A configured DNS resolver
from_options
python
ly4k/Certipy
certipy/lib/target.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/target.py
MIT
def create( ns: Optional[str] = None, dc_ip: Optional[str] = None, dns_tcp: bool = False, ) -> "DnsResolver": """ Create a DnsResolver with specified parameters. Args: target: Target object which may contain DC IP information ns: Nameserver to...
Create a DnsResolver with specified parameters. Args: target: Target object which may contain DC IP information ns: Nameserver to use dns_tcp: Whether to use TCP for DNS queries Returns: DnsResolver: A configured DNS resolver
create
python
ly4k/Certipy
certipy/lib/target.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/target.py
MIT
def resolve(self, hostname: str) -> str: """ Resolve hostname to IP address using DNS or local resolution. Uses cache for previously resolved hostnames. Args: hostname: The hostname to resolve Returns: str: The resolved IP address or the original hostnam...
Resolve hostname to IP address using DNS or local resolution. Uses cache for previously resolved hostnames. Args: hostname: The hostname to resolve Returns: str: The resolved IP address or the original hostname if resolution fails
resolve
python
ly4k/Certipy
certipy/lib/target.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/target.py
MIT
def is_ip(hostname: Optional[str]) -> bool: """ Check if the given hostname is an IP address. Args: hostname: The hostname to check Returns: bool: True if the hostname is an IP address, False otherwise """ if hostname is None: return False try: _ = socket.i...
Check if the given hostname is an IP address. Args: hostname: The hostname to check Returns: bool: True if the hostname is an IP address, False otherwise
is_ip
python
ly4k/Certipy
certipy/lib/target.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/target.py
MIT
def get_kerberos_principal() -> Optional[Tuple[str, str]]: """ Get Kerberos principal information from the KRB5CCNAME environment variable. Returns: Tuple containing (username, domain) or None if not available """ krb5ccname = os.getenv("KRB5CCNAME") if krb5ccname is None: loggi...
Get Kerberos principal information from the KRB5CCNAME environment variable. Returns: Tuple containing (username, domain) or None if not available
get_kerberos_principal
python
ly4k/Certipy
certipy/lib/target.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/target.py
MIT
def filetime_to_span(filetime: bytes) -> int: """ Convert Windows FILETIME to time span in seconds. Windows FILETIME is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 UTC. When used for validity periods, negative values represent time remaining. Args: ...
Convert Windows FILETIME to time span in seconds. Windows FILETIME is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 UTC. When used for validity periods, negative values represent time remaining. Args: filetime: Windows FILETIME as 8 bytes Re...
filetime_to_span
python
ly4k/Certipy
certipy/lib/time.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/time.py
MIT
def span_to_filetime(span: int) -> bytes: """ Convert a time span in seconds to Windows FILETIME format. This function converts the time span to a 64-bit integer representing the number of 100-nanosecond intervals since January 1, 1601 UTC. Args: span: Time span in seconds (positive intege...
Convert a time span in seconds to Windows FILETIME format. This function converts the time span to a 64-bit integer representing the number of 100-nanosecond intervals since January 1, 1601 UTC. Args: span: Time span in seconds (positive integer) Returns: Windows FILETIME as 8 by...
span_to_filetime
python
ly4k/Certipy
certipy/lib/time.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/time.py
MIT
def span_to_str(span: int) -> str: """ Convert a time span in seconds to a human-readable string. The function converts the span to the largest appropriate unit (years, months, weeks, days, or hours) for readability. Args: span: Time span in seconds (positive integer) Returns: ...
Convert a time span in seconds to a human-readable string. The function converts the span to the largest appropriate unit (years, months, weeks, days, or hours) for readability. Args: span: Time span in seconds (positive integer) Returns: Human-readable time span (e.g., "1 year",...
span_to_str
python
ly4k/Certipy
certipy/lib/time.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/time.py
MIT
def filetime_to_str(filetime: bytes) -> str: """ Convert Windows FILETIME to a human-readable time span string. This is a convenience function that combines filetime_to_span() and span_to_str() operations. Args: filetime: Windows FILETIME as bytes Returns: Human-readable time ...
Convert Windows FILETIME to a human-readable time span string. This is a convenience function that combines filetime_to_span() and span_to_str() operations. Args: filetime: Windows FILETIME as bytes Returns: Human-readable time span string Example: >>> filetime_bytes...
filetime_to_str
python
ly4k/Certipy
certipy/lib/time.py
https://github.com/ly4k/Certipy/blob/master/certipy/lib/time.py
MIT
def __init__(self, serial: str, adb: ADBWrapper): """Initialize device. Args: serial: Device serial number adb: ADB wrapper instance """ self._serial = serial self._adb = adb self._properties_cache: Dict[str, str] = {}
Initialize device. Args: serial: Device serial number adb: ADB wrapper instance
__init__
python
droidrun/droidrun
droidrun/adb/device.py
https://github.com/droidrun/droidrun/blob/master/droidrun/adb/device.py
MIT
async def tap(self, x: int, y: int) -> None: """Tap at coordinates. Args: x: X coordinate y: Y coordinate """ await self._adb.shell(self._serial, f"input tap {x} {y}")
Tap at coordinates. Args: x: X coordinate y: Y coordinate
tap
python
droidrun/droidrun
droidrun/adb/device.py
https://github.com/droidrun/droidrun/blob/master/droidrun/adb/device.py
MIT
async def swipe( self, start_x: int, start_y: int, end_x: int, end_y: int, duration_ms: int = 300 ) -> None: """Perform swipe gesture. Args: start_x: Starting X coordinate start_y: Starting Y coordinate end_...
Perform swipe gesture. Args: start_x: Starting X coordinate start_y: Starting Y coordinate end_x: Ending X coordinate end_y: Ending Y coordinate duration_ms: Swipe duration in milliseconds
swipe
python
droidrun/droidrun
droidrun/adb/device.py
https://github.com/droidrun/droidrun/blob/master/droidrun/adb/device.py
MIT