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/twisted/conch/test/__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/twisted/conch/test/__pycache__/test_channel.cpython-310.pyc
o

�b�/�@s�dZddlmZddlmZz.ddlmZddlmZddl	m
Z
ddlmZddl
mZdd	lmZdd
lmZdZWn
eyIdZeZ
Ynwdd
lmZGdd�de
�Zddd�Zeee�Gdd�de��ZdS)z
Test ssh/channel.py.
�)�skipIf)�verifyObject)�channel)�SSHTransportAddress)�
SSHService)�SSHServerTransport)�
interfaces)�IPv4Address)�StringTransport�zConch SSH not supported.)�TestCasec@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�MockConnectiona�
    A mock for twisted.conch.ssh.connection.SSHConnection.  Record the data
    that channels send, and when they try to close the connection.

    @ivar data: a L{dict} mapping channel id #s to lists of data sent by that
        channel.
    @ivar extData: a L{dict} mapping channel id #s to lists of 2-tuples
        (extended data type, data) sent by that channel.
    @ivar closes: a L{dict} mapping channel id #s to True if that channel sent
        a close message.
    cCsi|_i|_i|_dS)N)�data�extData�closes��self�r�A/usr/lib/python3/dist-packages/twisted/conch/test/test_channel.py�__init__*s
zMockConnection.__init__cCsdS)z,
        Return our logging prefix.
        r
rrrrr�	logPrefix/szMockConnection.logPrefixcCs|j�|g��|�dS)z'
        Record the sent data.
        N)r�
setdefault�append)rrrrrr�sendData5�zMockConnection.sendDatacCs|j�|g��||f�dS)z0
        Record the sent extended data.
        N)rrr)rr�typerrrr�sendExtendedData;szMockConnection.sendExtendedDatacCsd|j|<dS)z?
        Record that the channel sent a close message.
        TN)r)rrrrr�	sendCloseAszMockConnection.sendCloseN)	�__name__�
__module__�__qualname__�__doc__rrrrrrrrrr
sr
NcCs&t�}|�t||d��|�|�dS)a�
    Connect a SSHTransport which is already connected to a remote peer to
    the channel under test.

    @param service: Service used over the connected transport.
    @type service: L{SSHService}

    @param hostAddress: Local address of the connected transport.
    @type hostAddress: L{interfaces.IAddress}

    @param peerAddress: Remote address of the connected transport.
    @type peerAddress: L{interfaces.IAddress}
    )�hostAddress�peerAddressN)r�makeConnectionr
�
setService)�servicer"r#�	transportrrr�connectSSHTransportHs

�r(c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd S)!�ChannelTestsz"
    Tests for L{SSHChannel}.
    cCs&t�|_tj|jdd�|_d|j_dS)z�
        Initialize the channel.  remoteMaxPacket is 10 so that data is able
        to be sent (the default of 0 means no data is sent because no packets
        are made).
        �
)�conn�remoteMaxPacketschannelN)r
r+r�
SSHChannel�namerrrr�setUpcszChannelTests.setUpcCs|�ttj|j��dS)zK
        L{SSHChannel} instances provide L{interfaces.ITransport}.
        N)�
assertTruerr�
ITransportrrrrr�test_interfacemrzChannelTests.test_interfacec	Cstj|jd�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|j|j�|�	|j
�|�	|j�t�ddddd	d
d�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd	�|�|j
d
�|�|jd�dS)
a�
        Test that SSHChannel initializes correctly.  localWindowSize defaults
        to 131072 (2**17) and localMaxPacket to 32768 (2**15) as reasonable
        defaults (what OpenSSH uses for those variables).

        The values in the second set of assertions are meaningless; they serve
        only to verify that the instance variables are assigned in the correct
        order.
        )r+ii�r�������N)rr-r+�assertEqual�localWindowSize�localWindowLeft�localMaxPacket�remoteWindowLeftr,�assertIsNoner�avatar)r�c�c2rrr�	test_initss$
zChannelTests.test_initcCs.|�t|j�d�|�ttjdd��d�dS)z{
        Test that str(SSHChannel) works gives the channel name and local and
        remote windows at a glance..
        z%<SSHChannel channel (lw 131072 rw 0)>r3��localWindowz<SSHChannel None (lw 1 rw 0)>N)r:�strrr-rrrr�test_str�s�zChannelTests.test_strcCs.|�|j��d�|�tjdd���d�dS)z
        Test that bytes(SSHChannel) works, gives the channel name and
        local and remote windows at a glance..

        s%<SSHChannel channel (lw 131072 rw 0)>r3rDs<SSHChannel None (lw 1 rw 0)>N)r:r�	__bytes__r-rrrr�
test_bytes�s
��zChannelTests.test_bytescCs|�|j��d�dS)z�
        Test that SSHChannel.logPrefix gives the name of the channel, the
        local channel ID and the underlying connection.
        z.SSHChannel channel (unknown) on MockConnectionN)r:rrrrrr�test_logPrefix�s
�zChannelTests.test_logPrefixcsdg��fdd�}||j_|j�d�|j�dd�|j�d�|�|jjd�|�|jj�|��d�|�|jj	d	�|�|j
j|jdg�|�|jjg�|�|j
j
|jd
g�d�d<|j�d�|��d�|j�d�|j��|j�d�|��d�d
S)zq
        Test that addWindowBytes adds bytes to the window and resumes writing
        if it was paused.
        Fc�d�d<dS�NTrrr��cbrr�stubStartWriting��z:ChannelTests.test_addWindowBytes.<locals>.stubStartWriting�testr3�2�*r�)r3rQ�sPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaN)r�startWriting�write�
writeExtended�addWindowBytesr:r>r0�
areWriting�bufr+r�extBufr�assertFalse�loseConnection)rrOrrMr�test_addWindowBytes�s(
z ChannelTests.test_addWindowBytescCsLdd�|j_|�|j�dd��|�|j�dd��|�|j�dd��dS)zn
        Test that requestReceived handles requests by dispatching them to
        request_* methods.
        cSs|dkS)NrTr)rrrr�<lambda>�sz3ChannelTests.test_requestReceived.<locals>.<lambda>stest-methodrT�as
bad-methodN)r�request_test_methodr0�requestReceivedr]rrrr�test_requestReceived�sz!ChannelTests.test_requestReceivedcCs*|�|jj�|j��|�|jj�dS)zM
        Test that the default closeReceieved closes the connection.
        N)r]r�closing�
closeReceivedr0rrrr�test_closeReceieved�s
z ChannelTests.test_closeReceievedcs$dg��fdd�}||j_|j�d�|j�d�|�|jj�|��d�|j�d�|j�d�|jj|j}|�	|d	dg�|�	|jj
d
�|j�d�|�	|gd��|�	|jj
d
�d�d<|j�d�|�|jj�|��d�|�	|gd��|�	|jjd�|�	|jj
d�dS)z�
        Test that write handles data correctly.  Send data up to the size
        of the remote window, splitting the data into packets of length
        remoteMaxPacket.
        FcrKrLrrrMrr�stubStopWriting�rPz0ChannelTests.test_write.<locals>.stubStopWriting�drarrU�ta�da��12345678901)rkrj�
1234567890�1r7�123456)rkrjrnro�12345�6N)r�stopWritingrWr]rZr0rYr+rr:r>r[�rrhrrrMr�
test_write�s,zChannelTests.test_writecsBdg��fdd�}||j_|j�dd�|j�dd�|j�dd�|�|jj�|��d	�|j�d
�|j�dd�|jj|j}|�	|gd��|�	|jj
d�|j�d
d�|�	|gd��|�	|jj
d�d�d	<|j�dd�|�|jj�|��d	�|�	|gd��|�	|jjddgg�|�	|jj
d	�dS)z�
        Test that writeExtended handles data correctly.  Send extended data
        up to the size of the window, splitting the extended data into packets
        of length remoteMaxPacket.
        FcrKrLrrrMrrrhrPz8ChannelTests.test_writeExtended.<locals>.stubStopWritingr3rirar4�trrU)�r3rk�r4rv�r4rarlr5rm)rwrxry�r5rn�r5ror7r6rp)rwrxryrzr{)r6rqrrN)rrsrXr]rZr0rYr+rr:r>r\rtrrMr�test_writeExtendeds8��zChannelTests.test_writeExtendedcCsB|j�d�|j�dd�td�D��|�|jj|jdg�dS)zS
        Test that writeSequence is equivalent to write(''.join(sequece)).
        rUcss�|]}d|fVqdS)s%dNr)�.0�irrr�	<genexpr>=s�z2ChannelTests.test_writeSequence.<locals>.<genexpr>r*s
0123456789N)rrY�
writeSequence�ranger:r+rrrrr�test_writeSequence8szChannelTests.test_writeSequencecCs�|j�d�|j�dd�|j��|�|jj�|j��|j�d�|�|jj�|j��|j�d�|�	|jj�|j��dS)zk
        Tesyt that loseConnection() doesn't close the channel until all
        the data is sent.
        sdatar3sdatadatar6�N)
rrWrXr^r?r+r�getrYr0rrrr�test_loseConnection@s
z ChannelTests.test_loseConnectioncC�6tddd�}t|jj|d�|�t|�|j���dS)z�
        L{SSHChannel.getPeer} returns the same object as the underlying
        transport's C{getPeer} method returns.
        �TCPz192.168.0.1i1�)r&r#N)r	r(rr+r:r�getPeer)r�peerrrr�test_getPeerN�zChannelTests.test_getPeercCr�)z�
        L{SSHChannel.getHost} returns the same object as the underlying
        transport's C{getHost} method returns.
        r�z	127.0.0.1i90)r&r"N)r	r(rr+r:r�getHost)r�hostrrr�test_getHostXr�zChannelTests.test_getHostN)rrr r!r/r2rCrGrIrJr_rdrgrur|r�r�r�r�rrrrr)]s"

	
$1
r))NN)r!�unittestr�zope.interface.verifyr�twisted.conch.sshr�twisted.conch.ssh.addressr�twisted.conch.ssh.servicer�twisted.conch.ssh.transportr�twisted.internetr�twisted.internet.addressr	�twisted.test.proto_helpersr
�skipTest�ImportError�object�twisted.trial.unittestrr
r(r)rrrr�<module>s*�
+

Anon7 - 2022
AnonSec Team