HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/conch/__pycache__/manhole_tap.cpython-38.pyc
U


W[��@s�dZddlmZddlmZddlmZmZddlm	Z	m
Z
ddlmZm
Z
ddlmZmZmZddlmZdd	lmZGd
d�d�ZGdd
�d
�Zee	j�Gdd�d��ZGdd�dej�Zdd�ZdS)z\
TAP plugin for creating telnet- and ssh-accessible manhole servers.

@author: Jp Calderone
�)�implementer)�protocol)�service�strports)�portal�checkers)�usage�filepath)�manhole�manhole_ssh�telnet)�insults)�keysc@seZdZdd�Zdd�ZdS)�makeTelnetProtocolcCs
||_dS�N)r)�selfr�r�;/usr/lib/python3/dist-packages/twisted/conch/manhole_tap.py�__init__szmakeTelnetProtocol.__init__cCstj}|jf}tj|f|��Sr)rZAuthenticatingTelnetProtocolrZTelnetTransport)rZauth�argsrrr�__call__szmakeTelnetProtocol.__call__N��__name__�
__module__�__qualname__rrrrrrrsrc@seZdZdd�Zdd�ZdS)�chainedProtocolFactorycCs
||_dSr)�	namespace)rrrrrr#szchainedProtocolFactory.__init__cCst�tj|j�Sr)r
�ServerProtocolr
�ColoredManholer�rrrrr&szchainedProtocolFactory.__call__Nrrrrrr"src@seZdZdd�Zdd�ZdS)�_StupidRealmcOs||_||_||_dSr)�protocolFactory�protocolArgs�protocolKwArgs)r�proto�a�kwrrrr-sz_StupidRealm.__init__cGs0tj|kr&tj|j|j|j�dd�fSt��dS)NcSsdSrrrrrr�<lambda>7�z,_StupidRealm.requestAvatar.<locals>.<lambda>)rZITelnetProtocolr!r"r#�NotImplementedError)rZavatarIdZ
interfacesrrr�
requestAvatar2s
��z_StupidRealm.requestAvatarN)rrrrr*rrrrr +sr c	@s\eZdZddddgddddgdd	d
dgddd
dgddddgddddggZdd�Zdd�ZdS)�Options�
telnetPort�tNzMstrports description of the address on which to listen for telnet connections�sshPort�szJstrports description of the address on which to listen for ssh connections�passwd�pz/etc/passwdz1name of a passwd(5)-format username/password file�	sshKeyDir�<USER DATA DIR>z2Directory where the autogenerated SSH key is kept.�
sshKeyNamez
server.keyz&Filename of the autogenerated SSH key.�
sshKeySizeiz,Size of the automatically generated SSH key.cCstj�|�d|d<dS)Nr)rr+rrrrrrNszOptions.__init__cCs&|ddkr"|ddkr"t�d��dS)Nr,r.z<At least one of --telnetPort and --sshPort must be specified)rZ
UsageErrorrrrr�postOptionsRs�zOptions.postOptions)rrrZ
optParametersrr6rrrrr+<s*�������r+cCs6t��}|d}|dkri}t�|d�}|dr�ttjtjt	j
|�}t�||g�}t
��}t|�|_
t�|d|�}|�|�|d�r2t��}t|�|_t�||g�}	t�|	�}
|ddkr�|d}ndd	lm}|�}t�|��|d
�}
t�|
t|d��}||
jd<||
jd<t�|d|
�}|�|�|S)
a;
    Create a manhole server service.

    @type options: L{dict}
    @param options: A mapping describing the configuration of
    the desired service.  Recognized key/value pairs are::

        "telnetPort": strports description of the address on which
                      to listen for telnet connections.  If None,
                      no telnet service will be started.

        "sshPort": strports description of the address on which to
                   listen for ssh connections.  If None, no ssh
                   service will be started.

        "namespace": dictionary containing desired initial locals
                     for manhole connections.  If None, an empty
                     dictionary will be used.

        "passwd": Name of a passwd(5)-format username/password file.

        "sshKeyDir": The folder that the SSH server key will be kept in.

        "sshKeyName": The filename of the key.

        "sshKeySize": The size of the key, in bits. Default is 4096.

    @rtype: L{twisted.application.service.IService}
    @return: A manhole service.
    rNr0r,r.r2r3r)�getDataDirectoryr4r5sssh-rsa) rZMultiServicerZFilePasswordDBr rZTelnetBootstrapProtocolr
rr
rrZPortalrZ
ServerFactoryrrZsetServiceParentrZ
TerminalRealmrZConchFactoryZtwisted.python._appdirsr7r	ZFilePathZchildrZ_getPersistentRSAKey�intZ
publicKeysZprivateKeys)ZoptionsZsvcrZcheckerZtelnetRealmZtelnetPortalZ
telnetFactoryZ
telnetServiceZsshRealmZ	sshPortalZ
sshFactoryZkeyDirr7ZkeyLocationZsshKeyZ
sshServicerrr�makeServiceYsH�

�





�


r9N)�__doc__Zzope.interfacerZtwisted.internetrZtwisted.applicationrrZtwisted.credrrZtwisted.pythonrr	Z
twisted.conchr
rrZtwisted.conch.insultsr
Ztwisted.conch.sshrrrZIRealmr r+r9rrrr�<module>s