+
    Dfj\                     F   R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt ^ RIHtHtHtHtHtHtHtHt ^ RIH t  ^ RI!H"t"H#t#H$t$H%t% ^ RI&H't'H(t(  ! R	 R
]PR                  4      t* ! R R](PV                  4      t,Rs-Rs.^ s/Rs0R t1R t2R t3 ! R R]#Ph                  4      t5 ! R R]Pl                  4      t6 ! R R]Pn                  4      t7 ! R R]Pp                  4      t8 ! R R]Pr                  4      t:];R8X  d
   ]2! 4        R# R# )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                   >   a  ] tR t^&t o R tR tR tR tR tRt	V t
R# )TkConchMenuc                h   \         P                  P                  ! V .VO5/ VB  V P                  P	                  R 4       \         P
                  ! 4       V n        V P                  P                  R4       \         P                  ! V RRRR7      P                  ^^RR7       \         P                  ! V 4      V n        V P                  P                  ^^^RR7       \         P                  ! V RRR	R7      P                  ^^RR7       \         P                  ! V 4      V n        V P                  P                  ^^^RR7       \         P                  ! V RRR
R7      P                  ^^RR7       \         P                  ! V 4      V n        V P                  P                  ^^^RR7       \         P                  ! V RRRR7      P                  ^^RR7       \         P                  ! V 4      V n        V P                  P                  ^^^RR7       \         P                  ! V RRRR7      P                  ^^RR7       \         P                  ! V 4      V n        V P                  P                  ^^RR7       \         P                   ! W P"                  RR7      P                  ^^RR7       \         P                  ! V RR7      P                  ^^RR7       \         P$                  ! V ^ ^ R7      V n        V P&                  P                  ^^^RR7       \         P                   ! V RV P(                  R7      P                  ^^R7       \         P                   ! V RV P*                  R7      P                  ^^R7       \         P                  ! V 4      V n        V P,                  P                  ^^RR7       \         P                  ! V R	R7      P                  ^^RR7       \         P                  ! V 4      V n        V P.                  P                  ^^RR7       \         P                  ! V RR7      P                  ^^RR7       \         P0                  ! V RV P                  RR7      V n        V P2                  P                  ^^	R7       \         P0                  ! V RV P                  RR7      V n        V P4                  P                  ^^	R7       \         P                  ! V RR7      P                  ^^^
RR7       \         P                  ! V RRRR7      P                  ^^RR7       \         P                  ! V RR7      V n        V P6                  P                  ^^^RR7       \         P                  ! V RRRR7      P                  ^^RR7       \         P                  ! V R R7      V n        V P8                  P                  ^^^RR7       \         P                  ! V RRR!R7      P                  ^^RR7       \         P                  ! V R"R7      V n        V P:                  P                  ^^^RR7       \         P                   ! V R#V P<                  R7      P                  ^^^RR7       V P?                  ^^^@R$7       V PA                  ^^^R$7       V P                  PC                  R%\D        PF                  4       R&# )'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   )heightwidthAdd)r   r*   )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_WINDOWN)$TkinterFrame__init__mastertitle	StringVarlocalRemoteVarsetLabelgridEntryhostportuserr*   identityButtongetIdentityFileListboxforwards
addForwardremoveForwardforwardPortforwardHostRadiobuttonlocalForwardremoteForwardr6   r9   r:   	doConnectgrid_rowconfiguregrid_columnconfigurer   sysexit)selfargsparamss   &*,?/usr/lib/python3/dist-packages/twisted/conch/scripts/tkconch.pyr@   TkConchMenu.__init__'   s   t5d5f5)$%//1(d3ZHMM!C 	N 	
 MM$'			aA1VDd3VDII!C 	J 	
 MM$'			aA1VDd3ZHMM!C 	N 	
 MM$'			aA1VDd3YGLL!C 	M 	
 }}T*qaGd3ZHMM!C 	N 	
  d+!6:t%9%9INN!F 	O 	
 	d!2388qQT8UQa@!qHt%AFFaUVFWt(D4F4FGLL! 	M 	
 #==.QAf=d(--QAf-M"==.QAf=d(--QAf-M#//w)<)<G
 	aQ/$00x$*=*=X
 	qa0d!34996 	: 	
 	d3XFKK"S 	L 	
 mmDx8aRGd3UCHH"S 	I 	
 ==E2Q1"VDd3]KPP"S 	Q 	
 mmDx8aRGt*dnnEJJ6 	K 	

 	qB7!!!Aq!9/:    c                    \         P                  ! 4       pV'       dW   V P                  P                  ^ \        P
                  4       V P                  P                  \        P
                  V4       R# R#     N)tkFileDialogaskopenfilenamerL   deleter>   ENDinsert)r]   rs   & r`   rN   TkConchMenu.getIdentityFile   sH    ((*MM  GKK0MM  a0 rb   c                   V P                   P                  4       pV P                   P                  ^ \        P                  4       V P
                  P                  4       pV P
                  P                  ^ \        P                  4       V P                  P                  4       R8X  d3   V P                  P                  \        P                  RV RV 24       R# V P                  P                  \        P                  RV RV 24       R# )re   r   L::R:N)	rS   getrh   r>   ri   rT   rD   rP   rj   )r]   rJ   rI   s   &  r`   rQ   TkConchMenu.addForward   s    ##%7;;/##%7;;/""$/MM  4&$.@AMM  4&$.@Arb   c                    V P                   P                  4       pV'       d%   V P                   P                  V^ ,          4       R# R# rd   )rP   curselectionremove)r]   curs   & r`   rR   TkConchMenu.removeForward   s2    mm((*MM  Q( rb   c                
   ^pV P                   P                  4       \        R&   V P                  P                  4       \        R&   V P                  P                  4       \        R&   V P
                  P                  4       \        R&   V P                  P                  4       pV P                  P                  4       pV P                  P                  4       pV'       d<   V\        P                  9   d   V.\        n
        M\        P                  ! RR4       ^ pV'       dD   V\        P                  9   d   V.\        n        M!V'       d   \        P                  ! RR4       ^ pV'       d   VR8X  d   R	\        R
&   MV^ ,          R8X  d;   \        V4      ^8X  d+   \        \!        V^,          4      ^@,
          4      \        R
&   MB\        V4      ^8X  d   V\        R
&   M(V'       d!   \        P                  ! RRV,          4       ^ pV P"                  P                  4       '       d8   \        P$                  P'                  V P"                  P                  4       4       V P(                  P                  ^ \*        P,                  4       FK  pV^ ,          R8X  d   \        P/                  VR,          4       K/  \        P1                  VR,          4       KM  	  R\        R,          9   d/   \        R,          P3                  R^4      w  \        R&   \        R&   \        R,          '       d   \        R,          '       g"   V'       d   \        P                  ! RR4       ^ pV'       Ed   V P4                  P7                  4        V P4                  P9                  4        \        R,          '       dA   \:        P<                  p\>        P@                  ! \:        PB                  4       V\:        n        M\>        PD                  ! 4        \F        \>        n$        \        P$                  '       g   RR.\        n        \        R,          p\K        \        R,          ;'       g    ^4      p\>        PL                  ! Wx34       \N        PP                  ! Wx\S        4       4       \T        P4                  PW                  4        \T        P4                  PY                  RP[                  \        R,          \        R,          4      4       R	# V P]                  4        R	# )   rI   rJ   rK   r*   r   zBad cipher.zBad MAC.noneNr:   ^zBad escape character '%s'.L:   NN@zMissing host or username.r   z~/.ssh/id_rsaz~/.ssh/id_dsaz{}@{} - TkConch)/rI   rq   optionsrJ   rK   r*   r6   r9   r:   SSHClientTransportsupportedCipherstkMessageBox	showerrorsupportedMACslenchrordrL   	identitysappendrP   r>   ri   opt_localforwardopt_remoteforwardsplitrA   quitdestroyr[   stdoutr   startLoggingstderrdiscardLogshandleErrordeferrintmsgr   
connectTCPSSHClientFactoryframe	deiconifyrB   formatfocus)	r]   finishedr6   r9   r:   linerealoutrI   rJ   s	   &        r`   rX   TkConchMenu.doConnect   sF   ))--/))--/))--/!\\--/	"hhlln"+<<<7=h"3&&y-@(666475"0&&y*=$(!c!c&kQ&6$'F1I(;$<!V!$*!&&y2NQW2WX==$$T]]%6%6%89MM%%a5DAw#~((b2))$r(3	 6 '&/!/6v/D/DS!/L,GFOWV_wvH""9.IJH8KKKK!u~~**  ,$
!$CJ$$$%4o$F!6?Dwv,,"-DGGTL!t+;+=>LL""$LL!(('&/J JJLrb   )r6   r*   r:   rT   rS   rP   rI   rL   rV   rD   r9   rJ   rW   rK   N)__name__
__module____qualname____firstlineno__r@   rN   rQ   rR   rX   __static_attributes____classdictcell____classdict__s   @r`   r   r   &   s(     \;|1B)
F Frb   r   c                     a ] tR t^t oRt. RO. RO. RO. RO. RO. RO. RO. RO.t. RO. RO. RO. R O. R!O. R"O. R#O. R$O.t]P                  P                  t
]P                  P                  t]P                  ! R%.R]P                  ! ]
 U u. uF  q P!                  4       NK  	  up 4      R]P                  ! ] U u. uF  q P!                  4       NK  	  up 4      R]P"                  ! RR7      R]P"                  ! RR7      /]P$                  ! 4       ]P"                  ! R	R7      ]P"                  ! R
RR7      .R7      t. t. t. tR tR tR tR tR tV3R ltRtVtR# u up i u up i )&GeneralOptionsz,Usage:    tkconch [options] host [command]
 Nr6   macslocalforwardremoteforwardzlisten-port:host:port)descrr*   argumentT)r   repeat)mutuallyExclusive
optActionsextraActionsc                <    V P                   P                  V4       R # N)r   r   )r]   is   &&r`   opt_identityGeneralOptions.opt_identity  s    a rb   c                    VP                  R 4      w  r#p\        V4      p\        V4      pV P                  P                  W#V334       R# ro   N)r   r   localForwardsr   )r]   f	localPort
remoteHost
remotePorts   &&   r`   r   GeneralOptions.opt_localforward   sB    ,-GGCL)	z	N	_
!!9:.F"GHrb   c                    VP                  R 4      w  r#p\        V4      p\        V4      pV P                  P                  W#V334       R# r   )r   r   remoteForwardsr   )r]   r   r   connHostconnPorts   &&   r`   r    GeneralOptions.opt_remoteforward&  sB    )*&
h_
x=""J80D#EFrb   c                .    R .\         P                  R&   R# )zlib:re   ry   NN)r   supportedCompressionsr]   s   &r`   opt_compressGeneralOptions.opt_compress,  s    9?005rb   c                |    V'       d*   V^ ,          V R&   RP                  VR,          4      V R&   R# RV R&   RV R&   R# )re   rI    ry   NNr*    N)join)r]   r^   s   &*r`   	parseArgsGeneralOptions.parseArgs/  s:    7DL!hhtBx0DODL DOrb   c                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[S[S[S[S[3,          3,          ,          ;R&   S[ S[S[S[S[S[3,          3,          ,          ;R&   # )r}   r   r   r   )r   strr   r   )r   r   s   "r`   __annotate__GeneralOptions.__annotate__   sd     l Cym n c5c?2349o p sE#s(O345:q rb    )rK   lNzLog in using this user name.)rL   r   z~/.ssh/identityz&Identity for public key authentication)r:   e~z(Set escape character; ``none'' = disable)r6   cNzSelect encryption algorithm.)r   mNz.Specify MAC algorithms for protocol version 2.)rJ   pNz7Connect to this port.  Server must be on the same port.)r   r|   Nz<listen-port:host:port   Forward local port to remote address)r   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   )r   r   r   r   synopsisoptParametersoptFlagsr   r   r   _ciphersr   _macsr   CompletionsCompleteListdecode	CompleterCompleteUserAtHostcompDatar   r   r   r   r   r   r   r   __annotate_func__r   r   )r   r   s   0@r`   r   r      sb    H 	<VH=MV	
	
M, 	F080>K%=	H ++<<H((66E  +,e((h)Gh((*h)GHE&&E'BEq
E'BCEOO2IJU__3JK	
 $$&OO),OO*T:
H I79M8:N!IGA!Y  T *H'Bs   E:E!r   c                 
  aa \         P                  '       d   \        R 4      h\        P                  ! 4       o. pV3VV3R llpV\         n        \         P                  V 4       \         P                  P                  4        S# )zcan't ask 2 questions at once!c                   < V '       g   R # V R8X  d   \         P                  ! 4        V R8X  dF   \        P                  R4       RP	                  V4      p?R \        n        SP                  V4       R # ^ \        V 4      u;8:  d   ^8  d6   M M2VP                  V 4       S'       d   \        P                  V 4       R # R # \        V 4      ^8X  d:   V'       d0   S'       d   \        P                  R4       VP                  4        R # R # R # )Nz
r   z )	r   stopr   writer   callbackr   r   pop)chrespstrespdechos   && r`   gotChar!deferredAskFrame.<locals>.gotCharE  s    <LLN:KKWWT]F!ENJJv3r7 S KKOB W\dK(HHJ #\rb   )r   r   
ValueErrorr   Deferredr   canvasfocus_force)questionr  r  r  r  s   &f  @r`   deferredAskFramer  ?  s`    ~~~9::AD  * EN	KK	LLHrb   c            
         \         P                  R ,          p RV 9   d6   V P                  R4      pWV^,            V ,           p W^,           V^,           1 V R,           FM  p V P                  V4      pVR,          R8X  d+   W^,           ,          ^ ,          R8w  d   . WV^,           % KK  KM  KO  	  \        P
                  ! 4       pVP                  4        \        P                  ! 4       p\        V4      s	\        P                  \        P                  \        P                  ^R7       \        4       s \        P                  V 4       \        P+                  4        FU  w  rgV'       g   K  \-        \        V4      '       g   K'  \/        \        V4      P1                  \        P2                  V4       KW  	  \        P4                   F?  w  pw  r\        P6                  P1                  \        P2                  R	V R
V	 R
V
 24       KA  	  . \        n        \        P8                   F?  w  pw  r\        P6                  P1                  \        P2                  RV R
V	 R
V
 24       KA  	  . \        n        \:        P<                  ! VRR7      sVPA                  R\:        PB                  \>        PD                  ,          ^,           \:        PF                  \>        PH                  ,          ^,           3,          4       \>        P                  \        P                  R7       \J        PL                  ! V4       VP                  4        \        R,          '       d   \        R,          '       g   R\        R,          9   d   \        PO                  4        MVPQ                  4        \R        PT                  ! 4        \         P(                  ! \V        4       R#   \         d     EK  i ; i  \         P"                   dH   p\%        RT,          4       \        P'                  4        \         P(                  ! ^4        Rp?ELRp?ii ; i)r   z-l:NNN:Nr}   Nz-o-)sidefillexpandz	ERROR: %sNrn   ro   rp   )r   z%dx%d)r  rI   rK   r~   ),r[   argvindexr	  r>   TkwithdrawToplevelr   menupackTOPBOTHr   r   parseOptionsr   
UsageErrorprintopt_helpr\   itemshasattrgetattrrj   ri   r   rP   r   r   
VT100Framer   geometry	fontWidthr,   
fontHeightr+   r   installrX   mainloopr   run
exitStatus)r^   r   argroottopukr   r   rhrps              r`   r*  r*  `  s   88B<Dt|JJtA%QQAww	

3A2w$4A;q>S#8"$Q $9  ::<DMMO



CsDII7;;W\\!I<GT"
 1q!!D!##GKK3   ,,8BW[[Bqc2$at*<= -G--8BW[[Bqc2$at*<= .Gtd3EMMu{{*Q.0B0BU\\0QTU0U
V	W 
JJGKKJ dMMOGFOOwv0FKKMHHZI  		  kAos+   !AO2O! OO!P=6<P88P=c                      ^ RI Hp  ^s\        P                  ! V P                  4       4       \        P                  ! 4        h )re   failure)twisted.pythonr5  r+  r   errFailurer   r   r4  s    r`   r   r     s+    & JGGGOOLLN	rb   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )r   i  Tc                0    \         P                  ! 4        R # r   )r   r   r   s   &r`   stopFactorySSHClientFactory.stopFactory  s    rb   c                    \        4       # r   )r   )r]   addrs   &&r`   buildProtocolSSHClientFactory.buildProtocol  s    !##rb   c                h    \         P                  ! R RVP                   RVP                   24       R# )r   zConnection Failed, Reason:
 z: N)r   showwarningtyper2   )r]   	connectorreasons   &&&r`   clientConnectionFailed'SSHClientFactory.clientConnectionFailed  s+      +FKK=6<<.I	
rb   r   N)
r   r   r   r   noisyr;  r?  rF  r   r   r   s   @r`   r   r     s     E$
 
rb   r   c                   D   a  ] tR tRt o R tR tR tR tR tR t	Rt
V tR	# )
r   i  c                    R W3,          s R# )zDconch:	Remote side disconnected with error code %i
conch:	reason: %sN)r+  )r]   codedescs   &&&r`   receiveErrorSSHClientTransport.receiveError  s     Vl 	rb   c                Z    R W3,          s \        P                  P                  WV4       R# )z>conch:	Sending disconnect with error code %i
conch:	reason: %sN)r+  r   r   sendDisconnect)r]   rK  rE  s   &&&r`   rP  !SSHClientTransport.sendDisconnect  s/     Pn 	 	$$33DGrb   c                z    V'       g   \         R ,          '       d    \        P                  ! RV,          4       R# R# )r   zReceived Debug Message: %sN)r   r   r   )r]   alwaysDisplaymessagelangs   &&&&r`   receiveDebugSSHClientTransport.receiveDebug  s$    GENNGG07:; +rb   c                B   \        \        R ,          VRR/4      pV^8X  d   \        P                  ! ^4      # V^8X  d+   \        P                  ! \
        P                  ! R4      4      # \        R ,          V P                  P                  4       P                  8X  d   \        R ,          p\        R ,          pM~RP                  \        R ,          V P                  P                  4       P                  4      pRP                  \        R ,          V P                  P                  4       P                  4      p\        P                  ! V4      ^ ,          pRP                  VRRR	R
/V,          V4      pVR,          p\        V^4      P                  V P                  WV4      # )rI   zknown-hostsNbad host keyz{} ({})z{},{}zNThe authenticity of host '{}' can't be established.
{} key fingerprint is {}.   ssh-dssDSA   ssh-rsaRSAz9
Are you sure you want to continue connecting (yes/no)? )r   r   r   succeedfailr   
ConchErrorr   getPeerrI   r   r   getNSr  addCallback_cbVerifyHostKey)r]   pubKeyfingerprintgoodKeyrI   khHostkeyTypequess   &&&     r`   verifyHostKey SSHClientTransport.verifyHostKey  sE   
 !&=$:OPa<==##\::e..~>??v$.."8"8":"?"??v  ''9O9O9Q9V9VW 9O9O9Q9V9VWll6*1-G#VUJ6w?  QQD#D!,88%%vw rb   c           
        VP                  4       R9  d(   \        R^4      P                  V P                  W#V4      # VP                  4       R8X  d,   \        P                  R4       \        P                  ! R4      h \        P                  RV: RRRR	R
/V,          : R24       \        \        P                  P                  R4      R4      ;_uu_ 4       p\        P                  ! V4      pVP                  RV RV RV 24       RRR4       R#   + '       g   i     R# ; i  \         d'    \        P                   ! 4        \        P                  hi ; i)yesnozPlease type  'yes' or 'no': zHost key verification failed.
rY  zWarning: Permanently added 'z' (rZ  r[  r\  r]  z) to the list of known hosts.
z~/.ssh/known_hostsr   
r   N)rn  ro  )lowerr  rc  rd  r   r   r   r`  openospath
expanduserbase64	b64encodeBaseExceptionr   r   )r]   ansre  rh  ri  known_hosts
encodedKeys   &&&&&  r`   rd  #SSHClientTransport._cbVerifyHostKey  s   99;m+#$BAFRR%%vw  99;$KK;<"">22	#KK Jz5A'JJL
 bgg(()=>DD#--f5
!!Bvhay*"FG EDDD  	#JJL"""	#s+   >AD' 1D	D' D$	D' $D' '1Ec                    \         R ,          '       d   \         R ,          pM\        P                  ! 4       pV P                  \	        V\        4       4      4       R# )rK   N)r   getpassgetuserrequestServiceSSHUserAuthClientSSHConnection)r]   rK   s   & r`   connectionSecure#SSHClientTransport.connectionSecure  s8    6??6?D??$D-dMODErb   r   N)r   r   r   r   rM  rP  rV  rk  rd  r  r   r   r   s   @r`   r   r     s+     
H<
:#*F Frb   r   c                   L   a  ] tR tRt o . tR	R ltR tR tR tV 3R lt	Rt
V tR# )
r  i  Nc                x    V'       g(   R P                  V P                  \        R,          4      p\        V^ 4      # )z{}@{}'s password: rI   )r   rK   r   r  )r]   prompts   &&r`   getPasswordSSHUserAuthClient.getPassword  s,    )00GFOLF**rb   c                2   \         P                   Uu. uF  qV P                  9  g   K  VNK  	  ppV'       g   R # V^ ,          p\        P                  ! V4       V P                  P                  V4       \        P                  P                  V4      pVR,          p\        P                  P                  V4      '       g   R #  \        P                  P                  V4      P                  4       # u upi   \         d    T P                  4       u # i ; i)Nz.pub)r   r   	usedFilesr   r   r   rs  rt  ru  existsr
   KeyfromFileblobrx  getPublicKey)r]   xfilesfiles   &   r`   r  SSHUserAuthClient.getPublicKey  s    #--I-q$..1H-IQxd#ww!!$'ww~~d##	'88$$T*//11 J  	'$$&&	's   C3C3,C8 8DDc                ,   \         P                  P                  V P                  R,          4      p\         P                  P	                  V4      '       g   R#  \
        P                  ! \        P                  P                  V4      P                  4      #   \        P                   di   pTP                  ^ ,          R8X  dF   RT P                  R,          ,          p\        T^ 4      P                  T P                  ^ 4      u Rp?#  Rp?R# Rp?ii ; i)ry   Nzencrypted key with no passwordEnter passphrase for key '%s': )rs  rt  ru  r  r  r   r^  r
   r  r  	keyObjectBadKeyErrorr^   r  rc  _cbGetPrivateKey)r]   r  r   r  s   &   r`   getPrivateKeySSHUserAuthClient.getPrivateKey  s    ww!!$.."45ww~~d##	Y==!2!24!8!B!BCC 	Yvvay<<:T^^B=OO'2>>t?T?TVWXX =	Ys   <B D+ADDDc                   \         P                  P                  V P                  R,          4      p \        P
                  P                  W1R7      P                  #   \        P                   dS    T^8X  d   h RT P                  R,          ,          p\        T^ 4      P                  T P                  T^,           4      u # i ; i)ry   )passwordr  r  )rs  rt  ru  r  r
   r  r  r  r  r  rc  r  )r]   ry  countr  r  s   &&&  r`   r  "SSHUserAuthClient._cbGetPrivateKey  s    ww!!$.."45	88$$T$8BBB 	z69KKF#FA.::%%uqy 		s   )A A$CCc                6   < V ^8  d   Qh/ S[ S[,          ;R&   # )r}   r  )r   r   )r   r   s   "r`   r   SSHUserAuthClient.__annotate__  s     Cy rb   r   r   )r   r   r   r   r  r  r  r  r  r   r   r   r   s   @r`   r  r    s'     I+
' 	Y
G  rb   r  c                   &   a  ] tR tRt o R tRtV tR# )r  i,  c           	     L   \         R ,          '       g   V P                  \        4       4       \         P                  '       dT   \         P                   F?  w  r\        P
                  ! V\        P                  ! W\        P                  4      4       KA  	  \         P                  '       dy   \         P                   Fb  w  r2\        P                  ! RP                  W24      4       \        P                  ! RV34      pV P                  RV4       W P                  V&   Kd  	  R# R# )r   z&asking for remote forwarding for {}:{}z0.0.0.0ztcpip-forwardN)r   openChannel
SSHSessionr   r   	listenTCPr	   SSHListenForwardingFactory SSHListenClientForwardingChannelr   r   r   r   packGlobal_tcpip_forwardsendGlobalRequest)r]   r   hostportr   datas   &    r`   serviceStartedSSHConnection.serviceStarted-  s    y!!Z\*   '.'<'<#	!!99
(S(S (= !!!(/(>(>$
<CC"
 "::Iz;RS&&=2:##J/ )? "rb   r   N)r   r   r   r   r  r   r   r   s   @r`   r  r  ,  s     ; ;rb   r  c                   T   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tRtV tR# )r  iD  s   sessionc                   ^V n         \        P                  ! 4       p\        R,          '       d   V P                  Vn        MV P                  Vn        V P                  Vn        VP
                  \        n
        \        P                  P                  4        \        R,          '       d?   V P                  P                  V R\        P                   ! \        R,          4      4       EM?\        R,          '       d   \        R,          '       dW   \"        P$                  P'                  RR4      pRp\        P(                  ! W4R4      pV P                  P                  V R	V4       V P                  P                  V R
\        P                   ! \        R,          4      4       M\        R,          '       gW   \"        P$                  P'                  RR4      pRp\        P(                  ! W4R4      pV P                  P                  V R	V4       V P                  P                  V RR4       V P                  P*                  P*                  P-                  ^4       R# )ry   r:   r   s	   subsystemr*   r   TERMxtermr   s   pty-reqexecr   s   shellrb   N)   P   re   re   )
escapeModer   SSHSessionClientr   handleInputdataReceivedr   sendEOFconnectionLostr   r   r  r  connsendRequestr   NSrs  environrq   packRequest_pty_reqr   setTcpNoDelay)r]   foor   termwinSize
ptyReqDatas   &&    r`   channelOpenSSHSession.channelOpenG  s    $$&8!--AN!ZZAN<<  ";II!!$fii	@R6STYu~~zz~~fg6($88K
		%%dJ
CII!!$		'):L0MN7##zz~~fg6($88K
		%%dJ
CII!!$#6		%%33A6rb   c                   VR	9   d   ^V n         V P                  V4       R# V P                   ^8X  d   V\        R,          8X  d
   ^V n         R# V P                   ^8X  d   ^V n         VR8X  d.   \        P                  ! R4       \
        P                  ! 4        R# VR8X  d;   \        P                  ! \        P                  ! 4       \        P                  4       R# VR8X  d=   \        P                  ! R4       V P                  P                  P                  4        R# V P                  RV,           4       R# ^ V n         V P                  V4       R# )
rp  r:   .zdisconnecting from escapeNr   zrekeying connectionr   )rp  r   )r  r   r   r   r   r   r   rs  killgetpidsignalSIGSTOPr  r   sendKexInit)r]   chars   &&r`   r  SSHSession.handleInputh  s    <DOJJt__!dgh.?&?DO__!DOs{34		V^^4-.		##//1JJsTz"DOJJtrb   c                    VP                  R 4      p\        R,          '       d   \        \        V4      4       \        P                  V4       R# )zutf-8r   N)r   r   r  reprr   r   r]   r  s   &&r`   r  SSHSession.dataReceived  s3    {{7#9$t*Drb   c                    V\         P                  8X  df   \        P                  ! R \	        V4      ,          4       \
        P                  P                  V4       \
        P                  P                  4        R# R# )zgot %s stderr dataN)	r   EXTENDED_DATA_STDERRr   r   r   r[   r   r   flush)r]   r   r  s   &&&r`   extReceivedSSHSession.extReceived  sM    
///GG(3t945JJT"JJ 0rb   c                n    \         P                  ! R 4       \        P                  P	                  4        R# )zgot eofN)r   r   r[   stdincloser   s   &r`   eofReceivedSSHSession.eofReceived  s    			rb   c                    \         P                  ! R V ,          4       \        V P                  P                  4      ^8X  d   \
        P                  ! 4        R# R# )z	closed %sN)r   r   r   r  channelsr   r   r   s   &r`   closedSSHSession.closed  s8    d"#tyy!!"a'LLN (rb   c                    \        \        P                  ! R V4      ^ ,          4      s\        P
                  ! R\        ,          4       R# )z>Lzexit status: %sN)r   structunpackr+  r   r   r  s   &&r`   request_exit_statusSSHSession.request_exit_status  s.    tT2156
!J./rb   c                <    V P                   P                  V 4       R # r   )r  r  r   s   &r`   r  SSHSession.sendEOF  s    		$rb   )r  N)r   r   r   r   r7   r  r  r  r  r  r  r  r  r   r   r   s   @r`   r  r  D  s8     D7B4
0
   rb   r  __main__)<__doc__rv  r~  rs  r  r  r[   tkinterr>   tkinter.filedialog
filedialogrf   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   r6  r   r   r?   r   Optionsr   r   r  r+  r   r  r*  r   ClientFactoryr   r   r  r  
SSHChannelr  r   r   rb   r`   <module>r     s  

   	   
  ) )   7	 	 	 % @ @ %z'-- zzR!U]] R!l 
B0f

x-- 
 LF55 LF^-22 -`;J,, ;0Y ## Y x zE rb   