;ņ = ÄDc@sŒdkZdkZdklZlZdklZdklZdk l Z l Z dk l Z dklZlZlZlZlZdklZlZdklZd Zd Zd ieed d gƒƒZd ieedddgƒƒZde ifd„ƒYZ de!fd„ƒYZ"dei#fd„ƒYZ$dei%fd„ƒYZ&dei'fd„ƒYZ(defd„ƒYZ)d„Z*dS(N(savatars credentials(sRSA(s components(sreactorsprotocol(sSSHPublicKeyDatabase(sfactorysuserauths connectionskeysssession(scommonschannel(s BasePlugins s sii[ii s SBProtocolcBsĪtZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zdd„Zd„ZRS(s' the protocol that gets wrapped in SSH cCs d|_|ii|iƒdS(s called on connection sN(sselfsrbufscbs authorisedsuser(sself((s./Gateway/gwssh.pysconnectionMade6s cCs|iii|iƒdS(s Called on loss of connection. N(sselfscbs _connectionssremovesuser(sselfsreason((s./Gateway/gwssh.pysconnectionLost;scCs|iiƒdS(N(sselfs transportsloseConnection(sself((s./Gateway/gwssh.pysloseConnection@scCsP|i|ƒt|iƒ}|o)|djo|iƒqL|iƒndS(s called on receipt of data iN(sselfs _processdatasdataslensrbufsrlsloseConnections_processreadbuf(sselfsdatasrl((s./Gateway/gwssh.pys dataReceivedCs  cCs\xU|D]M}t|ƒ}d|}t||ƒot||ƒƒq|i|ƒqWdS(s- Process individual characters in the stream s_receivedchr_%sN( sdatascsordsccsdonameshasattrsselfsgetattrs_receivedchr_general(sselfsdatascsccsdoname((s./Gateway/gwssh.pys _processdataOs  cCs^|iitƒ}t|ƒdjo5d|_|iƒx|D]}|i|ƒq?WndS(Nis( sselfsrbufssplitsRNLslinesslenspopsls _linereceived(sselfslinessl((s./Gateway/gwssh.pys_processreadbuf\s  cCs8t|ƒo'|iii||iƒ|iƒndS(s Received a line of data N(slenscmdsselfscbsreceivedCommandsusers write_prompt(sselfscmd((s./Gateway/gwssh.pys _linereceivedgs cCs'd|i|f|_|i|ƒdS(s Handle all other keys s%s%sN(sselfsrbufscswrite(sselfsc((s./Gateway/gwssh.pys_receivedchr_generalnscCs'|iitƒd|_|iƒdS(s Control-C handler sN(sselfs transportswritesSNLsrbufs write_prompt(sself((s./Gateway/gwssh.pys_receivedchr_3ts cCs|idƒdS(s Control-D handler slogoutN(sselfs _linereceived(sself((s./Gateway/gwssh.pys_receivedchr_4{scCs'|itƒd|itf|_dS(s Return key handler s%s%sN(sselfswritesSNLsrbufsRNL(sself((s./Gateway/gwssh.pys_receivedchr_13€s cCs d|itdƒf|_dS(Ns%s%si(sselfsrbufschr(sself((s./Gateway/gwssh.pys_receivedchr_27‡scCsP|iitdƒƒo d|itdƒf|_n|itdƒƒdS(Nis%s%si[(sselfsrbufsendswithschrs_receivedchr_general(sself((s./Gateway/gwssh.pys_receivedchr_91Šs cCs>|iitƒo|id |_n|itdƒƒdS(s Up key handler iž’’’iAN(sselfsrbufsendswithsESCs_receivedchr_generalschr(sself((s./Gateway/gwssh.pys_receivedchr_65scCs>|iitƒo|id |_n|itdƒƒdS(s Down key handler iž’’’iBN(sselfsrbufsendswithsESCs_receivedchr_generalschr(sself((s./Gateway/gwssh.pys_receivedchr_66—scCs>|iitƒo|id |_n|itdƒƒdS(s Left key handler iž’’’iCN(sselfsrbufsendswithsESCs_receivedchr_generalschr(sself((s./Gateway/gwssh.pys_receivedchr_67žscCs>|iitƒo|id |_n|itdƒƒdS(s Left key handler iž’’’iDN(sselfsrbufsendswithsESCs_receivedchr_generalschr(sself((s./Gateway/gwssh.pys_receivedchr_68„scCs;t|iƒdjo!|itƒ|id |_ndS(s backspace handler ii’’’’N(slensselfsrbufswritesBS(sself((s./Gateway/gwssh.pys_receivedchr_127¬s cCstid|ii|ƒdS(Ni(sreactors callLatersselfs transportswritesmsg(sselfsmsg((s./Gateway/gwssh.pyswrite²sscCs|id|ƒ|iƒdS(Ns%s (sselfswritesmsgs write_prompt(sselfsmsg((s./Gateway/gwssh.pys write_replyµscCs6|id|iii|iiiƒ|ifƒdS(Ns %s@%s: $ %s(sselfswritesusersnamescbsgetNicksrbuf(sself((s./Gateway/gwssh.pys write_prompt¹s(s__name__s __module__s__doc__sconnectionMadesconnectionLostsloseConnections dataReceiveds _processdatas_processreadbufs _linereceiveds_receivedchr_generals_receivedchr_3s_receivedchr_4s_receivedchr_13s_receivedchr_27s_receivedchr_91s_receivedchr_65s_receivedchr_66s_receivedchr_67s_receivedchr_68s_receivedchr_127swrites write_replys write_prompt(((s./Gateway/gwssh.pys SBProtocol4s,                  sSshTunnelSessioncBs;tZeZd„Zd„Zd„Zd„Zd„ZRS(NcCs6|i|_||_|iiiid|iƒdS(Ns%s(savatarscbsselfslogscriticals __class__(sselfsavatar((s./Gateway/gwssh.pys__init__Ąs  cCsdS(N((sselfsterms windowSizesattrs((s./Gateway/gwssh.pysgetPtyÅscCs|iiƒdS(N(sselfsepsloseConnection(sself((s./Gateway/gwssh.pysclosedČscCsdS(N((sselfsprotoscmd((s./Gateway/gwssh.pys execCommandĖscCs‡|iƒ|_|i|i_|i|i_|i|i_|iiiii ƒ|i_ |ii |ƒ|i t i|iƒƒdS(s( called back on a successful connection N(sselfs WRAPPROTOCOLsepsavatarsconsuserscbsconns transportsgetPeerspeersmakeConnectionstransssessions wrapProtocol(sselfstrans((s./Gateway/gwssh.pys openShellĪs( s__name__s __module__s SBProtocols WRAPPROTOCOLs__init__sgetPtyscloseds execCommands openShell(((s./Gateway/gwssh.pysSshTunnelSession½s    s ShellSessioncBstZeZdZd„ZRS(NssessioncOs8tii|||Žd|_|i|iƒ|_ dS(Ns( schannels SSHChannels__init__sselfsargsskwsbufsISESSIONsavatarssession(sselfsargsskw((s./Gateway/gwssh.pys__init__ās (s__name__s __module__sSshTunnelSessionsISESSIONsnames__init__(((s./Gateway/gwssh.pys ShellSessionßss ShellUsercBs2tZeZd„Zd„Zd„Zd„ZRS(NcCs)tii|ƒ||_|i|_dS(N(savatars ConchUsers__init__sselfsusersgwhmshostmask(sselfsuser((s./Gateway/gwssh.pys__init__és c Cs&|id|d|d|d|ƒSdS(Ns remoteWindowsremoteMaxPacketsdatasavatar(sselfs SESSIONCLASSs windowSizes maxPacketsdata(sselfs channelTypes windowSizes maxPacketsdata((s./Gateway/gwssh.pys lookupChannelļs cKs|iid||fƒdS(Ns [%s] %s(sselfscons write_replysinreplysreply(sselfsreplysinreplyskw((s./Gateway/gwssh.pys sendReplyōscCs|iiƒ|iiƒdS(N(sselfsusers clearAuthsconsloseConnection(sself((s./Gateway/gwssh.pysclose÷s (s__name__s __module__s ShellSessions SESSIONCLASSs__init__s lookupChannels sendReplysclose(((s./Gateway/gwssh.pys ShellUserēs    sSBSSHUserAuthServercBs tZeZd„Zd„ZRS(NcCspti|dƒd}tii|i|ƒ}|i i i ƒi |_ |i i|t|iƒi|iƒSdS(Nii(suserauthsgetNSspacketspasswords credentialssUsernamePasswordsselfsuserscs transportsgetPeershostspeersportalsloginsNones USERCLASSs addErrbacks _ebPassword(sselfspacketscspassword((s./Gateway/gwssh.pys auth_passwordżsc Cs;ti} t|dƒ}ti|ddƒ\}}}ti i d|ƒ} | |i iƒttiƒ| |iƒ| |iƒ| dƒt|ƒ| t i| ƒƒ| |ƒ}|oti|ƒdpt}ti|i|||ƒ}|i i iƒi|_|ii|t|iƒi |i!|dƒSdS(Niiisdatas publickey("suserauthsNSsordspacketshasSigsgetNSsalgNamesblobsrestskeyssgetPublicKeyObjectspubKeysselfs transports sessionIDschrsMSG_USERAUTH_REQUESTsusers nextServices objectTypesbsNones signatures credentialss SSHPrivateKeyscsgetPeershostspeersportalslogins USERCLASSs addErrbacks _ebCheckKey( sselfspacketsbsrestshasSigs signaturescsblobsalgNamesNSspubKey((s./Gateway/gwssh.pysauth_publickeys j!!(s__name__s __module__s ShellUsers USERCLASSs auth_passwordsauth_publickey(((s./Gateway/gwssh.pysSBSSHUserAuthServerūs sShellGWcBsNtZeZeZdZdZeZ gZ d„Z de i fd„ƒYZRS(Ni>#ssshcCsĪti|ƒ|iid}d|ti|idƒf}ti i |ƒ o t d‚nd|}ti i |ƒ o t d‚nhdtid|ƒ<|i_hdtid|ƒ<|i_dS( Nskeys.sshs%s%s%sskeys.rsaKeyFilesThe SSH private key is missings%s.pubsThe SSH public key is missingsssh-rsasfilename(s BasePluginsfactoryPreinitsselfscbs datapathsssshdirsosssepsmainRegistryValueskeypathspathsexistss ExceptionspubpathskeyssgetPublicKeyStrings FactoryClasss publicKeyssgetPrivateKeyObjects privateKeys(sselfssshdirspubpathskeypath((s./Gateway/gwssh.pysfactoryPreinits    !s FactoryClasscBs>tZhde<deiKsiN(sselfs primesKeysssortsbitssrealBitssrandomschoicesprimes(sselfsbitssrealBits((s./Gateway/gwssh.pys getDHPrimeCs cCsatiiƒ}|iiƒ|_|i o$|i }|i dƒ||_ n||_|SdS(Ns"diffie-hellman-group-exchange-sha1( sfactorys transportsSSHServerTransportstsselfs privateKeysskeysssupportedPublicKeyssprimesssupportedKeyExchangessskesremove(sselfsaddrsskest((s./Gateway/gwssh.pys buildProtocolOs     ( s__name__s __module__sSBSSHUserAuthServers connections SSHConnectionsservicess startFactorys getDHPrimes buildProtocol(((s./Gateway/gwssh.pys FactoryClass)s  (s__name__s __module__sTrues PORTALISEs ShellUsers USERCLASSs DEFAULT_PORTsPROTOCOLsFalsesUSESSLs CONFIG_EXTRAsfactoryPreinitsfactorys SSHFactorys FactoryClass(((s./Gateway/gwssh.pysShellGWs cCsštidtiiƒ}ti|ƒ}t |dƒ}|i |ƒ|i ƒti|dƒti|ƒ}t d|dƒ}|i |ƒ|i ƒdS(Niswi€s%s.pub(sRSAsgeneratescommonsentropys get_bytesskeyskeyssmakePrivateKeyStringsprivksopensfilepathsprivfswritesclosesosschmodsmakePublicKeyStringspubkspubf(sfilepathspubfspubksprivfskeysprivk((s./Gateway/gwssh.pyskeygenYs   (+sossmd5s twisted.conchsavatars credentialssCrypto.PublicKeysRSAstwisted.pythons componentsstwisted.internetsreactorsprotocolstwisted.conch.checkerssSSHPublicKeyDatabasestwisted.conch.sshsfactorysuserauths connectionskeysssessionscommonschannelsgwbases BasePluginsRNLsSNLsjoinsmapschrsESCsBSsProtocols SBProtocolsobjectsSshTunnelSessions SSHSessions ShellSessions ConchUsers ShellUsersSSHUserAuthServersSBSSHUserAuthServersShellGWskeygen(sprotocolsreactorsBSsShellGWssessionsuserauths ShellUsersSBSSHUserAuthServersfactoryschannelsavatarsSSHPublicKeyDatabaseskeyss ShellSessionsESCs credentialssmd5s BasePluginsRNLsSshTunnelSessions SBProtocolsSNLsRSAskeygens connectionscommons componentssos((s./Gateway/gwssh.pys?s(     % !‰"G