CasperSecurity

Current Path : /lib/python3/dist-packages/certbot/plugins/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/certbot/plugins/__pycache__/dns_common.cpython-310.pyc

o

6��a�1�@s�dZddlZddlZddlmZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlm
Z
dd	lmZdd
lmZddlmZe�e�ZGdd
�d
eje
jejd�ZGdd�d�Zdd�Zdd�Zdd�ZdS)z*Common code for DNS Authenticator Plugins.�N)�sleep)�
challenges)�errors)�
interfaces)�
filesystem)�os)�ops)�util)�commoncs�eZdZdZ�fdd�Zed&dd��Zdd�Zd	d
�Zdd�Z	d
e
fdd�Zdd�Zdd�Z
ejdd��Zejdd��Zejdd��Zdd�Zd'dd�Z		d(	d)d d!�Zed"d#��Zed'd$d%��Z�ZS)*�DNSAuthenticatorz!Base class for DNS Authenticatorscst��||�d|_dS)NF)�super�__init__�_attempt_cleanup)�self�config�name��	__class__��</usr/lib/python3/dist-packages/certbot/plugins/dns_common.pyr
s
zDNSAuthenticator.__init__�
cCs|d|tdd�dS)N�propagation-secondszjThe number of seconds to wait for DNS to propagate before asking the ACME server to verify the DNS record.)�default�type�help)�int)�cls�add�default_propagation_secondsrrr�add_parser_argumentss

�z%DNSAuthenticator.add_parser_argumentscCs,|�d�}dj|j||dkrdd�Sdd�S)z,See certbot.plugins.common.Plugin.auth_hint.rz�The Certificate Authority failed to verify the DNS TXT records created by --{name}. Ensure the above domains are hosted by this DNS provider, or try increasing --{name}-propagation-seconds (currently {secs} second{suffix}).��s�)r�secs�suffix)�conf�formatr)r�failed_achalls�delayrrr�	auth_hint%s
����zDNSAuthenticator.auth_hintcCstjgS�N)r�DNS01)r�
unused_domainrrr�get_chall_pref/szDNSAuthenticator.get_chall_prefcCsdSr*r�rrrr�prepare2szDNSAuthenticator.prepare�returncC�t��r*��NotImplementedErrorr.rrr�	more_info5szDNSAuthenticator.more_infocCs~|��d|_g}|D] }|j}|�|�}|�|j�}|�|||�|�|�|j��qt	�
d|�d��t|�d��|S)NTz/Waiting %d seconds for DNS changes to propagater)
�_setup_credentialsr�domain�validation_domain_name�
validation�account_key�_perform�append�response�display_util�notifyr%r)r�achalls�	responses�achallr6r7r8rrr�perform8s
�zDNSAuthenticator.performcCsB|jr|D]}|j}|�|�}|�|j�}|�|||�qdSdSr*)rr6r7r8r9�_cleanup)rr?rAr6r7r8rrr�cleanupOs
�zDNSAuthenticator.cleanupcCr1)z@
        Establish credentials, prompting if necessary.
        r2r.rrrr5Xsz#DNSAuthenticator._setup_credentialscCr1)aX
        Performs a dns-01 challenge by creating a DNS TXT record.

        :param str domain: The domain being validated.
        :param str validation_domain_name: The validation record domain name.
        :param str validation: The validation record content.
        :raises errors.PluginError: If the challenge cannot be performed
        r2�rr6�validation_namer8rrrr:_s
zDNSAuthenticator._performcCr1)aX
        Deletes the DNS TXT record which would have been created by `_perform_achall`.

        Fails gracefully if no such record exists.

        :param str domain: The domain being validated.
        :param str validation_domain_name: The validation record domain name.
        :param str validation: The validation record content.
        r2rErrrrCkszDNSAuthenticator._cleanupcCs4|�|�}|s|�|�}t|j|�|�|�dSdS)a
        Ensure that a configuration value is available.

        If necessary, prompts the user and stores the result.

        :param str key: The configuration key.
        :param str label: The user-friendly label for this piece of information.
        N)r%�_prompt_for_data�setattrr�dest)r�key�label�configured_value�	new_valuerrr�
_configurexs



�zDNSAuthenticator._configureNcCsF|�|�}|s!|�||�}t|j|�|�tj�tj�|���dSdS)a
        Ensure that a configuration value is available for a path.

        If necessary, prompts the user and stores the result.

        :param str key: The configuration key.
        :param str label: The user-friendly label for this piece of information.
        N)	r%�_prompt_for_filerHrrIr�path�abspath�
expanduser)rrJrK�	validatorrLrMrrr�_configure_file�s


(�z DNSAuthenticator._configure_file�CredentialsConfigurationcsN���fdd�}��|||�t��|��j�}�r|����r%�|�|S)a�
        As `_configure_file`, but for a credential configuration file.

        If necessary, prompts the user and stores the result.

        Always stores absolute paths to avoid issues during renewal.

        :param str key: The configuration key.
        :param str label: The user-friendly label for this piece of information.
        :param dict required_variables: Map of variable which must be present to error to display.
        :param callable validator: A method which will be called to validate the
            `CredentialsConfiguration` resulting from the supplied input after it has been validated
            to contain the `required_variables`. Should throw a `~certbot.errors.PluginError` to
            indicate any issue.
        cs.t|�j�}�r
|����r�|�dSdSr*)rUrI�require)�filename�
configuration��required_variablesrrSrr�__validator�s
�z<DNSAuthenticator._configure_credentials.<locals>.__validator)rTrUr%rIrV)rrJrKrZrS�_DNSAuthenticator__validator�credentials_configurationrrYr�_configure_credentials�s	
z'DNSAuthenticator._configure_credentialscsD�fdd�}tj|d���dd�\}}|tjkr|St�d�����)z�
        Prompt the user for a piece of information.

        :param str label: The user-friendly label for this piece of information.
        :returns: The user's response (guaranteed non-empty).
        :rtype: str
        cs|s
t�d�����dS)NzPlease enter your {0}.)r�PluginErrorr&)�i�rKrrr[�s�z6DNSAuthenticator._prompt_for_data.<locals>.__validatorzInput your {0}T��force_interactive�{0} required to proceed.)r�validated_inputr&r=�OKrr_)rKr\�coder<rrarrG�s

�
z!DNSAuthenticator._prompt_for_datacsF��fdd�}tj|d���dd�\}}|tjkr|St�d�����)a�
        Prompt the user for a path.

        :param str label: The user-friendly label for the file.
        :param callable validator: A method which will be called to validate the supplied input
            after it has been validated to be a non-empty path to an existing file. Should throw a
            `~certbot.errors.PluginError` to indicate any issue.
        :returns: The user's response (guaranteed to exist).
        :rtype: str
        cs<|s
t�d�����tj�|�}t|��r�|�dSdS)Nz&Please enter a valid path to your {0}.)rr_r&rrPrR�
validate_file�rW�rKrSrrr[�s�z6DNSAuthenticator._prompt_for_file.<locals>.__validatorzInput the path to your {0}Trbrd)r�validated_directoryr&r=rfrr_)rKrSr\rgr<rrjrrO�s

�
z!DNSAuthenticator._prompt_for_file)rr*)NN)r0rU)�__name__�
__module__�__qualname__�__doc__r
�classmethodrr)r-r/�strr4rBrD�abc�abstractmethodr5r:rCrNrTr^�staticmethodrGrO�
__classcell__rrrrrs8
	



�
�&
r)�	metaclassc@s@eZdZdZdd�fdd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rUz>Represents a user-supplied filed which stores API credentials.cCs|Sr*r)�xrrr�<lambda>�sz!CredentialsConfiguration.<lambda>c
Cs^t|�zt�|�|_Wntjy)}ztjd|dd�t�d�	|���d}~ww||_
dS)z�
        :param str filename: A path to the configuration file.
        :param callable mapper: A transformation to apply to configuration key names
        :raises errors.PluginError: If the file does not exist or is not a valid format.
        z+Error parsing credentials configuration: %sT)�exc_infoz,Error parsing credentials configuration: {0}N)�validate_file_permissions�	configobj�	ConfigObj�confobj�ConfigObjError�logger�debugrr_r&�mapper)rrWr��errrr
�s��
z!CredentialsConfiguration.__init__c	Cs�g}|D])}|�|�s|�d�|�|�||��q|�|�s-|�d�|�|�||��q|rGt�d�t|�dkr<dnd|jj	d�
|����dS)	z�Ensures that the supplied set of variables are all present in the file.

        :param dict required_variables: Map of variable which must be present to error to display.
        :raises errors.PluginError: If one or more are missing.
        z)Property "{0}" not found (should be {1}).z'Property "{0}" not set (should be {1}).z9Missing {0} in credentials configuration file {1}:
 * {2}r �property�
propertiesz
 * N)�_hasr;r&r��_getrr_�lenr}rW�join)rrZ�messages�varrrrrV
s(
�
�����z CredentialsConfiguration.requirecCs
|�|�S)z�Find a configuration value for variable `var`, as transformed by `mapper`.

        :param str var: The variable to get.
        :returns: The value of the variable.
        :rtype: str
        )r��rr�rrrr%#s
zCredentialsConfiguration.confcCs|�|�|jvSr*)r�r}r�rrrr�-szCredentialsConfiguration._hascCs|j�|�|��Sr*)r}�getr�r�rrrr�0szCredentialsConfiguration._getN)	rlrmrnror
rVr%r�r�rrrrrU�s
rUcCs<tj�|�st�d�|���tj�|�rt�d�|���dS)z&Ensure that the specified file exists.zFile not found: {0}zPath is a directory: {0}N)rrP�existsrr_r&�isdirrirrrrh4s
�rhcCs&t|�t�|�rt�d|�dSdS)zHEnsure that the specified file exists and warn about unsafe permissions.z8Unsafe permissions on credentials configuration file: %sN)rhr�has_world_permissionsr�warningrirrrrz>s
�rzcs&|�d���fdd�tdt���D�S)a�Return a list of progressively less-specific domain names.

    One of these will probably be the domain name known to the DNS provider.

    :Example:

    >>> base_domain_name_guesses('foo.bar.baz.example.com')
    ['foo.bar.baz.example.com', 'bar.baz.example.com', 'baz.example.com', 'example.com', 'com']

    :param str domain: The domain for which to return guesses.
    :returns: The a list of less specific domain names.
    :rtype: list
    �.csg|]}d��|d���qS)r�N)r�)�.0r`��	fragmentsrr�
<listcomp>Wsz,base_domain_name_guesses.<locals>.<listcomp>r)�split�ranger�)r6rr�r�base_domain_name_guessesGs
r�)rorr�logging�timerr{�acmer�certbotrr�certbot.compatrr�certbot.displayrr	r=�certbot.pluginsr
�	getLoggerrlr�Plugin�
Authenticator�ABCMetarrUrhrzr�rrrr�<module>s(
c=
	
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY