%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/paramiko/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/paramiko/__pycache__/packet.cpython-312.pyc

�

K�e�X����dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
mZmZmZmZmZddlmZmZddlmZmZddlmZd	�ZGd
�de�Zd�ZGd
�de�Z y)z
Packet handling
�N)�HMAC)�util)�
linefeed_byte�
cr_byte_value�asbytes�	MSG_NAMES�DEBUG�	xffffffff�	zero_byte)�u�byte_ord)�SSHException�ProxyCommandFailure)�Messagec�8�t|||�j�S�N)r�digest)�key�message�digest_classs   �1/usr/lib/python3/dist-packages/paramiko/packet.py�compute_hmacr.s����W�l�+�2�2�4�4�c��eZdZdZy)�NeedRekeyExceptionz1
    Exception indicating a rekey is needed.
    N)�__name__�
__module__�__qualname__�__doc__�rrrr2s���	rrc��d}t|j�tur't|j�dkDr|jd}|S�Nr)�type�args�tuple�len)�e�args  r�	first_argr):s7��
�C��A�F�F�|�u���Q�V�V��q���f�f�Q�i���Jrc�"�eZdZdZedd�Zedd�Zedd�Zedd�Zd�Z	e
d��Zd�Zd�Z
d�Z		d#d	�Z	d$d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd$d�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d �Z&d!�Z'y")%�
Packetizerz9
    Implementation of the base SSH packet protocol.
    ��c��||_d|_d|_d|_d|_d|_t
�|_d|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_t
�|_t
�|_d|_d|_d|_d|_d|_d|_tAjB�|_"d|_#tIjH�|_%d|_&d|_'d|_(d|_)y)NFr�)*�_Packetizer__socket�_Packetizer__logger�_Packetizer__closed�_Packetizer__dump_packets�_Packetizer__need_rekey�_Packetizer__init_count�bytes�_Packetizer__remainder�_initial_kex_done�_Packetizer__sent_bytes�_Packetizer__sent_packets�_Packetizer__received_bytes�_Packetizer__received_packets�$_Packetizer__received_bytes_overflow�&_Packetizer__received_packets_overflow�_Packetizer__block_size_out�_Packetizer__block_size_in�_Packetizer__mac_size_out�_Packetizer__mac_size_in�_Packetizer__block_engine_out�_Packetizer__block_engine_in�_Packetizer__sdctr_out�_Packetizer__mac_engine_out�_Packetizer__mac_engine_in�_Packetizer__mac_key_out�_Packetizer__mac_key_in� _Packetizer__compress_engine_out�_Packetizer__compress_engine_in� _Packetizer__sequence_number_out�_Packetizer__sequence_number_in�_Packetizer__etm_out�_Packetizer__etm_in�	threading�RLock�_Packetizer__write_lock�_Packetizer__keepalive_interval�time�_Packetizer__keepalive_last�_Packetizer__keepalive_callback�_Packetizer__timer�_Packetizer__handshake_complete�_Packetizer__timer_expired)�self�sockets  r�__init__zPacketizer.__init__QsG����
���
���
�#���!������ �7���!&��������� !���"#���)*��&�+,��(�!"��� ���������"&���!%��� ��� $���#���"�W���!�G���%)��"�$(��!�%&��"�$%��!������
�&�O�O�-���%&��!� $�	�	����$(��!����$)��!�$��rc��|jSr)r2�rZs r�closedzPacketizer.closed�s���}�}�rc��d|_yr")rLr^s r�reset_seqno_outzPacketizer.reset_seqno_out�s
��%&��"rc��d|_yr")rMr^s r�reset_seqno_inzPacketizer.reset_seqno_in�s
��$%��!rc��||_y)z?
        Set the Python log object to use for logging.
        N)r1)rZ�logs  r�set_logzPacketizer.set_log�s����
rc���||_||_||_||_||_||_d|_d|_||_|xjdzc_	|jdk(rd|_	d|_
yy)zd
        Switch outbound data cipher.
        :param etm: Set encrypt-then-mac from OpenSSH
        r��FN)rCrEr?rFrArHr9r:rNr5r4)rZ�block_engine�
block_size�
mac_engine�mac_size�mac_key�sdctr�etms        r�set_outbound_cipherzPacketizer.set_outbound_cipher�s���#/��� ��� *��� *���&���$������������	
���Q�������!� !�D�� %�D��"rc��||_||_||_||_||_d|_d|_d|_d|_||_	|xjdzc_
|jdk(rd|_
d|_yy)zc
        Switch inbound data cipher.
        :param etm: Set encrypt-then-mac from OpenSSH
        rr,riFN)rDr@rGrBrIr;r<r=r>rOr5r4)rZrjrkrlrmrnrps       r�set_inbound_cipherzPacketizer.set_inbound_cipher�s���".���)���)���%���#��� !���"#���)*��&�+,��(���
�	
���Q�������!� !�D�� %�D��"rc��||_yr)rJ�rZ�
compressors  r�set_outbound_compressorz"Packetizer.set_outbound_compressor�s
��%/��"rc��||_yr)rKrus  r�set_inbound_compressorz!Packetizer.set_inbound_compressor�s
��$.��!rc�F�d|_|jj�y�NT)r2r0�closer^s rr|zPacketizer.close�s����
��
�
���rc��||_yr�r3)rZ�hexdumps  r�set_hexdumpzPacketizer.set_hexdump�s
��%��rc��|jSrr~r^s r�get_hexdumpzPacketizer.get_hexdump�����"�"�"rc��|jSr)rBr^s r�get_mac_size_inzPacketizer.get_mac_size_in�s���!�!�!rc��|jSr)rAr^s r�get_mac_size_outzPacketizer.get_mac_size_out�r�rc��|jS)z�
        Returns ``True`` if a new set of keys needs to be negotiated.  This
        will be triggered during a packet read or write, so it should be
        checked after every read or write, or at least after every few.
        �r4r^s r�
need_rekeyzPacketizer.need_rekey�s��� � � rc�R�||_||_tj�|_y)z�
        Turn on/off the callback keepalive.  If ``interval`` seconds pass with
        no data read from or written to the socket, the callback will be
        executed and the timer will be reset.
        N)rSrVrTrU)rZ�interval�callbacks   r�
set_keepalivezPacketizer.set_keepalive�s"��%-��!�$,��!� $�	�	���rc��d|_yr{)rYr^s r�
read_timerzPacketizer.read_timer�s
��#��rc��|jsItjt|�|j�|_|jj�yy)z�
        Tells `Packetizer` that the handshake process started.
        Starts a book keeping timer that can signal a timeout in the
        handshake process.

        :param float timeout: amount of seconds to wait before timing out
        N)rWrP�Timer�floatr��start)rZ�timeouts  r�start_handshakezPacketizer.start_handshake�s:���|�|�$�?�?�5��>�4�?�?�K�D�L��L�L��� �rc�N�|jsy|jry|jS)aR
        Checks if the handshake has timed out.

        If `start_handshake` wasn't called before the call to this function,
        the return value will always be `False`. If the handshake completed
        before a timeout was reached, the return value will be `False`

        :return: handshake time out status, as a `bool`
        F)rWrXrYr^s r�handshake_timed_outzPacketizer.handshake_timed_outs&���|�|���$�$���#�#�#rc�n�|jr)|jj�d|_d|_yy)zF
        Tells `Packetizer` that the handshake has completed.
        FTN)rW�cancelrYrXr^s r�complete_handshakezPacketizer.complete_handshakes0���<�<��L�L���!�#(�D� �(,�D�%�rc�(�t�}t|j�dkDr1|jd|}|j|d|_|t|�z}|dkDr�d}|j�r
t	��	|j
j
|�}t|�dk(r
t	��||z
}|t|�z}|rL|jr
t	��|r$t|�dk(r|jr
t!��|j#�|dkDr��|S#tj$rd}Y�mtj$rV}t|�}|tjk(rd}n+|tjk(rn|jr
t	���Yd}~��d}~wwxYw)a&
        Read as close to N bytes as possible, blocking as long as necessary.

        :param int n: number of bytes to read
        :return: the data read, as a `str`

        :raises:
            ``EOFError`` -- if the socket was closed before all the bytes could
            be read
        rNFT)r6r&r7r��EOFErrorr0�recvr[r��errorr)�errno�EAGAIN�EINTRr2r4r�_check_keepalive)rZ�n�check_rekey�out�got_timeout�xr'r(s        r�read_allzPacketizer.read_allsh���g���t��� �1�$��"�"�2�A�&�C�#�/�/���3�D��
��S��M�A��!�e��K��'�'�)��j� �
��M�M�&�&�q�)���q�6�Q�;�"�*�$��q����S��V���"��=�=�"�*�$��C��H��M�t�7H�7H�,�.�.��%�%�'�?�!�e�@�
��-�>�>�
#�"���<�<�

� ��l���%�,�,�&�"&�K��E�K�K�'���]�]�"�*�$����

�s �6AD�F�)F�;AF�Fc�H�tj�|_d}t|�dkDrud}	|jj	|�}|rd}|jrd}ndk(r|dkDrd}|dz
}|dkr
t��|t|�k(r	y||d}t|�dkDr�uy#t
j$rd}Y�ot
j$rC}t|�}|tjk(rd}n|tjk(rd}nd}Yd}~��d}~wt$r�t$rd}Y��wxYw)NrFT����
rh)rTrUr&r0�sendr[r�r�r)r�r�r�r�	Exceptionr2r�)rZr��#iteration_with_zero_as_return_value�retry_writer�r'r(s       r�	write_allzPacketizer.write_allQs(�� $�	�	����./�+��#�h��l��K�
��M�M�&�&�s�+��"����=�=��A���6�A�B�F��A�3�q�8�3��1�u��j� ��C��H�}����a�b�'�C�K�#�h��l�L	��E�>�>�
#�"���<�<�
���l���%�,�,�&�"&�K��E�K�K�'�"&�K��A���&�
���
���
�s#�B � D!�7D!�	9D�D!� D!c��|j}t|vr||j|�z
}t|vr�|jt�}||dzd|_|d|}t	|�dkDr|dt
k(r|dd}t
|�S)z�
        Read a line from the socket.  We assume no data is pending after the
        line, so it's okay to attempt large reads.
        rhNrr�)r7r�
_read_timeout�indexr&rr)rZr��bufr�s    r�readlinezPacketizer.readline|s���
�����3�&��4�%�%�g�.�.�C��3�&��I�I�m�$���q�1�u�w�<����"�1�g����H�q�L�s�2�w�-�7��c�r�(�C���v�
rc��t|�}t|d�}|tvr
t|}ndj|�}t	|�}|j
j
�	|j�|j|�}|j|�}|jrP|jtdj||��|jttj|d��|j�M|jr%|dd|jj!|dd�z}n|jj!|�}n|}|j�dt#j$d|j&�}||jr|n|z}|t)|j*||j,�d|j.z
}|j&dzt0z}	|	dk(r|j2st5d	��|	|_|j7|�|xj8t	|�z
c_|xj:dz
c_|j:|j<k\xs|j8|j>k\}
|
rf|j@sZd
}|jt|j|j:|j8��d|_!d|_"|jG�|j
jI�y#|j
jI�wxYw)zR
        Write a block of data using the current cipher, as an SSH block.
        r�${:x}NzWrite packet <{}>, length {}zOUT: ��>Irh�/Sequence number rolled over during initial kex!z(Rekeying (hit {} packets, {} bytes sent))%rr
r�formatr&rR�acquirerJ�
_build_packetr3�_logr	r�
format_binaryrCrN�update�struct�packrLrrHrFrAr
r8rr�r9r:�
REKEY_PACKETS�REKEY_BYTESr4r=r>�_trigger_rekey�release)rZ�data�cmd�cmd_name�orig_len�packetr��packed�payload�next_seq�
sent_too_much�msgs            r�send_messagezPacketizer.send_message�s���
�t�}���t�A�w����)�� ��~�H��~�~�c�*�H��t�9�����!�!�#�3	(��)�)�5��1�1�$�7���'�'��-�F��"�"��	�	��2�9�9�(�H�M���	�	�%��!3�!3�F�G�!D�E��&�&�2��>�>� ��1�+��(?�(?�(F�(F��q�r�
�)��C��1�1�8�8��@�C����&�&�2����T�4�+E�+E�F�� �4�>�>�C�v�F���|��&�&���1F�1F��'�D�'�'�)�)���2�2�Q�6�)�C�H��1�}�T�%;�%;�"�E���*2�D�&��N�N�3������S��)�����1�$���#�#�t�'9�'9�9�9��$�$��(8�(8�8�
��T�%6�%6�@���	�	��3�:�:�d�&9�&9�4�;L�;L�M��23��.�34��0��#�#�%����%�%�'��D���%�%�'�s
�#I.K,�,Lc	��
�|j|jd��}|jr�tjd|dd�d}||jz
dz}|dd|j|d��z}|j|j
d��}tjd|j|�|z}t|j||j�d|j
}tj||�std	��|}|j�|jj|�}|j r*|j#t$tj&|d
��|jr|}n�tjd|dd�d}|dd}|t)|�z
|jzdk7rtd��|j||j
zt)|�z
�}	|	d|t)|�z
}|	|t)|�z
d}
|j�|jj|�}||z}|j r*|j#t$tj&|d
��|j
dkDr�|js�
d|j
}tjd|j�|z}t|j||j�d|j
}tj||�std	��t+|d�}|d|z
}|j r&|j#t$d
j-||��|j.�|j/|�}t1|dd�}
|j|
_|jdzt4z}|dk(r|j6std��||_||j
zdz}|xj8|z
c_|xj:dz
c_|j<rg|xj>|z
c_|xj@dz
c_ |j@|jBk\s|j>|jDk\r�td��|j:|jFk\s|j8|jHk\rZd}|j#t$|j-|j:|j8��d|_d|_ |jK�t+|d�}|tLvr
tL|}ndj-|�}|j r/|j#t$dj-|t)|���||
fS)z�
        Only one thread should ever be in this function (no other locking is
        done).

        :raises: `.SSHException` -- if the packet is mangled
        :raises: `.NeedRekeyException` -- if the transport should rekey
        T)r�r�Nr�rFz>IIzMismatched MACzIN: zInvalid packet blockingrhz"Got payload ({} bytes, {} padding)r�z+Remote transport is ignoring rekey requestsz,Rekeying (hit {} packets, {} bytes received)r�zRead packet <{}>, length {})'r�r@rOr��unpackrBr�rMrrIrGr�constant_time_bytes_eqrrDr�r3r�r	r�r&r
r�rKr�seqnor
r8r;r<r4r=r>�REKEY_PACKETS_OVERFLOW_MAX�REKEY_BYTES_OVERFLOW_MAXr�r�r�r)rZ�header�packet_size�	remainingr��mac�mac_payload�my_mac�leftoverr��post_packet�paddingr�r�r��raw_packet_size�errr�r�s                   r�read_messagezPacketizer.read_message�s �����t�3�3���F���=�=� �-�-��f�R�a�j�9�!�<�K�#�d�&:�&:�:�Q�>�I��A�B�Z�$�-�-�	�u�-�"M�M�F��-�-�� 2� 2��-�F�C����E�4�#<�#<�k�J���
�"��!�!�;��0D�0D��"��"�"�$�F��.�.�v�s�;�"�#3�4�4��F��!�!�-��+�+�2�2�6�:�F�����I�I�e�T�/�/���?�@��=�=��F�!�-�-��f�R�a�j�9�!�<�K��a�b�z�H��c�(�m�+�t�/C�/C�C�q�H�"�#<�=�=��-�-��d�0�0�0�3�x�=�@��C��6�;��X��6�7�F��k�C��M�9�;�<�K��%�%�1��/�/�6�6�v�>����&�F�����I�I�e�T�/�/���?�@�����!�$�-�-��2�� 2� 2�3�C����E�4�#<�#<�k�J���
�"��!�!�;��0D�0D��"��"�"�$�F��.�.�v�s�;�"�#3�4�4��6�!�9�%����[�7�2�3������I�I��4�;�;����
��$�$�0��/�/��8�G��g�a�b�k�"���-�-��	��-�-��1�Y�>���q�=��!7�!7��A��
�%-��!�&��(:�(:�:�Q�>������0�����1�$�����
�*�*�o�=�*��,�,��1�,��0�0��2�2�3��.�.�$�2O�2O�O�"�A����%�%��);�);�;��!�!�T�%5�%5�5�A�C��I�I���
�
�4�2�2�D�4I�4I�J�
�./�D�*�/0�D�,����!��w�q�z�"���)�� ��~�H��~�~�c�*�H�����I�I��-�4�4�X�s�7�|�L�
��C�x�rc���|j�ytt|�t�r$|D]}|jj	||�� y|jj	||�yr)r1�
issubclassr#�listre)rZ�levelr��ms    rr�zPacketizer._logTsV���=�=� ���d�3�i��&��
,���
�
�!�!�%��+�
,�
�M�M���e�S�)rc���|jr|jr|jrytj�}||j|jzkDr|j�||_yyr)rSrCr4rTrUrV)rZ�nows  rr�zPacketizer._check_keepalive]s`���)�)��*�*�� � �
��i�i�k����&�&��)B�)B�B�B��%�%�'�$'�D�!�Crc��tj�}		|jjd�}t|�dk(r
t	��	|S#t
j$rYn3t$r(}t|�tjk(rn�Yd}~nd}~wwxYw|jr
t	��tj�}||z
|k\rtj����)N�r)rTr0r�r&r�r[r��EnvironmentErrorr)r�r�r2)rZr�r�r�r'r�s      rr�zPacketizer._read_timeoutjs����	�	����
��M�M�&�&�s�+���q�6�Q�;�"�*�$������>�>�
��#�
��Q�<�5�;�;�.�����
��
�}�}��j� ��)�)�+�C��U�{�g�%��n�n�&�&�#s�3A
�
B�"B�*B
�
Bc�>�|j}|jrdnd}d|zt|�|z|zz
}tjdt|�|zdz|�}||z
}|j
s|j�|t|zz
}|S|tj|�z
}|S)Nr�r/riz>IBrh)
r?rNr&r�r�rErCr�os�urandom)rZr��bsize�addlenr�r�s      rr�zPacketizer._build_packet�s����%�%���n�n��!���e�)��G��v� 5��>�?�����U�C��L�7�$:�Q�$>��H���'������t�6�6�>�
�i�'�)�)�F��
�
�b�j�j��)�)�F��
rc��d|_yr{r�r^s rr�zPacketizer._trigger_rekey�s
�� ��rN)FF)F)(rrrr�powr�r�r�r�r\�propertyr_rarcrfrqrsrwryr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r rrr+r+As������2�J�M��a��*�K�"%�Q����"�1�b�z��/%�b����'�&����&�J
�&�<0�/��&�#�"�#�!�,�$�
!�$� -�1�f)�V
�@(�DC�N*�(��,�$!rr+)!rr�r�r[r�rPrT�hmacr�paramikor�paramiko.commonrrrrr	r
r�paramiko.py3compatrr
�paramiko.ssh_exceptionrr�paramiko.messagerrr�rr)�objectr+r rr�<module>r�sb��&�
�	�
�
��������+�D�$�5�	��	��S	!��S	!r

Zerion Mini Shell 1.0