HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/paramiko/__pycache__/util.cpython-310.pyc
o

�hN%�@s@dZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZddl
mZd5dd�Zd6d	d
�Zd7dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Ze��adae��ad d!�Z efd"d#�Z!Gd$d%�d%�Z"e"�Z#d&d'�Z$d(d)�Z%Gd*d+�d+�Z&d,d-�Z'd.d/�Z(d8d1d2�Z)d8d3d4�Z*dS)9z0
Useful functions used by the rest of paramiko.
�N)�DEBUG�	zero_byte�	xffffffff�max_byte�byte_ord�byte_chr)�	SSHConfigFc	Cs�d}d}|st|�dkrt|d�dkrd}t|�dr.t}|r"t}|dt|�d|}tdt|�d�D]}|d>t�d|||d��d}q6|rW|ddt|�>8}|S)zTturns a normalized byte string into a long-int
    (adapted from Crypto.Util.number)r���� �>I�)�lenrrr�range�struct�unpack)�s�always_positive�out�negative�filler�i�r�C/usr/local/CyberPanel/lib/python3.10/site-packages/paramiko/util.py�inflate_long)s &rTcCs�t�}t|�}|dkr%|dkr%t�d|t@�|}|dL}|dkr%|dkst|�D]}|dkr7|ddkr7n|dkrC|ddkrCnq)d}|dkrMt}nt}||dd�}|ry|dkrit|d�d	krit|}|dkryt|d�d	kryt|}|S)
zTturns a long-int into a normalized byte string
    (adapted from Crypto.Util.number)r���r
rr
�)rNr	)	�bytes�intr�packr�	enumeraterrr)�n�add_sign_paddingrrrrr�deflate_long>s.��r$�cs~d}g}t|�|dkr%|�t|||d���|d7}t|�|dks|t|�kr6|�t||d����fdd�|D�S)Nr�csg|]}�|�qSrr)�.0�line��prefixrr�
<listcomp>esz!format_binary.<locals>.<listcomp>)r�append�format_binary_line)�datar*�xrrr)r�
format_binary]s�r0cCs4d�dd�|D��}d�dd�|D��}d�||�S)N� cSsg|]	}d�t|���qS)z{:02X}��formatr�r'�crrrr+isz&format_binary_line.<locals>.<listcomp>r%cSs*g|]}d�t|��t|�dd�qS)z.{:c}..�?�_r2r4rrrr+ks*z	{:50s} {})�joinr3)r.�left�rightrrrr-hs
�r-cCsRd}|D]"}t|�}d|krdkrnn|t|�7}q|td�|��7}q|S)N�r�z%{:02X})rr�br3)rrr5rrrr�safe_stringpsr>cCsrz|��WSty8t|d�}t|d�}|dkrYdSt|�d}|d@s4|dK}|d8}|d@r(|YSw)NFrr
rr	)�
bit_length�AttributeErrorr$rr)r"�norm�hbyte�bitlenrrrr?{s

��r?cCsd�tjt�����d�S)Nr%�
)r8�	traceback�format_exception�sys�exc_info�splitrrrr�
tb_strings�srJcCs�t�}t�}t|�dkr|dd�}|dkrK|�}t|�dkr$|�|�|�t|��|�|�|��}t|t|��}||d|�7}||8}|dks|S)a)
    Given a password, passphrase, or other human-source key, scramble it
    through a secure hash into some keyworthy bytes.  This specific algorithm
    is used for encrypting/decrypting private key files.

    :param function hash_alg: A function which creates a new hash object, such
        as ``hashlib.sha256``.
    :param salt: data to salt the hash with.
    :type bytes salt: Hash salt bytes.
    :param str key: human-entered password or passphrase.
    :param int nbytes: number of bytes to generate.
    :return: Key data, as `bytes`.
    rNr)rr�updater=�digest�min)�hash_alg�salt�key�nbytes�keydatarL�hash_obj�sizerrr�generate_key_bytes�s 

�
rUcCsddlm}||�S)a�
    Read a file of known SSH host keys, in the format used by openssh, and
    return a compound dict of ``hostname -> keytype ->`` `PKey
    <paramiko.pkey.PKey>`. The hostname may be an IP address or DNS name.  The
    keytype will be either ``"ssh-rsa"`` or ``"ssh-dss"``.

    This type of file unfortunately doesn't exist on Windows, but on posix,
    it will usually be stored in ``os.path.expanduser("~/.ssh/known_hosts")``.

    Since 1.5.3, this is just a wrapper around `.HostKeys`.

    :param str filename: name of the file to read host keys from
    :return:
        nested dict of `.PKey` objects, indexed by hostname and then keytype
    r)�HostKeys)�paramiko.hostkeysrV)�filenamerVrrr�load_host_keys�srYcCst�}|�|�|S)z�
    Provided only as a backward-compatible wrapper around `.SSHConfig`.

    .. deprecated:: 2.7
        Use `SSHConfig.from_file` instead.
    )r�parse)�file_obj�configrrr�parse_ssh_config�s
r]cCs
|�|�S)zM
    Provided only as a backward-compatible wrapper around `.SSHConfig`.
    )�lookup)�hostnamer\rrr�lookup_ssh_host_config�s
r`c	Cs�dd|}}}dd|}}}|dkr7||}||||}}||||}}||||}}|dks|dkr?||7}|S)Nr
rr)	r/�m�u1�u2�u3�v1�v2�v3�qrrr�mod_inverse�s�ricCsTztjWSty)t�td7att_Wd�n1swYtjYSw)Nr
)�_g_thread_data�idr@�_g_thread_lock�_g_thread_counterrrrr�
get_thread_id�s�
�rncCsft�d�}t|j�dkrdS|�|�t|d�}t�|�}d}|d7}|�t�|d��|�	|�dS)zKsend paramiko logs to a logfile,
    if they're not already going somewhere�paramikorN�az>%(levelname)-.3s [%(asctime)s.%(msecs)03d] thr=%(_threadid)-3dz %(name)s: %(message)sz%Y%m%d-%H:%M:%S)
�logging�	getLoggerr�handlers�setLevel�open�
StreamHandler�setFormatter�	Formatter�
addHandler)rX�level�logger�f�handler�frmrrr�log_to_file�s



rc@seZdZdd�ZdS)�PFiltercCst�|_dS)NT)rn�	_threadid)�self�recordrrr�filterszPFilter.filterN)�__name__�
__module__�__qualname__r�rrrrr�sr�cCst�|�}|�t�|S�N)rqrr�	addFilter�_pfilter)�namer{rrr�
get_logger
s

r�cCsNt|�t|�kr
dSd}tt|��D]}|t||�t||�AO}q|dkS)NFr)rrr)rpr=�resrrrr�constant_time_bytes_eqsr�c@seZdZdd�Zdd�ZdS)�ClosingContextManagercCs|Sr�r)r�rrr�	__enter__szClosingContextManager.__enter__cCs|��dSr�)�close)r��type�valuerErrr�__exit__!szClosingContextManager.__exit__N)r�r�r�r�r�rrrrr�sr�cCst|t||��Sr�)�maxrM)�minimum�val�maximumrrr�clamp_value%sr�cCsDzt|�WSty!z|��WYSty |YYSww)z:
    Coerce to bytes if possible or return unchanged.
    )r=�	TypeError�asbytesr@)rrrrr�)s
��r��utf8cCs4t|t�r|St|t�r|�|�Stdt|�����)zcast unicode or bytes to bytes�Expected unicode or bytes, got )�
isinstancer�str�encoder�r��r�encodingrrrr=?s



r=cCs4t|t�r
|�|�St|t�r|Stdt|�����)z cast bytes or unicode to unicoder�)r�r�decoder�r�r�r�rrr�uJs



r�)F)T)r%)r�)+�__doc__rGrrE�	threadingrq�paramiko.commonrrrrrr�paramiko.configrrr$r0r-r>r?rJrUrYr]r`ri�localrjrm�Lockrlrnrr�r�r�r�r�r�r�r=r�rrrr�<module>sD