AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/certbot/plugins/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/certbot/plugins/__pycache__/common.cpython-310.pyc
o

6��a >�@sTdZddlmZddlmZddlZddlZddlZddlZddlm	Z	ddl
Z
ddlmZddlm
Z
ddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZe�e�Zdd�Zdd�Z e�!d�Z"e�!dej#�Z$Gdd�deed�ZGdd�deeed�ZGdd�d�Z%Gdd�d�Z&dd �Z'd!d"�Z(dS)#zPlugin common functions.�)�ABCMeta)�abstractmethodN)�List)�achallenges)�crypto_util)�errors)�reverter)�	constants)�
filesystem)�os)�	Installer)�Plugin)�
PluginStoragecCs|dS)�9ArgumentParser options namespace (prefix of all options).�-���namerr�8/usr/lib/python3/dist-packages/certbot/plugins/common.py�option_namespacesrcCs|�dd�dS)�;ArgumentParser dest namespace (prefix of all destinations).r�_)�replacerrrr�dest_namespacesrzX(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)z3^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*[a-z]+$cs�eZdZdZ�fdd�Zeedd���Zedd��Ze	dd	��Z
d
d�Ze	dd
��Zdd�Z
dd�Zdeejdefdd�Z�ZS)r
zGeneric plugin.cst��||�||_||_dS�N)�super�__init__�configr)�selfrr��	__class__rrr.s
zPlugin.__init__cCsdS)z�Add plugin arguments to the CLI argument parser.

        :param callable add: Function that proxies calls to
            `argparse.ArgumentParser.add_argument` prepending options
            with unique plugin name prefix.

        Nr)�cls�addrrr�add_parser_arguments3szPlugin.add_parser_argumentscs��fdd�}|�|�S)zkInject parser options.

        See `~.certbot.interfaces.Plugin.inject_parser_options` for docs.

        cs$�jd�t��|�g|�Ri|��S)Nz--{0}{1})�add_argument�formatr)�arg_name_no_prefix�args�kwargs�r�parserrrr"Fs���z)Plugin.inject_parser_options.<locals>.add)r#)r!r*rr"rr)r�inject_parser_options>s
zPlugin.inject_parser_optionscC�
t|j�S)r)rr�rrrrrL�
zPlugin.option_namespacecCs
|j|S)z'Option name (include plugin namespace).)r)rrrrr�option_nameQ�
zPlugin.option_namecCr,)r)rrr-rrrrUr.zPlugin.dest_namespacecCs|j|�dd�S)z.Find a destination for given variable ``var``.rr)rr�r�varrrr�destZszPlugin.destcCst|j|�|��S)z0Find a configuration value for variable ``var``.)�getattrrr3r1rrr�conf`szPlugin.conf�failed_achalls�returncCs(d�tdd�|D���}dj|j|d�S)a9Human-readable string to help the user troubleshoot the authenticator.

        Shown to the user if one or more of the attempted challenges were not a success.

        Should describe, in simple language, what the authenticator tried to do, what went
        wrong and what the user should try as their "next steps".

        TODO: auth_hint belongs in Authenticator but can't be added until the next major
        version of Certbot. For now, it lives in .Plugin and auth_handler will only call it
        on authenticators that subclass .Plugin. For now, inherit from `.Plugin` to implement
        and/or override the method.

        :param list failed_achalls: List of one or more failed challenges
                                    (:class:`achallenges.AnnotatedChallenge` subclasses).

        :rtype str:
        z and cSsh|]}|j�qSr)�typ)�.0�achallrrr�	<setcomp>xsz#Plugin.auth_hint.<locals>.<setcomp>z�The Certificate Authority couldn't externally verify that the {name} plugin completed the required {challs} challenges. Ensure the plugin is configured correctly and that the changes it makes are accessible from the internet.)r�challs)�join�sortedr%r)rr6r<rrr�	auth_hintds�zPlugin.auth_hint)�__name__�
__module__�__qualname__�__doc__r�classmethodrr#r+�propertyrr/rr3r5rr�AnnotatedChallenge�strr?�
__classcell__rrrrr
+s 	


 r
)�	metaclasscsleZdZdZ�fdd�Zddd�Zdd�Zd	d
�Zdd�Zddd�Z	e
dd��Ze
dd��Zdd�Z
�ZS)rz�An installer base class with reverter and ssl_dhparam methods defined.

    Installer plugins do not have to inherit from this class.

    cs4t�j|i|��t|j|j�|_t�|j�|_dSr)rrrrr�storager�Reverter)rr'r(rrrr�szInstaller.__init__Fc
CsP|r|jj}n|jj}z|||�WdStjy'}zt�t|���d}~ww)a�Add files to a checkpoint.

        :param set save_files: set of filepaths to save
        :param str save_notes: notes about changes during the save
        :param bool temporary: True if the files should be added to a
            temporary checkpoint rather than a permanent one. This is
            usually used for changes that will soon be reverted.

        :raises .errors.PluginError: when unable to add to checkpoint

        N)r�add_to_temp_checkpoint�add_to_checkpointr�
ReverterError�PluginErrorrG)r�
save_files�
save_notes�	temporary�checkpoint_func�errrrrrM�s
��zInstaller.add_to_checkpointc
C�<z	|j�|�WdStjy}zt�t|���d}~ww)z�Timestamp and save changes made through the reverter.

        :param str title: Title describing checkpoint

        :raises .errors.PluginError: when an error occurs

        N)r�finalize_checkpointrrNrOrG)r�titlerTrrrrV�s��zInstaller.finalize_checkpointc
C�:z|j��WdStjy}zt�t|���d}~ww)z�Revert all previously modified files.

        Reverts all modified files that have not been saved as a checkpoint

        :raises .errors.PluginError: If unable to recover the configuration

        N)r�recovery_routinerrNrOrG�rrTrrrrY�s��zInstaller.recovery_routinec
CrX)zkRollback temporary checkpoint.

        :raises .errors.PluginError: when unable to revert config

        N)r�revert_temporary_configrrNrOrGrZrrrr[�s��z!Installer.revert_temporary_config�c
CrU)z�Rollback saved checkpoints.

        :param int rollback: Number of checkpoints to revert

        :raises .errors.PluginError: If there is a problem with the input or
            the function is unable to correctly revert the configuration

        N)r�rollback_checkpointsrrNrOrG)r�rollbackrTrrrr]�s	��zInstaller.rollback_checkpointscC�tj�|jjtj�S)z(Full absolute path to ssl_dhparams file.)r�pathr=r�
config_dirr	�SSL_DHPARAMS_DESTr-rrr�ssl_dhparams��zInstaller.ssl_dhparamscCr_)z:Full absolute path to digest of updated ssl_dhparams file.)rr`r=rrar	�UPDATED_SSL_DHPARAMS_DIGESTr-rrr�updated_ssl_dhparams_digest�rdz%Installer.updated_ssl_dhparams_digestcCst|j|jtjtj�S)zJCopy Certbot's ssl_dhparams file into the system's config dir if required.)�install_version_controlled_filercrfr	�SSL_DHPARAMS_SRC�ALL_SSL_DHPARAMS_HASHESr-rrr�install_ssl_dhparams�s�zInstaller.install_ssl_dhparams�F)r\)r@rArBrCrrMrVrYr[r]rErcrfrjrHrrrrrs




rc@sveZdZdZddd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�Addrz�Represents an virtual host address.

    :param str addr: addr part of vhost address
    :param str port: port number or \*, or ""

    FcCs||_||_dSr)�tup�ipv6)rrmrnrrrr�s
z
Addr.__init__cCs�|�d�r4|�d�}|d|d�}d}t|�|dkr,||ddkr,||dd�}|||fdd	�S|�d�}||d
|df�S)zInitialize Addr from string.�[�]Nr\���:T)rnr)�
startswith�rfind�len�	partition)r!�str_addr�endIndex�host�portrmrrr�
fromstring�s

 
zAddr.fromstringcCs|jdr
d|jS|jdS)Nr\z%s:%sr�rmr-rrr�__str__s


zAddr.__str__cCs|jr|��|jdfS|jS)z5Normalized representation of addr/port tuple
        r\)rn�get_ipv6_explodedrmr-rrr�normalized_tupleszAddr.normalized_tuplecCs t||j�r|��|��kSdS)NF)�
isinstancer r�)r�otherrrr�__eq__szAddr.__eq__cCr,r)�hashrmr-rrr�__hash__s
z
Addr.__hash__cC�
|jdS)z Return addr part of Addr object.rr}r-rrr�get_addrr0z
Addr.get_addrcCr�)zReturn port.r\r}r-rrr�get_portr0z
Addr.get_portcCs|�|jd|f|j�S)z6Return new address object with same addr and new port.r)r rmrn)rr{rrr�get_addr_objszAddr.get_addr_objcCs|�d�}|�d�}|�|�S)z7Return IPv6 address in normalized form, helper functionrorp)�lstrip�rstrip�
_explode_ipv6)r�addrrrr�_normalize_ipv6#s


zAddr._normalize_ipv6cCs |jrd�|�|jd��SdS)zReturn IPv6 in normalized formrsrrq)rnr=r�rmr-rrrr)szAddr.get_ipv6_explodedcCs�gd�}|�d�}t|�t|�kr|dt|��}d}t|�D]'\}}|s(d}qt|�dkr3|�d�}|s<t|�||<qt|�||t|�<q|S)z#Explode IPv6 address for comparison)�0r�r�r�r�r�r�r�rsrFTr\r�)�splitrv�	enumerater�rG)rr��result�	addr_list�
append_to_end�i�blockrrrr�/s

zAddr._explode_ipv6Nrk)r@rArBrCrrDr|r~r�r�r�r�r�r�r�rr�rrrrrl�s

rlc@s*eZdZdZdd�Zd	dd�Zdd�ZdS)
�ChallengePerformeravAbstract base for challenge performers.

    :ivar configurator: Authenticator and installer plugin
    :ivar achalls: Annotated challenges
    :vartype achalls: `list` of `.KeyAuthorizationAnnotatedChallenge`
    :ivar indices: Holds the indices of challenges from a larger array
        so the user of the class doesn't have to.
    :vartype indices: `list` of `int`

    cCs||_g|_g|_dSr)�configurator�achalls�indices)rr�rrrrTs
zChallengePerformer.__init__NcCs(|j�|�|dur|j�|�dSdS)z�Store challenge to be performed when perform() is called.

        :param .KeyAuthorizationAnnotatedChallenge achall: Annotated
            challenge.
        :param int idx: index to challenge in a larger array

        N)r��appendr�)rr:�idxrrr�	add_challYs�zChallengePerformer.add_challcCst��)z�Perform all added challenges.

        :returns: challenge responses
        :rtype: `list` of `acme.challenges.KeyAuthorizationChallengeResponse`


        )�NotImplementedErrorr-rrr�performeszChallengePerformer.performr)r@rArBrCrr�r�rrrrr�Hs

r�cs�t������fdd�����fdd�}tj���s|�dSt���}|�kr*dS||vr3|�dStj���rXt�d��}|��}Wd�n1sMwY|�krXdS��t�d����dS)a�Copy a file into an active location (likely the system's config dir) if required.

       :param str dest_path: destination path for version controlled file
       :param str digest_path: path to save a digest of the file in
       :param str src_path: path to version controlled file found in distribution
       :param list all_hashes: hashes of every released version of the file
    cs:t�d��}|���Wd�dS1swYdS)N�w)�open�write)�f)�current_hash�digest_pathrr�_write_current_hashzs"�z<install_version_controlled_file.<locals>._write_current_hashcst������dSr)�shutil�copyfiler)r��	dest_path�src_pathrr�_install_current_file~s
z>install_version_controlled_file.<locals>._install_current_fileN�rzh%s has been manually modified; updated file saved to %s. We recommend updating %s for security purposes.)	r�	sha256sumrr`�isfiler��read�logger�warning)r�r�r��
all_hashesr��active_file_digestr��saved_digestr)r�r�r�r�r�rrgps*



��rgcCs�dd�}|d�}|d�}|d�}t�|tj�t�|tj�t�|tj�t�|tj�d|��}t	j
|tj�||�dd�|||fS)	z5Setup the directories necessary for the configurator.cSst�t�|��S)a�Return the real path of a temp directory with the specified prefix

        Some plugins rely on real paths of symlinks for working correctly. For
        example, certbot-apache uses real paths of configuration files to tell
        a virtual host from another. On systems where TMP itself is a symbolic
        link, (ex: OS X) such plugins will be confused. This function prevents
        such a case.
        )r
�realpath�tempfile�mkdtemp)�prefixrrr�expanded_tempdir�s	z#dir_setup.<locals>.expanded_tempdir�tempr�work�testdataT)�symlinks)r
�chmodr	�CONFIG_DIRS_MODE�
pkg_resources�resource_filenamerr`r=r��copytree)�test_dir�pkgr��temp_dirra�work_dir�test_configsrrr�	dir_setup�s��
r�))rC�abcrr�logging�rer�r��typingrr��certbotrrrr�certbot._internalr	�certbot.compatr
r�certbot.interfacesr�AbstractInstallerr
�AbstractPlugin�certbot.plugins.storager�	getLoggerr@r�rr�compile�private_ips_regex�
IGNORECASE�hostname_regexrlr�rgr�rrrr�<module>sD
��Tgb(2

Anon7 - 2022
AnonSec Team