
    Yf\                     .   d Z ddlZddlZddlZddlZddlZddlZddlZddl	m
Z ddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZ ddlm Z  ddl!m"Z"m#Z#m$Z$m%Z% dd	l&m'Z'm(Z(  G d
 dej)                  Z* G d de(j+                  Z,da-da.da/da0d Z1d Z2d Z3 G d de#j4                  Z5 G d dej6                  Z6 G d dej7                  Z7 G d dej8                  Z8 G d dej9                  Z:e;dk    r e2             dS dS )z2
Implementation module for the `tkconch` command.
    N)ListTuple)error)isInKnownHosts)channelcommon
connection
forwardingkeyssession	transportuserauth)tkvt100)deferprotocolreactor	tksupport)logusagec                   ,    e Zd Zd Zd Zd Zd Zd ZdS )TkConchMenuc                 
   t          j        j        | g|R i | | j                            d           t          j                    | _        | j                            d           t          j        | ddd          	                    ddd           t          j
        |           | _        | j        	                    d	d	dd
           t          j        | ddd          	                    dd	d           t          j
        |           | _        | j        	                    d	d	d	d
           t          j        | ddd          	                    ddd           t          j
        |           | _        | j        	                    d	d	dd
           t          j        | ddd          	                    ddd           t          j
        |           | _        | j        	                    d	d	dd
           t          j        | ddd          	                    ddd           t          j
        |           | _        | j        	                    d	dd
           t          j        | | j        d          	                    ddd
           t          j        | d          	                    ddd           t          j        | dd          | _        | j        	                    d	d	dd
           t          j        | d| j                  	                    dd           t          j        | d| j                  	                    dd           t          j
        |           | _        | j        	                    d	dd
           t          j        | d          	                    ddd
           t          j
        |           | _        | j        	                    d	dd
           t          j        | d           	                    ddd
           t          j        | d!| j        d"          | _        | j        	                    d	d#           t          j        | d$| j        d%"          | _        | j        	                    dd#           t          j        | d&          	                    ddd'd
           t          j        | ddd(          	                    dd)d           t          j
        | d*+          | _        | j        	                    d	d	d)d
           t          j        | ddd,          	                    dd-d           t          j
        | d.+          | _        | j        	                    d	d	d-d
           t          j        | ddd/          	                    dd0d           t          j
        | d1+          | _        | j        	                    d	d	d0d
           t          j        | d2| j                  	                    ddd3d
           |                     ddd45           |                      d	dd	5           | j        !                    d6tD          j#                   d S )7NTkConchlocalwleftHostname)anchorjustifytext   )columnrowsticky   nesw)r"   
columnspanr#   r$   PortUsername   Command   Identity   Browse)commandr    zPort Forwarding)r       r   )heightwidthAdd)r    r0      )r"   r#   Remove   HostLocal)r    variablevalue	   RemoteremotezAdvanced Options
   Cipher   cipher)nameMAC   maczEscape Char   escapezConnect!   @   )weightminsizeWM_DELETE_WINDOW)$TkinterFrame__init__mastertitle	StringVarlocalRemoteVarsetLabelgridEntryhostportuserr0   identityButtongetIdentityFileListboxforwards
addForwardremoveForwardforwardPortforwardHostRadiobuttonlocalForwardremoteForwardrB   rF   rH   	doConnectgrid_rowconfiguregrid_columnconfigurer   sysexit)selfargsparamss      O/var/www/html/env/lib/python3.11/site-packages/twisted/conch/scripts/tkconch.pyrP   zTkConchMenu.__init__'   s   t5d555f555)$$$%/11(((d3ZHHHMM!C 	N 	
 	
 	
 M$''		aA1VDDDd3VDDDII!C 	J 	
 	
 	
 M$''		aA1VDDDd3ZHHHMM!C 	N 	
 	
 	
 M$''		aA1VDDDd3YGGGLL!C 	M 	
 	
 	
 }T**qaGGGd3ZHHHMM!C 	N 	
 	
 	
  d++!6:::tT%9IIINN!F 	O 	
 	
 	
 	d!233388qQT8UUUQa@@@!qHHHt%AAAFFaUVFWWWt(D4FGGGLL! 	M 	
 	
 	
 #=..QAf===d(((--QAf-MMM"=..QAf===d(((--QAf-MMM#/w)<G
 
 
 	aQ///$0x$*=X
 
 
 	qa000d!3444996 	: 	
 	
 	
 	d3XFFFKK"S 	L 	
 	
 	
 mDx888aRGGGd3UCCCHH"S 	I 	
 	
 	
 =E222Q1"VDDDd3]KKKPP"S 	Q 	
 	
 	
 mDx888aRGGGt*dnEEEJJ6 	K 	
 	
 	

 	qB777!!!Aq!999/:::::    c                     t          j                    }|rL| j                            dt          j                   | j                            t          j        |           d S d S Nr   )tkFileDialogaskopenfilenamer\   deleterN   ENDinsert)rm   rs     rp   r^   zTkConchMenu.getIdentityFile   s\    (** 	1M  GK000M  a00000	1 	1rq   c                    | j                                         }| j                             dt          j                   | j                                        }| j                            dt          j                   | j                                        dk    r-| j                            t          j        d| d|            d S | j                            t          j        d| d|            d S )Nr   r   L::R:)	rc   getrv   rN   rw   rd   rT   r`   rx   )rm   rZ   rY   s      rp   ra   zTkConchMenu.addForward   s    ##%%7;///##%%7;///""$$//M  .@4.@.@$.@.@AAAAAM  .@4.@.@$.@.@AAAAArq   c                     | j                                         }|r"| j                             |d                    d S d S rs   )r`   curselectionremove)rm   curs     rp   rb   zTkConchMenu.removeForward   sG    m((** 	)M  Q(((((	) 	)rq   c                 Z	   d}| j                                         t          d<   | j                                        t          d<   | j                                        t          d<   | j                                        t          d<   | j                                        }| j                                        }| j                                        }|r3|t          j
        v r|gt          _
        nt          j        dd           d}|r5|t          j        v r|gt          _        n|rt          j        dd	           d}|r|d
k    rd t          d<   n|d         dk    rAt          |          dk    r.t          t!          |d                   dz
            t          d<   n:t          |          dk    r|t          d<   n|rt          j        dd|z             d}| j                                        r6t          j                            | j                                                   | j                            dt*          j                  D ]S}|d         dk    r#t                              |dd                     1t                              |dd                     Tdt          d         v r4t          d                             dd          \  t          d<   t          d<   t          d         rt          d         s|rt          j        dd           d}|r~| j                                         | j                                         t          d         r7t:          j        }t?          j         t:          j!                   |t:          _        nt?          j"                     tF          t>          _$        t          j        sddgt          _        t          d         }tK          t          d         pd          }t?          j&        ||f           tO          j(        ||tS                                 tT          j        +                                 tT          j        ,                    d-                    t          d         t          d                              d S | .                                 d S )Nr!   rY   rZ   r[   r0   r   zBad cipher.r   zBad MAC.nonerH   ^r%   rJ   zBad escape character '%s'.L@zMissing host or username.r   z~/.ssh/id_rsaz~/.ssh/id_dsa   z{}@{} - TkConch)/rY   r~   optionsrZ   r[   r0   rB   rF   rH   SSHClientTransportsupportedCipherstkMessageBox	showerrorsupportedMACslenchrordr\   	identitysappendr`   rN   rw   opt_localforwardopt_remoteforwardsplitrQ   quitdestroyrk   stdoutr   startLoggingstderrdiscardLogshandleErrordeferrintmsgr   
connectTCPSSHClientFactoryframe	deiconifyrR   formatfocus)	rm   finishedrB   rF   rH   linerealoutrY   rZ   s	            rp   rh   zTkConchMenu.doConnect   s
   )--//)--//)--//!\--//	""hllnn"" 	+<<<7=h"33&y-@@@ 	(666475"00 &y*=== 		$(!!c!!c&kkQ&6&6$'F1I(;$<$<!!V!!$*!! &y2NQW2WXXX= 	:$$T]%6%6%8%8999M%%a55 	4 	4DAw#~~((abb2222))$qrr(3333'&/!!/6v/D/DS!/L/L,GFOWV_ 	wv 	H 	"9.IJJJH 	KK!!!u~ "* ,,,$

!!!$CJ$ G%4o$F!6?Dwv,"--DGT4L!!!tT+;+=+=>>>L""$$$L!(('&/JJ     JJLLLLLrq   N)__name__
__module____qualname__rP   r^   ra   rb   rh    rq   rp   r   r   &   sk        \; \; \;|1 1 1B B B) ) )
F F F F Frq   r   c            
          e Zd ZU dZg dg dg dg dg dg dg dg d	gZg d
g dg dg dg dg dg dg dgZej        j        Z	ej        j
        Z ej        dg ej        d e	D                        ej        d eD                        ej        d           ej        d          d ej                     ej        d           ej        dd          g          Zg Zee         ed<   g Zeeeeeef         f                  ed<   g Zeeeeeef         f                  ed<   d  Zd! Zd" Zd# Zd$ Zd%S )&GeneralOptionsz,Usage:    tkconch [options] host [command]
 )r[   lNzLog in using this user name.)r\   iz~/.ssh/identityz&Identity for public key authentication)rH   e~z(Set escape character; ``none'' = disable)rB   cNzSelect encryption algorithm.)macsmNz.Specify MAC algorithms for protocol version 2.)rZ   pNz7Connect to this port.  Server must be on the same port.)localforwardr   Nz<listen-port:host:port   Forward local port to remote address)remoteforwardRNz<listen-port:host:port   Forward remote port to local address)ttytz-Tty; allocate a tty even if command is given.)nottyTzDo not allocate a tty.)versionVzDisplay version number only.)compressCzEnable compression.)noshellNz"Do not execute a shell or command.)	subsystemsz-Invoke command (mandatory) as SSH2 subsystem.)r   vzLog to stderr)ansilogaz!Print the received data to stdout)r   r   c                 6    g | ]}|                                 S r   decode.0r   s     rp   
<listcomp>zGeneralOptions.<listcomp>  s     )G)G)G!((**)G)G)Grq   c                 6    g | ]}|                                 S r   r   r   s     rp   r   zGeneralOptions.<listcomp>  s     'B'B'Bq

'B'B'Brq   zlisten-port:host:port)descr)rB   r   r   r   r0   argumentT)r   repeat)mutuallyExclusive
optActionsextraActionsr   localForwardsremoteForwardsc                 :    | j                             |           d S N)r   r   )rm   r   s     rp   opt_identityzGeneralOptions.opt_identity  s    a     rq   c                     |                     d          \  }}}t          |          }t          |          }| j                            |||ff           d S Nr|   )r   r   r   r   )rm   f	localPort
remoteHost
remotePorts        rp   r   zGeneralOptions.opt_localforward   sU    ,-GGCLL)	:z	NN	__
!!9z:.F"GHHHHHrq   c                     |                     d          \  }}}t          |          }t          |          }| j                            |||ff           d S r   )r   r   r   r   )rm   r   r   connHostconnPorts        rp   r   z GeneralOptions.opt_remoteforward&  sU    )*&
Hh__
x==""J80D#EFFFFFrq   c                 *    dgt           j        dd<   d S )Nzlibr   r!   )r   supportedCompressionsrm   s    rp   opt_compresszGeneralOptions.opt_compress,  s    9?01555rq   c                 x    |r-|d         | d<   d                     |dd                    | d<   d S d| d<   d| d<   d S )Nr   rY    r!   r0    )join)rm   rn   s     rp   	parseArgszGeneralOptions.parseArgs/  sN     	!7DL!hhtABBx00DOOODL DOOOrq   N)r   r   r   synopsisoptParametersoptFlagsr   r   r   _ciphersr   _macsr   CompletionsCompleteList	CompleterCompleteUserAtHostcompDatar   r   str__annotations__r   r   r   r   r   r   r   r   r   r   rq   rp   r   r      sd        H 	<;;VVVHHH===MMMVVV	
 	
 	
	
 	
 	
M, 	FEE000888000>>>KKK%%%===	H +<H(6E u +,(e()G)Gh)G)G)GHH&E&'B'BE'B'B'BCC+EO2IJJJ,U_3JKKK	
 
 %E$&&EO),,,EO*T:::
  H ItCy79M4c5c?2349998:NDsE#s(O345:::! ! !I I IG G GA A A! ! ! ! !rq   r   c                    t           j        rt          d          t          j                    g }|ffd	}|t           _        t                               |            t           j                                         S )Nzcan't ask 2 questions at once!c                 *   | sd S | dk    rt          j                     | dk    rSt                              d           d                    |          }~d t          _                            |           d S dt          |           cxk    rdk     r8n n5|                    |            rt                              |            d S d S t          |           dk    r4|r4rt                              d           |                                 d S d S d S )	Nz
r          r7   z )	r   stopr   writer   callbackr   r   pop)chrespstrespdechos      rp   gotCharz!deferredAskFrame.<locals>.gotCharE  s    	F<<LNNN::KKWWT]]F!ENJJvF3r77    S     KKOOO  B   WW\\d\ )K(((HHJJJJJ \\\rq   )r   r  
ValueErrorr   Deferredr  canvasfocus_force)questionr	  r  r
  r  s    `  @rp   deferredAskFramer  ?  s    ~ ;9:::AD       * EN	KK	LHrq   c            
         t           j        dd          } d| v r0|                     d          }| ||dz            | z   } | |dz   |dz   = | d d          D ]U}	 |                     |          }|d d         dk    r| |dz            d         dk    r
g | ||dz   <   F# t          $ r Y Rw xY wt	          j                    }|                                 t	          j                    }t          |          a	t          
                    t          j        t          j        d           t                      a	 t                              |            n[# t           j        $ rI}t%          d	|z             t                                           t          j        d           Y d }~nd }~ww xY wt                                          D ]O\  }}|rHt-          t          |          r3t/          t          |                              t          j        |           Pt          j        D ];\  }\  }	}
t          j                            t          j        d
| d|	 d|
            <g t          _        t          j        D ];\  }\  }	}
t          j                            t          j        d| d|	 d|
            <g t          _        t;          j        |d           a|                     dt:          j!        t>          j"        z  dz   t:          j#        t>          j$        z  dz   fz             t>          
                    t          j                   tK          j&        |           |                                 t          d         rt          d         sdt          d         v rt          '                                 n|(                                 tS          j*                     t          j        tV                     d S )Nr!   z-lr%   r,   z-or   -)sidefillexpandz	ERROR: %sr{   r|   r}   )r  z%dx%dr*   )r  rY   r[   r   ),rk   argvindexr  rN   TkwithdrawToplevelr   menupackTOPBOTHr   r   parseOptionsr   
UsageErrorprintopt_helprl   itemshasattrgetattrrx   rw   r   r`   r   r   
VT100Framer   geometry	fontWidthr3   
fontHeightr2   r   installrh   mainloopr   run
exitStatus)rn   r   argroottopukr   r   rhrps              rp   r,  r,  `  s   8ABB<Dt||JJtAAI%QQAAAw  	

3A2A2w$4A;q>S#8#8"$QQY 	 	 	D	:<<DMMOOO



CsDII7;W\!I<<<GT""""   kAo  4 41 	4q!! 	4D!##GK333, > >8BW[*<q*<*<2*<*<*<*<====G- > >8BW[*<q*<*<2*<*<*<*<====Gtd333EMMu{*Q.0BU\0QTU0U
V	W   
JJGKJ   dMMOOO GFO wv0F0FKMMMHZs+   AB
B&%B&2E F%?F  F%c                      ddl m}  dat          j        |                                            t          j                      )Nr   failurer%   )twisted.pythonr7  r-  r   errFailurer   r  r6  s    rp   r   r     sC    &&&&&& JGGOOLNNN	rq   c                   $    e Zd ZdZd Zd Zd ZdS )r   Tc                 ,    t          j                     d S r   )r   r  r   s    rp   stopFactoryzSSHClientFactory.stopFactory  s    rq   c                     t                      S r   )r   )rm   addrs     rp   buildProtocolzSSHClientFactory.buildProtocol  s    !###rq   c                 P    t          j        dd|j         d|j                    d S )Nr   zConnection Failed, Reason:
 z: )r   showwarningtyper;   )rm   	connectorreasons      rp   clientConnectionFailedz'SSHClientFactory.clientConnectionFailed  s;     IFKII6<II	
 	
 	
 	
 	
rq   N)r   r   r   noisyr=  r@  rF  r   rq   rp   r   r     sF        E  $ $ $
 
 
 
 
rq   r   c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )r   c                     d||fz  a d S )NzDconch:	Remote side disconnected with error code %i
conch:	reason: %s)r-  )rm   codedescs      rp   receiveErrorzSSHClientTransport.receiveError  s     VTl 	

rq   c                 V    d||fz  a t          j                            | ||           d S )Nz>conch:	Sending disconnect with error code %i
conch:	reason: %s)r-  r   r   sendDisconnect)rm   rJ  rE  s      rp   rN  z!SSHClientTransport.sendDisconnect  s<     PVn 	 	$33D$GGGGGrq   c                 V    |st           d         rt          j        d|z             d S d S )Nr   zReceived Debug Message: %s)r   r   r   )rm   alwaysDisplaymessagelangs       rp   receiveDebugzSSHClientTransport.receiveDebug  s;     	<GEN 	<G07:;;;;;	< 	<rq   c                 "   t          t          d         |dd i          }|dk    rt          j        d          S |dk    r&t          j        t          j        d                    S t          d         | j                                        j	        k    rt          d         }t          d         }nzd
                    t          d         | j                                        j	                  }d
                    t          d         | j                                        j	                  }t          j        |          d         }d	
                    |d
dd|         |          }|dz  }t          |d                              | j        |||          S )NrY   zknown-hostsr!   r%   bad host keyz{} ({})z{},{}r   zNThe authenticity of host '{}' can't be established.
{} key fingerprint is {}.DSARSAs   ssh-dsss   ssh-rsaz9
Are you sure you want to continue connecting (yes/no)? )r   r   r   succeedfailr   
ConchErrorr   getPeerrY   r   r   getNSr  addCallback_cbVerifyHostKey)rm   pubKeyfingerprintgoodKeyrY   khHostkeyTypequess           rp   verifyHostKeyz SSHClientTransport.verifyHostKey  s_   
 !&=$:OPPa<<=###\\:e.~>>???v$."8"8":":"???v  ''9O9O9Q9Q9VWW 9O9O9Q9Q9VWWl6**1-G#V"66w?   QQD#D!,,88%vvw  rq   c           	         |                                 dvr+t          dd                              | j        |||          S |                                 dk    r.t                              d           t          j        d          	 t                              d|dd	d
d|         d           t          t          j
                            d          d          5 }t          j        |          }|                    d| d| d|            d d d            d S # 1 swxY w Y   d S # t          $ r  t          j                     t          j        w xY w)N)yesnozPlease type  'yes' or 'no': r!   ri  zHost key verification failed.
rU  zWarning: Permanently added 'z' (rV  rW  rX  z) to the list of known hosts.
z~/.ssh/known_hostsr   
r   )lowerr  r^  r_  r   r  r   r[  openospath
expanduserbase64	b64encodeBaseExceptionr   r   )rm   ansr`  rc  rd  known_hosts
encodedKeys          rp   r_  z#SSHClientTransport._cbVerifyHostKey  s   99;;m++#$BAFFRR%vvw   99;;$KK;<<<">222	#KKK 665AA'JJJL  
 bg(()=>>DD H#-f55
!!"Fv"F"F"F"F*"F"FGGGH H H H H H H H H H H H H H H H H H  	# 	# 	#JLLL""	#s1   	AD-  3D D-  D$$D- 'D$(D- -*Ec                     t           d         rt           d         }nt          j                    }|                     t	          |t                                           d S )Nr[   )r   getpassgetuserrequestServiceSSHUserAuthClientSSHConnection)rm   r[   s     rp   connectionSecurez#SSHClientTransport.connectionSecure  sO    6? 	%6?DD?$$D-dMOODDEEEEErq   N)	r   r   r   rL  rN  rS  rf  r_  r|  r   rq   rp   r   r     sv        
 
 
H H H< < <
  :# # #*F F F F Frq   r   c                   D    e Zd ZU g Zee         ed<   ddZd Zd Z	d Z
dS )rz  	usedFilesNc                 r    |s&d                     | j        t          d                   }t          |d          S )Nz{}@{}'s password: rY   r   )r   r[   r   r  )rm   prompts     rp   getPasswordzSSHUserAuthClient.getPassword  s6     	M)00GFOLLF***rq   c                      fdt           j        D             }|sd S |d         }t          j        |            j                            |           t          j                            |          }|dz  }t          j        	                    |          sd S 	 t          j                            |                                          S # t          $ r                                  cY S w xY w)Nc                 &    g | ]}|j         v|S r   )r~  )r   xrm   s     rp   r   z2SSHUserAuthClient.getPublicKey.<locals>.<listcomp>  s%    IIIq$.1H1H1H1H1Hrq   r   z.pub)r   r   r   r   r~  r   rm  rn  ro  existsr   KeyfromFileblobrr  getPublicKey)rm   filesfiles   `  rp   r  zSSHUserAuthClient.getPublicKey  s    IIIIG-III 	4Qxd###w!!$''w~~d## 	F	'8$$T**//111 	' 	' 	'$$&&&&&	's   0C C,+C,c                    t           j                            | j        d                   }t           j                            |          sd S 	 t          j        t          j        	                    |          j
                  S # t          j        $ rZ}|j        d         dk    r>d| j        d         z  }t          |d                              | j        d          cY d }~S Y d }~d S d }~ww xY w)Nr   zencrypted key with no passwordEnter passphrase for key '%s': )rm  rn  ro  r~  r  r   rY  r   r  r  	keyObjectBadKeyErrorrn   r  r^  _cbGetPrivateKey)rm   r  r   r  s       rp   getPrivateKeyzSSHUserAuthClient.getPrivateKey  s    w!!$."455w~~d## 	4	Y=!2!24!8!8!BCCC 	Y 	Y 	Yvay<<<:T^B=OO'22>>t?TVWXXXXXXXX =<<<<<	Ys   5B C,A	C'C,'C,c                 T   t           j                            | j        d                   }	 t          j                            ||          j        S # t          j        $ rF |dk    r d| j        d         z  }t          |d          
                    | j        |dz             cY S w xY w)Nr  )passwordr%   r  r   r!   )rm  rn  ro  r~  r   r  r  r  r  r  r^  r  )rm   rs  countr  r  s        rp   r  z"SSHUserAuthClient._cbGetPrivateKey  s    w!!$."455	8$$TC$88BB 	 	 	zz69KKF#FA..::%uqy    		s   %A AB'&B'r   )r   r   r   r~  r   r   r   r  r  r  r  r   rq   rp   rz  rz    sn         ItCy+ + + +
' ' ' 	Y 	Y 	Y
 
 
 
 
rq   rz  c                       e Zd Zd ZdS )r{  c           	          t           d         s!|                     t                                 t           j        rEt           j        D ]8\  }}t	          j        |t          j        | |t          j                             9t           j	        rpt           j	        D ]e\  }}t          j        d                    ||                     t          j        d|f          }|                     d|           || j	        |<   dd S d S )Nr   z&asking for remote forwarding for {}:{}z0.0.0.0ztcpip-forward)r   openChannel
SSHSessionr   r   	listenTCPr
   SSHListenForwardingFactory SSHListenClientForwardingChannelr   r   r   r   packGlobal_tcpip_forwardsendGlobalRequest)rm   r   hostportr   datas        rp   serviceStartedzSSHConnection.serviceStarted-  s!   y! 	+Z\\***  	'.'<  #	8!9h
(S     ! 		;(/(> ; ;$
H<CC"H   
 ":Iz;RSS&&===2:#J//		; 		;; ;rq   N)r   r   r   r  r   rq   rp   r{  r{  ,  s#        ; ; ; ; ;rq   r{  c                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )r  s   sessionc                    d| _         t          j                    }t          d         r| j        |_        n| j        |_        | j        |_        |j        t          _
        t          j                                         t          d         r;| j                            | dt          j        t          d                              n%t          d         rt          d         rTt"          j                            dd          }d	}t          j        ||d
          }| j                            | d|           | j                            | dt          j        t          d                              n}t          d         sTt"          j                            dd          }d	}t          j        ||d
          }| j                            | d|           | j                            | dd           | j        j        j                            d           d S )Nr!   rH   r   s	   subsystemr0   r   TERMxterm)   P   r   r   r   s   pty-reqexecr   s   shellrq   )
escapeModer   SSHSessionClientr   handleInputdataReceivedr  sendEOFconnectionLostr   r  r  r  connsendRequestr   NSrm  environr~   packRequest_pty_reqr   setTcpNoDelay)rm   foor   termwinSize
ptyReqDatas         rp   channelOpenzSSHSession.channelOpenG  s    $&&8 	(!-ANN!ZAN<  """; 	7I!!$fi	@R6S6STTTTY 	7u~ Dz~~fg66($8wKK
	%%dJ
CCCI!!$	'):L0M0MNNNN7# Dz~~fg66($8wKK
	%%dJ
CCCI!!$#666	%33A66666rq   c                 f   |dv rd| _         |                     |           d S | j         dk    r|t          d         k    r	d| _         d S | j         dk    rd| _         |dk    r)t          j        d           t          j                     d S |dk    r2t          j        t          j	                    t          j                   d S |dk    r4t          j        d	           | j        j                                         d S |                     d
|z              d S d| _         |                     |           d S )N)rj  r   r!   rH   r%   .zdisconnecting from escaper   zrekeying connectionr   r   )r  r  r   r   r   r   r  rm  killgetpidsignalSIGSTOPr  r   sendKexInit)rm   chars     rp   r  zSSHSession.handleInputh  s*   <DOJJt_!!dgh.?&?&?DOOO_!!DOs{{3444	V^444-...	#//111JJsTz"""""DOJJtrq   c                     |                     d          }t          d         rt          t          |                     t                              |           d S )Nzutf-8r   )r   r   r!  reprr   r  rm   r  s     rp   r  zSSHSession.dataReceived  sL    {{7##9 	$t**Drq   c                     |t           j        k    rct          j        dt	          |          z             t
          j                            |           t
          j                                         d S d S )Nzgot %s stderr data)	r	   EXTENDED_DATA_STDERRr   r   r   rk   r   r  flush)rm   r   r  s      rp   extReceivedzSSHSession.extReceived  sd    
///G(3t994555JT"""J 0/rq   c                 j    t          j        d           t          j                                         d S )Nzgot eof)r   r   rk   stdincloser   s    rp   eofReceivedzSSHSession.eofReceived  s*    		rq   c                     t          j        d| z             t          | j        j                  dk    rt          j                     d S d S )Nz	closed %sr!   )r   r   r   r  channelsr   r  r   s    rp   closedzSSHSession.closed  sF    d"###ty!""a''LNNNNN ('rq   c                     t          t          j        d|          d                   at	          j        dt          z             d S )Nz>Lr   zexit status: %s)r   structunpackr-  r   r   r  s     rp   request_exit_statuszSSHSession.request_exit_status  s<    tT221566
!J./////rq   c                 :    | j                             |            d S r   )r  r  r   s    rp   r  zSSHSession.sendEOF  s    	$rq   N)r   r   r   rC   r  r  r  r  r  r  r  r  r   rq   rp   r  r  D  s        D7 7 7B  4        
0 0 0
         rq   r  __main__)<__doc__rp  rw  rm  r  r  rk   tkinterrN   tkinter.filedialog
filedialogrt   tkinter.messagebox
messageboxr   typingr   r   twisted.conchr   twisted.conch.client.defaultr   twisted.conch.sshr   r   r	   r
   r   r   r   r   twisted.conch.uir   twisted.internetr   r   r   r   r8  r   r   rO   r   Optionsr   r   r  r-  r   r  r,  r   ClientFactoryr   r   rz  r{  
SSHChannelr  r   r   rq   rp   <module>r     s6  
 
   				   



     ) ) ) ) ) ) ) ) ) ) ) )               7 7 7 7 7 7	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 % $ $ $ $ $ @ @ @ @ @ @ @ @ @ @ @ @ % % % % % % % %z z z z z'- z z zzR! R! R! R! R!U] R! R! R!l 
  B0 0 0f
 
 

 
 
 
 
x- 
 
 
 LF LF LF LF LF5 LF LF LF^- - - - -2 - - -`; ; ; ; ;J, ; ; ;0Y  Y  Y  Y  Y # Y  Y  Y x zCEEEEE rq   