ó
    Ö›‘hl  ã                   ó  • S r SSKJr  SSKJrJr  SSKJrJrJ	r	  SSK
Jr  SSKJr  SSKJrJr  SSKJr  SS	KJrJr   " S
 S5      r " S S5      r\" \R0                  5       " S S5      5       r " S S\R4                  5      rS rg)z\
TAP plugin for creating telnet- and ssh-accessible manhole servers.

@author: Jp Calderone
é    )Úimplementer)ÚserviceÚstrports)ÚmanholeÚmanhole_sshÚtelnet)Úinsults)Úkeys)ÚcheckersÚportal)Úprotocol)ÚfilepathÚusagec                   ó    • \ rS rSrS rS rSrg)ÚmakeTelnetProtocolé   c                 ó   • Xl         g ©N©r   )Úselfr   s     Ú]C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/conch/manhole_tap.pyÚ__init__ÚmakeTelnetProtocol.__init__   s   € Ø�ó    c                 ój   • [         R                  nU R                  4n[         R                  " U/UQ76 $ r   )r   ÚAuthenticatingTelnetProtocolr   ÚTelnetTransport)r   ÚauthÚargss      r   Ú__call__ÚmakeTelnetProtocol.__call__   s.   € Ü×2Ñ2ˆØ—‘ˆ~ˆÜ×%Ò% dÐ2¨TÒ2Ð2r   r   N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r    Ú__static_attributes__© r   r   r   r      s   † òõ3r   r   c                   ó    • \ rS rSrS rS rSrg)ÚchainedProtocolFactoryé   c                 ó   • Xl         g r   ©Ú	namespace)r   r.   s     r   r   ÚchainedProtocolFactory.__init__    s   € Ø"�r   c                 ó`   • [         R                  " [        R                  U R                  5      $ r   )r	   ÚServerProtocolr   ÚColoredManholer.   ©r   s    r   r    ÚchainedProtocolFactory.__call__#   s   € Ü×%Ò%¤g×&<Ñ&<¸d¿n¹nÓMÐMr   r-   Nr"   r(   r   r   r*   r*      s   † ò#õNr   r*   c                   ó    • \ rS rSrS rS rSrg)Ú_StupidRealmé'   c                 ó(   • Xl         X l        X0l        g r   )ÚprotocolFactoryÚprotocolArgsÚprotocolKwArgs)r   ÚprotoÚaÚkws       r   r   Ú_StupidRealm.__init__)   s   € Ø$ÔØÔØ Õr   c                 ó®   • [         R                  U;   a8  [         R                  U R                  " U R                  0 U R                  D6S 4$ [        5       e)Nc                  ó   • g r   r(   r(   r   r   Ú<lambda>Ú,_StupidRealm.requestAvatar.<locals>.<lambda>3   s   € ˜r   )r   ÚITelnetProtocolr9   r:   r;   ÚNotImplementedError)r   ÚavatarIdÚ
interfacess      r   ÚrequestAvatarÚ_StupidRealm.requestAvatar.   sP   € Ü×!Ñ! ZÓ/ä×&Ñ&Ø×$Ò$ d×&7Ñ&7ÐO¸4×;NÑ;NÑOÙðð ô
 "Ó#Ð#r   )r:   r9   r;   N)r#   r$   r%   r&   r   rH   r'   r(   r   r   r6   r6   '   s   † ò!õ
$r   r6   c                   óH   • \ rS rSr/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/rS rS	 rS
rg)ÚOptionsé8   )Ú
telnetPortÚtNzMstrports description of the address on which to listen for telnet connections)ÚsshPortÚsNzJstrports description of the address on which to listen for ssh connections)ÚpasswdÚpz/etc/passwdz1name of a passwd(5)-format username/password file)Ú	sshKeyDirNú<USER DATA DIR>z2Directory where the autogenerated SSH key is kept.)Ú
sshKeyNameNz
server.keyz&Filename of the autogenerated SSH key.)Ú
sshKeySizeNi   z,Size of the automatically generated SSH key.c                 óL   • [         R                  R                  U 5        S U S'   g )Nr.   )r   rK   r   r3   s    r   r   ÚOptions.__init__\   s   € Ü�‰×Ñ˜tÔ$Ø ˆˆ[Òr   c                 óJ   • U S   c  U S   c  [         R                  " S5      eg g )NrM   rO   z<At least one of --telnetPort and --sshPort must be specified)r   Ú
UsageErrorr3   s    r   ÚpostOptionsÚOptions.postOptions`   s5   € Ø�ÑÑ%¨$¨y©/Ñ*AÜ×"Ò"ØNóð ð +BÐ%r   r(   N)r#   r$   r%   r&   ÚoptParametersr   r[   r'   r(   r   r   rK   rK   8   s2   † ò	
ò	
ò	
ò	
ò 	UÚRðA!€MòF!õr   rK   c                 óÞ  • [         R                  " 5       nU S   nUc  0 n[        R                  " U S   5      nU S   (       aŸ  [	        [
        R                  [        R                  [        R                  U5      n[        R                  " XC/5      n[        R                  " 5       n[        U5      Ul        [         R                   " U S   U5      nUR#                  U5        U S   (       Ga   [$        R&                  " 5       n[)        U5      Ul        [        R                  " Xƒ/5      n	[$        R*                  " U	5      n
U S   S:w  a  U S   nOSSKJn  U" 5       n[0        R2                  " U5      R5                  U S	   5      n[6        R8                  " U[;        U S
   5      5      nXêR<                  S'   XêR>                  S'   [         R                   " U S   U
5      nUR#                  U5        U$ )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.
r.   rQ   rM   rO   rS   rT   r   )ÚgetDataDirectoryrU   rV   s   ssh-rsa) r   ÚMultiServicer   ÚFilePasswordDBr6   r   ÚTelnetBootstrapProtocolr	   r1   r   r2   r   ÚPortalr   ÚServerFactoryr   r   ÚsetServiceParentr   ÚTerminalRealmr*   ÚConchFactoryÚtwisted.python._appdirsr_   r   ÚFilePathÚchildr
   Ú_getPersistentRSAKeyÚintÚ
publicKeysÚprivateKeys)ÚoptionsÚsvcr.   ÚcheckerÚtelnetRealmÚtelnetPortalÚtelnetFactoryÚtelnetServiceÚsshRealmÚ	sshPortalÚ
sshFactoryÚkeyDirr_   ÚkeyLocationÚsshKeyÚ
sshServices                   r   ÚmakeServicer}   g   s©  € ô> ×
Ò
Ó
 €Cà˜Ñ$€IØÑØˆ	ä×%Ò% g¨hÑ&7Ó8€Gàˆ|×Ü"Ü×*Ñ*Ü×"Ñ"Ü×"Ñ"Øó	
ˆô —}’} [°)Ó<ˆä ×.Ò.Ó0ˆÜ!3°LÓ!AˆÔÜ ×(Ò(¨°Ñ)>ÀÓNˆØ×&Ñ& sÔ+àˆy×ÐÜ×,Ò,Ó.ˆÜ*@ÀÓ*KˆÔ'ä—M’M (¨IÓ6ˆ	Ü ×-Ò-¨iÓ8ˆ
à�;ÑÐ#4Ó4Ø˜[Ñ)‰Få@á%Ó'ˆFä×'Ò'¨Ó/×5Ñ5°g¸lÑ6KÓLˆä×*Ò*¨;¼¸GÀLÑ<QÓ8RÓSˆØ,2×Ñ˜jÑ)Ø-3×Ñ˜zÑ*ä×%Ò% g¨iÑ&8¸*ÓEˆ
Ø×#Ñ# CÔ(à€Jr   N)Ú__doc__Úzope.interfacer   Útwisted.applicationr   r   Útwisted.conchr   r   r   Útwisted.conch.insultsr	   Útwisted.conch.sshr
   Útwisted.credr   r   Útwisted.internetr   Útwisted.pythonr   r   r   r*   ÚIRealmr6   rK   r}   r(   r   r   Ú<module>rˆ      sv   ðñõ 'ç 1ß 6Ñ 6Ý )Ý "ß )Ý %ß *÷3ñ 3÷Nñ Nñ ˆV�]‰]Ó÷$ð $ó ð$ô ,ˆe�m‰mô ,ó^Mr   