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 :  /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 : /lib/python3/dist-packages/twisted/conch/test/__pycache__/test_agent.cpython-310.pyc
o

�b�3�@sxdZddlZddlmZddlmZzddlZWney#dZYnweZzddl	Z
Wney7dZ	Ynwe
Z	z
ddlmZ
mZWn
eyQdZZYnwee
ZZddlmZmZddlmZGdd	�d	�ZGd
d�dej�ZGdd
�d
e�ZGdd�de�Zedur�Gdd�dej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z dS)z'
Tests for L{twisted.conch.ssh.agent}.
�N)�iosim)�unittest)�agent�keys)�
ConchError�MissingKeyStoreError)�keydatac@�eZdZdZdd�ZdS)�StubFactoryzb
    Mock factory that provides the keys attribute required by the
    SSHAgentServerProtocol
    cCs
i|_dS�N)r��self�r�?/usr/lib/python3/dist-packages/twisted/conch/test/test_agent.py�__init__,s
zStubFactory.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrr
&sr
c@s,eZdZdZedusedurdZdd�ZdS)�
AgentTestBasez*
    Tests for SSHAgentServer/Client.
    Nz)Cannot run without cryptography or PyASN1cCsjt�tjtj�\|_|_|_t�|j_	t
j�t
j�|_t
j�t
j�|_t
j�t
j�|_t
j�t
j�|_dSr)r�connectedServerAndClientr�SSHAgentServer�SSHAgentClient�client�server�pumpr
�factoryr�Key�
fromStringr�privateRSA_openssh�
rsaPrivate�privateDSA_openssh�
dsaPrivate�publicRSA_openssh�	rsaPublic�publicDSA_openssh�	dsaPublicrrrr�setUp8s�
zAgentTestBase.setUp)rrrrrr�skipr'rrrrr0s
rc@r	)�&ServerProtocolContractWithFactoryTestsz�
    The server protocol is stateful and so uses its factory to track state
    across requests.  This test asserts that the protocol raises if its factory
    doesn't provide the necessary storage for that state.
    cCs2t�ddtj�}|jjjd=|�t|jj	|�dS)Nz!LB�r)
�struct�packr�AGENTC_REQUEST_IDENTITIESrr�__dict__�assertRaisesr�dataReceived)r
�msgrrr�/test_factorySuppliesKeyStorageForServerProtocolQszVServerProtocolContractWithFactoryTests.test_factorySuppliesKeyStorageForServerProtocolN)rrrrr2rrrrr)Jsr)c@�(eZdZdZdd�Zdd�Zdd�ZdS)	�"UnimplementedVersionOneServerTestsa!
    Tests for methods with no-op implementations on the server. We need these
    for clients, such as openssh, that try v1 methods before going to v2.

    Because the client doesn't expose these operations with nice method names,
    we invoke sendRequest directly with an op code.
    cs0�j�tjd�}�j���fdd�}|�|�S)zV
        assert that we get the correct op code for an RSA identities request
        �cs��tjt|dd���dS)Nrr*)�assertEqualr�AGENT_RSA_IDENTITIES_ANSWER�ord)�packetrrr�_cbhszRUnimplementedVersionOneServerTests.test_agentc_REQUEST_RSA_IDENTITIES.<locals>._cb)r�sendRequestr�AGENTC_REQUEST_RSA_IDENTITIESr�flush�addCallback)r
�dr:rrr�"test_agentc_REQUEST_RSA_IDENTITIESas

zEUnimplementedVersionOneServerTests.test_agentc_REQUEST_RSA_IDENTITIEScC�(|j�tjd�}|j��|�|jd�S)z[
        assert that we get the correct op code for an RSA remove identity request
        r5)rr;r�AGENTC_REMOVE_RSA_IDENTITYrr=r>r6�r
r?rrr�test_agentc_REMOVE_RSA_IDENTITYms
zBUnimplementedVersionOneServerTests.test_agentc_REMOVE_RSA_IDENTITYcCrA)zj
        assert that we get the correct op code for an RSA remove all identities
        request.
        r5)rr;r� AGENTC_REMOVE_ALL_RSA_IDENTITIESrr=r>r6rCrrr�%test_agentc_REMOVE_ALL_RSA_IDENTITIESus
zHUnimplementedVersionOneServerTests.test_agentc_REMOVE_ALL_RSA_IDENTITIESN)rrrrr@rDrFrrrrr4Xs
r4c@s eZdZdZdd�Zdd�ZdS)�
CorruptServerz�
        A misbehaving server that returns bogus response op codes so that we can
        verify that our callbacks that deal with these op codes handle such
        miscreants.
        cC�|�dd�dS�N�r5��sendResponse�r
�datarrr�agentc_REQUEST_IDENTITIES��z'CorruptServer.agentc_REQUEST_IDENTITIEScCrHrIrKrMrrr�agentc_SIGN_REQUEST�rPz!CorruptServer.agentc_SIGN_REQUESTN)rrrrrOrQrrrrrG�srGc@r3)	�ClientWithBrokenServerTestszM
    verify error handling code in the client using a misbehaving server
    cCs2t�|�t�ttj�\|_|_|_	t
�|j_dSr)rr'rrrGrrrrrr
rrrrrr'�s

�z!ClientWithBrokenServerTests.setUpcCs*|j�|j��d�}|j��|�|t�S)z�
        Assert that L{SSHAgentClient.signData} raises a ConchError
        if we get a response from the server whose opcode doesn't match
        the protocol for data signing requests.
        �John Hancock)r�signDatar$�blobrr=�
assertFailurerrCrrr�"test_signDataCallbackErrorHandling�s
z>ClientWithBrokenServerTests.test_signDataCallbackErrorHandlingcCs |j��}|j��|�|t�S)z�
        Assert that L{SSHAgentClient.requestIdentities} raises a ConchError
        if we get a response from the server whose opcode doesn't match
        the protocol for identity requests.
        )r�requestIdentitiesrr=rVrrCrrr�+test_requestIdentitiesCallbackErrorHandling�s

zGClientWithBrokenServerTests.test_requestIdentitiesCallbackErrorHandlingN)rrrrr'rWrYrrrrrR�s
	
rRc@�0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�AgentKeyAdditionTestsz<
    Test adding different flavors of keys to an agent.
    c�2�j��j���}�j���fdd�}|�|�S)�@
        L{SSHAgentClient.addIdentity} adds the private key it is called
        with to the SSH agent server to which it is connected, associating
        it with the comment it is called with.

        This test asserts that omitting the comment produces an
        empty string for the comment on the server.
        c�:�jjj�j��}���j|d���d|d�dS�Nrr5r*�rrrr rUr6��ignored�	serverKeyrrr�_check��zBAgentKeyAdditionTests.test_addRSAIdentityNoComment.<locals>._check�r�addIdentityr �privateBlobrr=r>�r
r?rdrrr�test_addRSAIdentityNoComment��	

z2AgentKeyAdditionTests.test_addRSAIdentityNoCommentcr\)r]cr^r_�rrrr"rUr6rarrrrd�rezBAgentKeyAdditionTests.test_addDSAIdentityNoComment.<locals>._check�rrgr"rhrr=r>rirrr�test_addDSAIdentityNoComment�rkz2AgentKeyAdditionTests.test_addDSAIdentityNoCommentc�6�jj�j��dd�}�j���fdd�}|�|�S)�1
        L{SSHAgentClient.addIdentity} adds the private key it is called
        with to the SSH agent server to which it is connected, associating
        it with the comment it is called with.

        This test asserts that the server receives/stores the comment
        as sent by the client.
        �My special key��commentcr^�Nrrqr*r`rarrrrd�rezDAgentKeyAdditionTests.test_addRSAIdentityWithComment.<locals>._checkrfrirrr�test_addRSAIdentityWithComment��	
�

z4AgentKeyAdditionTests.test_addRSAIdentityWithCommentcro)rprqrrcr^rtrlrarrrrdrezDAgentKeyAdditionTests.test_addDSAIdentityWithComment.<locals>._checkrmrirrr�test_addDSAIdentityWithComment�rvz4AgentKeyAdditionTests.test_addDSAIdentityWithCommentN)rrrrrjrnrurwrrrrr[�sr[c@seZdZdd�ZdS)�AgentClientFailureTestscCs$|j�dd�}|j��|�|t�S)zK
        verify that the client raises ConchError on AGENT_FAILURE
        rJr5)rr;rr=rVrrCrrr�test_agentFailure	s
z)AgentClientFailureTests.test_agentFailureN)rrrryrrrrrxsrxc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�AgentIdentityRequestsTestszJ
    Test operations against a server with identities already loaded.
    cC�Bt�|�|jdf|jjj|j��<|jdf|jjj|j��<dS�N�	a comment�another comment�rr'r"rrrrUr rrrrr'�
��z AgentIdentityRequestsTests.setUpcCsX|j�|j��d�}|j��|�|�}|j�d�}|�	||�|�
|j�|d��dS)zc
        Sign data with an RSA private key and then verify it with the public
        key.
        rSN)rrTr$rUrr=�successResultOfr �signr6�
assertTrue�verify)r
r?�	signature�expectedrrr�test_signDataRSA"s

z+AgentIdentityRequestsTests.test_signDataRSAcs4�j��j��d�}�j���fdd�}|�|�S)zb
        Sign data with a DSA private key and then verify it with the public
        key.
        rScs���j�|d��dS)NrS)r�r&r�)�sigrrrrd7sz;AgentIdentityRequestsTests.test_signDataDSA.<locals>._check)rrTr&rUrr=r>rirrr�test_signDataDSA/s

z+AgentIdentityRequestsTests.test_signDataDSAcCs<|jjj|j��=|j�|j��d�}|j��|�	|t
�S)zm
        Assert that we get an errback if we try to sign data using a key that
        wasn't added.
        rS)rrrr$rUrrTrr=rVrrCrrr�$test_signDataRSAErrbackOnUnknownBlob?s
z?AgentIdentityRequestsTests.test_signDataRSAErrbackOnUnknownBlobc�*�j��}�j���fdd�}|�|�S)z}
        Assert that we get all of the keys/comments that we add when we issue a
        request for all identities.
        cs^i}d|�j��<d|�j��<i}|D]}|d|tjj|ddd���<q��||�dS)Nr}r~r*rrU)�type)r&rUr$rrrr6)�keytr��received�krrrrdQs"zAAgentIdentityRequestsTests.test_requestIdentities.<locals>._check)rrXrr=r>rirrr�test_requestIdentitiesIs



z1AgentIdentityRequestsTests.test_requestIdentitiesN)	rrrrr'r�r�r�r�rrrrrzs

rzc@rZ)�AgentKeyRemovalTestsz<
    Test support for removing keys in a remote server.
    cCr{r|rrrrrr'cr�zAgentKeyRemovalTests.setUpcr\)z<
        Assert that we can remove an RSA identity.
        csJ��dt�jjj�����j���jjj����j	���jjj�dS�Nr*)
r6�lenrrr�assertInr"rU�assertNotInr �rbrrrrdvsz;AgentKeyRemovalTests.test_removeRSAIdentity.<locals>._check)r�removeIdentityr rUrr=r>rirrr�test_removeRSAIdentityns

z+AgentKeyRemovalTests.test_removeRSAIdentitycr\)z;
        Assert that we can remove a DSA identity.
        cs2��dt�jjj�����j���jjj�dSr�)r6r�rrrr�r rUr�rrrrd�sz;AgentKeyRemovalTests.test_removeDSAIdentity.<locals>._check)rr�r"rUrr=r>rirrr�test_removeDSAIdentity}s

z+AgentKeyRemovalTests.test_removeDSAIdentitycr�)z;
        Assert that we can remove all identities.
        cs��dt�jjj��dS)Nr)r6r�rrrr�rrrrd�sz=AgentKeyRemovalTests.test_removeAllIdentities.<locals>._check)r�removeAllIdentitiesrr=r>rirrr�test_removeAllIdentities�s


z-AgentKeyRemovalTests.test_removeAllIdentitiesN)rrrrr'r�r�r�rrrrr�^sr�)!rr+�twisted.testr�
twisted.trialr�cryptography�
_cryptography�ImportError�pyasn1�_pyasn1�twisted.conch.sshr�_agentr�_keys�twisted.conch.errorrr�twisted.conch.testrr
�TestCaserr)r4rrGrRr[rxrzr�rrrr�<module>sF���

'#V
L

Anon7 - 2022
AnonSec Team