CasperSecurity

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

o

6��at�@s�dZddlmZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddl
mZzddlmZdd	lmZmZdd
lmZdZWneyWdZYnwe�e�Zercgd
�ngZd+dd�Zd+dd�Zde de!de!fdd�Z"dddd�Z#dddd�Z$de!de!fdd �Z%d!e!de!fd"d#�Z&	d,d$e!d%e!d&e	e'de
e(e!e!ffd'd(�Z)d,d$e!d%e!d&e	e'de
e!e!ffd)d*�Z*dS)-zk
This compat module handles various platform specific calls that do not fall into one
particular category.
�)�absolute_importN)�Optional)�Tuple)�errors)�os)�shell)�GetStdHandle�STD_OUTPUT_HANDLE)�errorFT)z	/usr/sbinz/usr/local/binz/usr/local/sbin�returncCs"ts
t��dkrt�d��dSdS)z�
    On Windows, raise if current shell does not have the administrative rights.
    Do nothing on Linux.

    :raises .errors.Error: If the current shell does not have administrative rights on Windows.
    rzAError, certbot must be run on a shell with administrative rights.N)�
POSIX_MODE�
shellwin32�
IsUserAnAdminr�Error�rr�5/usr/lib/python3/dist-packages/certbot/compat/misc.py�+raise_for_non_administrative_windows_rights!s
�rcCsZtrdSd}ztt�}|r|�|��|B�WdSWdSty,tjddd�YdSw)zR
    On Windows, ensure that Console Virtual Terminal Sequences are enabled.

    N�zFailed to set console modeT)�exc_info)rrr	�SetConsoleMode�GetConsoleMode�
pywinerror�logger�debug)�"ENABLE_VIRTUAL_TERMINAL_PROCESSING�hrrr�prepare_virtual_console,s��r�timeout�promptcCsZzt�tjggg|�\}}}|st�d�|���|d��WSty,tj��YSw)a(
    Read user input to return the first line entered, or raise after specified timeout.

    :param float timeout: The timeout in seconds given to the user.
    :param str prompt: The prompt message to display to the user.

    :returns: The first line entered by the user.
    :rtype: str

    z,Timed out waiting for answer to prompt '{0}'r)�select�sys�stdinrr�format�readline�OSError)rr�rlist�_rrr�readline_with_timeout@s��r'z
C:\CertbotzC:\Certbot\libzC:\Certbot\log)�config�work�logsz/etc/letsencryptz/var/lib/letsencryptz/var/log/letsencrypt�folder_typecCstjdkr	t|St|S)z�
    Return the relevant default folder for the current OS

    :param str folder_type: The type of folder to retrieve (config, work or logs)

    :returns: The relevant default folder.
    :rtype: str

    �nt)r�name�LINUX_DEFAULT_FOLDERS�WINDOWS_DEFAULT_FOLDERS)r+rrr�get_default_folderis

r0�pathcCs.tjdkr|Stj�|�\}}||�dd�S)z�
    Replace unsupported characters in path for current OS by underscores.
    :param str path: the path to normalize
    :return: the normalized path
    :rtype: str
    r,�:r&)rr-r1�
splitdrive�replace)r1�drive�tailrrr�.underscores_for_unsupported_characters_in_pathzs
r7�cmd_name�	shell_cmd�envc	Csnt�d||�trtj|dtjtjdd|d�}ndd|g}tj|tjtjdd|d�}|j|j}}|j||fS)a;
    Run a command:
        - on Linux command will be run by the standard shell selected with
          subprocess.run(shell=True)
        - on Windows command will be run in a Powershell shell

    This differs from execute_command: it returns the exit code, and does not log the result
    and output of the command.

    :param str cmd_name: the user facing name of the hook being run
    :param str shell_cmd: shell command to execute
    :param dict env: environ to pass into subprocess.run

    :returns: `tuple` (`int` returncode, `str` stderr, `str` stdout)
    zRunning %s command: %sTF)r�stdout�stderr�universal_newlines�checkr:zpowershell.exez-Command)r;r<r=r>r:)	r�infor�
subprocess�run�PIPEr;r<�
returncode)r8r9r:�proc�line�out�errrrr�execute_command_status�s�
�rHcCs~t�dt�t|||�\}}}tj�|�dd�d�}|r%t�	d|||�|dkr1t�
d|||�|r;t�
d|||�||fS)a)
    Run a command:
        - on Linux command will be run by the standard shell selected with
          subprocess.run(shell=True)
        - on Windows command will be run in a Powershell shell

    This differs from execute_command: it returns the exit code, and does not log the result
    and output of the command.

    :param str cmd_name: the user facing name of the hook being run
    :param str shell_cmd: shell command to execute
    :param dict env: environ to pass into subprocess.run

    :returns: `tuple` (`str` stderr, `str` stdout)
    zTexecute_command will be deprecated in the future, use execute_command_status insteadN�rzOutput from %s command %s:
%sz&%s command "%s" returned error code %dz#Error output from %s command %s:
%s)�warnings�warn�PendingDeprecationWarningrHrr1�basename�splitrr?r
)r8r9r:rCrGrF�base_cmdrrr�execute_command�s��rP)rN)N)+�__doc__�
__future__r�loggingrr@r rJ�typingrr�certbotr�certbot.compatr�win32com.shellrr
�win32consolerr	�
pywintypesr
rr�ImportError�	getLogger�__name__r�STANDARD_BINARY_DIRSrr�float�strr'r/r.r0r7�dict�intrHrPrrrr�<module>sR�


����
�,"
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