python (3.11.7)

(root)/
lib/
python3.11/
__pycache__/
telnetlib.cpython-311.pyc

e[dZddlZddlZddlZddlmZddlZeje	ddgZ
dZdZe
dgZe
d	gZe
d
gZe
dgZe
dgZe
dgZe
d
gZe
dgZe
dgZe
dgZe
dgZe
dgZe
dgZe
dgZe
dgZe
dgZe
dgZe
dgZe
dgZ e
dgZ!e
dgZ"e
dgZ#e
dgZ$e
dgZ%e
dgZ&e
dgZ'e
d gZ(e
d!gZ)e
d"gZ*e
d#gZ+e
d$gZ,e
d%gZ-e
d&gZ.e
d'gZ/e
d(gZ0e
d)gZ1e
d*gZ2e
d+gZ3e
d,gZ4e
d-gZ5e
dgZ6e
d.gZ7e
d/gZ8e
d0gZ9e
d1gZ:e
d2gZ;e
d3gZ<e
d4gZ=e
d5gZ>e
d6gZ?e
d7gZ@e
d8gZAe
d9gZBe
d:gZCe
d;gZDe
d<gZEe
d=gZFe
d>gZGe
d?gZHe
d@gZIe
dAgZJe
dBgZKe
dCgZLe
dDgZMe
dEgZNe
dFgZOe
dGgZPe
dHgZQe
dIgZRe
dJgZSe
dgZTe
dgZUeVedKrejWZXnejYZXGdLdZZdMZ[e	dNkre[dSdS)OaQTELNET client class.

Based on RFC 854: TELNET Protocol Specification, by J. Postel and
J. Reynolds

Example:

>>> from telnetlib import Telnet
>>> tn = Telnet('www.python.org', 79)   # connect to finger port
>>> tn.write(b'guido\r\n')
>>> print(tn.read_all())
Login       Name               TTY         Idle    When    Where
guido    Guido van Rossum      pts/2        <Dec  2 11:10> snag.cnri.reston..

>>>

Note that read_all() won't read until eof -- it just reads some data
-- but it guarantees to read at least one byte unless EOF is hit.

It is possible to pass a Telnet object to a selector in order to wait until
more data is available.  Note that in this case, read_eager() may return b''
even if there was data on the socket, because the protocol negotiation may have
eaten the data.  This is why EOFError is needed in some cases to distinguish
between "no data" and "connection closed" (since the socket also appears ready
for reading when it is closed).

To do:
- option negotiation
- timeout should be intrinsic to the connection object instead of an
  option on one of the read calls only

N)	monotonic)
)removeTelnetr	
r !"#$%&'()*+,-./01PollSelectorceZdZdZddejfdZdejfdZdZdZ	dZ
d	Zd
ZdZ
dZd d
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd dZdZ dZ!dS)!raTelnet interface class.

    An instance of this class represents a connection to a telnet
    server.  The instance is initially not connected; the open()
    method must be used to establish a connection.  Alternatively, the
    host name and optional port number can be passed to the
    constructor, too.

    Don't try to reopen an already connected instance.

    This class has many read_*() methods.  Note that some of them
    raise EOFError when the end of the connection is read, because
    they can return an empty string for other reasons.  See the
    individual doc strings.

    read_until(expected, [timeout])
        Read until the expected string has been seen, or a timeout is
        hit (default is no timeout); may block.

    read_all()
        Read all data until EOF; may block.

    read_some()
        Read at least one byte or EOF; may block.

    read_very_eager()
        Read all data available already queued or on the socket,
        without blocking.

    read_eager()
        Read either data already queued or some data available on the
        socket, without blocking.

    read_lazy()
        Read all data in the raw queue (processing it first), without
        doing any socket I/O.

    read_very_lazy()
        Reads all data in the cooked queue, without doing any socket
        I/O.

    read_sb_data()
        Reads available data between SB ... SE sequence. Don't block.

    set_option_negotiation_callback(callback)
        Each time a telnet option is read on the input flow, this callback
        (if set) is called with the following parameters :
        callback(telnet socket, command, option)
            option will be chr(0) when there is no option.
        No other action is done afterwards by telnetlib.

    Nrct|_||_||_||_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
|||||dSdS)zConstructor.

        When called without arguments, create an unconnected instance.
        With a hostname argument, it connects the instance; port number
        and timeout are optional.
        Nr)
DEBUGLEVEL
debuglevelhostporttimeoutsockrawqirawqcookedqeofiacseqsbsbdataqoption_callbackopenselfrPrQrRs    =/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/telnetlib.py__init__zTelnet.__init__s%				
#IIdD'*****rMcd|_|st}||_||_||_tjd|||tj||f||_	dS)zConnect to a host.

        The optional second argument is the port number, which
        defaults to the standard telnet port (23).

        Don't try to reopen an already connected instance.
        rztelnetlib.Telnet.openN)
rWTELNET_PORTrPrQrRsysauditsocketcreate_connectionrSr]s    r_r\zTelnet.opens`	D			)4t<<<,dD\7CC			rMc.|dS)z#Destructor -- close the connection.Ncloser^s r___del__zTelnet.__del__s

rMc|jdkrItd|jd|jdd|rt||zdSt|dSdS)zPrint a debug message, when the debug level is > 0.

        If extra arguments are present, they are substituted in the
        message using the standard string formatting operator.

        rzTelnet(,z): )endN)rOprintrPrQ)r^msgargss   r_rqz
Telnet.msgsn?QEdiii;EEEE
cDj!!!!!c




rMc||_dS)zhSet the debug level.

        The higher it is, the more debug output you get (on sys.stdout).

        N)rO)r^rOs  r_set_debuglevelzTelnet.set_debuglevels%rMc||j}d|_d|_d|_d|_|r|dSdS)zClose the connection.NTrMr)rSrWrXrYri)r^rSs  r_rizTelnet.close
sHy		JJLLLLL		rMc|jS)z)Return the socket object used internally.)rSrjs r_
get_socketzTelnet.get_sockets
yrMc4|jS)z9Return the fileno() of the socket object used internally.)rSfilenorjs r_ryz
Telnet.filenosy!!!rMct|vr(|tttz}tjd|||d||j|dS)zWrite a string to the socket, doubling any IAC characters.

        Can block if the connection is blocked.  May raise
        OSError if the connection is closed.

        ztelnetlib.Telnet.writezsend %rN)IACreplacercrdrqrSsendall)r^buffers  r_writezTelnet.writesi&==^^CS11F	*D&999F###	&!!!!!rMcxt|}||j|}|dkr*||z}|jd|}|j|d|_|S|t	|z}t5}||tj|j	s|
|rtdt|j|z
}|||j||}|dkr6||z}|jd|}|j|d|_|cdddS||t	z
}|dkrn|j	dddn#1swxYwY|
S)aRead until a given string is encountered or until timeout.

        When no match is found, return whatever is available instead,
        possibly the empty string.  Raise EOFError if the connection
        is closed and no cooked data is available.

        rN)lenprocess_rawqrVfind_time_TelnetSelectorregister	selectors
EVENT_READrWselectmax	fill_rawqread_very_lazy)r^matchrRnibufdeadlineselectors        r_
read_untilzTelnet.read_until)s
JJLe$$66!A,rr"C<+DLJww(H


	(dI$8999h
??7++	#As4<00233ANN$$$%%'''))%33AAvvaC"l2A2.'+|ABB'7"								&&0G{{h
															"""$$$sCF0!FF!$F!c||js/|||j/|j}d|_|S)z7Read all data until EOF; block until connection closed.rM)rrWrrVr^rs  r_read_allzTelnet.read_allNsa(	 NN(	 l
rMc||js=|js6|||js|j6|j}d|_|S)zRead at least one byte of cooked data unless EOF is hit.

        Return b'' if EOF is hit.  Block if no data is immediately
        available.

        rM)rrVrWrrs  r_	read_somezTelnet.read_someXsu	
,	 tx	 NN,	 tx	 l
rMc||jsW|rC|||js|C|S)aRead everything that's possible without blocking in I/O (eager).

        Raise EOFError if connection closed and no cooked data
        available.  Return b'' if no cooked data available otherwise.
        Don't block unless in the midst of an IAC sequence.

        )rrW
sock_availrrrjs r_read_very_eagerzTelnet.read_very_eagergs	
(	 t00	 NN(	 t00	 ""$$$rMc*||jse|js^|rJ|||js|js|J|S)zRead readily available data.

        Raise EOFError if connection closed and no cooked data
        available.  Return b'' if no cooked data available otherwise.
        Don't block unless in the midst of an IAC sequence.

        )rrVrWrrrrjs r_
read_eagerzTelnet.read_eagerus	
,	 tx	 DOO4E4E	 NN,	 tx	 DOO4E4E	 ""$$$rMcR||S)aProcess and return data that's already in the queues (lazy).

        Raise EOFError if connection closed and no data available.
        Return b'' if no cooked data available otherwise.  Don't block
        unless in the midst of an IAC sequence.

        )rrrjs r_	read_lazyzTelnet.read_lazys(	
""$$$rMc`|j}d|_|s|jr|jstd|S)zReturn any data available in the cooked queue (very lazy).

        Raise EOFError if connection closed and no data available.
        Return b'' if no cooked data available otherwise.  Don't block.

        rMztelnet connection closed)rVrWrTEOFErrorrs  r_rzTelnet.read_very_lazys@l	7tx	7		75666
rMc"|j}d|_|S)aReturn any data available in the SB ... SE queue.

        Return b'' if no SB ... SE available. Should only be called
        after seeing a SB or SE command. When a new SB command is
        found, old unread SB data will be discarded. Don't block.

        rM)rZrs  r_read_sb_datazTelnet.read_sb_datasl
rMc||_dS)zIProvide a callback function called after each receipt of a telnet option.N)r[)r^callbacks  r_set_option_negotiation_callbackz&Telnet.set_option_negotiation_callbacks'rMc:ddg}	|jr|}|jsI|tkr/|dkr6|tkr||j|z||j<Z|xj|z
c_nXt
|jdkr|ttttfvr|xj|z
c_d|_|tkr||j|z||j<n|tkrd|_d|_n,|tkr!d|_|j|dz|_d|d<|jr#||j|t nw|dt%|znPt
|jdkr7|jdd}d|_|}|ttfvr|d|tkrdpd	t%||jr||j||n|jttz|zn|ttfvr|d|tkrd
pdt%||jr||j||n*|jttz|z|jn#t($rd|_d|_YnwxYw|j|dz|_|j|dz|_dS)
zTransfer from raw queue to cooked queue.

        Set self.eof when connection is closed.  Don't block unless in
        the midst of an IAC sequence.

        rMrrzIAC %d not recognizedrz	IAC %s %dDODONTWILLWONTN)rTrawq_getcharrXtheNULLr{rYrrrrrSBrZSEr[rSNOOPTrqordr}rrV)r^rccmdopts     r_rzTelnet.process_rawqs.Cj;	)7
@%%''{5@G|| G|| Cxx'*47|a'7DG q(%%**RtT222q( "%DKCxx'*47|a'7DG77&'DG+.DLL"WW&'DG+/<#a&+@DL%(CF/G!00AuEEEE
!HH%<s1vv%EFFFF%%**+ac*C"%DKCr4j((2I.$8&#c((DDD/@ 00CEEEE I--cDj3.>????t,,4K2F<fc#hhHHH/@ 00CEEEE I--cDj3.>???o)7
@p			DKDGGG	|c!f,|c!f,sKKK.-K.c|js"||jrt|j|j|jdz}|jdz|_|jt|jkrd|_d|_|S)zGet next char from raw queue.

        Block if no data is immediately available.  Raise EOFError
        when connection is closed.

        rrMr)rTrrWrrUr)r^rs  r_rzTelnet.rawq_getchars{y	NNx
IdjA-.Z!^
:TY''DIDJrMc|jt|jkrd|_d|_|jd}|d|||_|j|z|_dS)zFill raw queue from exactly one recv() system call.

        Block if no data is immediately available.  Set self.eof when
        connection is closed.

        rMr2zrecv %rN)rUrrTrSrecvrqrWrs  r_rzTelnet.fill_rawqsj:TY''DIDJinnR  C   GIO			rMct5}||tjt	|dcdddS#1swxYwYdS)z-Test whether data is available on the socket.rN)rrrrboolr)r^rs  r_rzTelnet.sock_avails


	,(dI$8999**++	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,sAAA"%A"cftjdkr|dSt5}||t
j|tjt
j	|D]
\}}|j	|ur	|
}n,#t$rtdYddddSwxYw|rPtj
|dtj
|j	tjurVtjd}|sddddS||%#1swxYwYdS)z9Interaction function, emulates a very dumb telnet client.win32NT(*** Connection closed by remote host ***ascii)rcplatformmt_interactrrrrstdinrfileobjrrrpstdoutrdecodeflushreadlineencode)r^rkeyeventstextlines      r_interactzTelnet.interacts<7""F


	)(dI$8999ci)=>>>
)#+??#4#4))KC{d**##'??#4#4DD'###!"LMMM"F	)	)	)	)	)	)	)	)# /J,,T[[-A-ABBBJ,,...	11"y1133::7CC##"%	)	)	)	)	)	)	)	)&

4(((
)		)	)	)	)	)	)	)	)	)	)s=A/F&%B:9F&:C#F&"C##BF&
F&&F*-F*cddl}||jd	tj}|sdS||dK)z$Multithreaded version of interact().rNrr)_threadstart_new_threadlistenerrcrrrr)r^rrs   r_rzTelnet.mt_interact5sk  333	-9%%''D
JJt{{7++,,,		-rMc		|}n #t$rtdYdSwxYw|r3tj|dntj)z>Helper for mt_interact() -- this executes in the other thread.rrNr)rrrprcrrrr)r^datas  r_rzTelnet.listener?s		#
((


@AAA

#
  W!5!56666
  """		#s55cd}|dd}tt|}|D]<}t||ds$|sddl}|||||<=|t|z}t
5}||tj	|j
s||D]n}|||j
}|rJ|}	|j
d|	}
|j
|	d|_
|||
fccdddSo|0||}|tz
}|s|dkrn||j
dddn#1swxYwY|}
|
s|j
rt$dd|
fS)aRead until one from a list of a regular expressions matches.

        The first argument is a list of regular expressions, either
        compiled (re.Pattern instances) or uncompiled (strings).
        The optional second argument is a timeout, in seconds; default
        is no timeout.

        Return a tuple of three items: the index in the list of the
        first regular expression that matches; the re.Match object
        returned; and the text read up till and including the match.

        If EOF is read and no text was read, raise EOFError.
        Otherwise, when nothing matches, return (-1, None, text) where
        text is the text received so far (may be the empty string if a
        timeout happened).

        If a regular expression ends with a greedy match (e.g. '.*')
        or if more than one expression can match the same input, the
        results are undeterministic, and may depend on the I/O timing.

        Nsearchr)rangerhasattrrecompilerrrrrrWrrrVrorrrr)r^listrRrindicesrrrmerreadys            r_expectz
Telnet.expectLsF,AAAwD		""	.	.A47H--
.$9999**T!W--Qww(H


	!(dI$8999h
!!!### ,,AQt|44A,EEGG#|BQB/'+|ABB'7 !1d|++	!	!	!	!	!	!	!	!,
&$OOG44E&0G %"Q;;!$   #h
!	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!(""$$		ND$s	BF5AFFFc|SNrrjs r_	__enter__zTelnet.__enter__srMc.|dSrrh)r^typevalue	tracebacks    r___exit__zTelnet.__exit__s

rMr)"__name__
__module____qualname____doc__re_GLOBAL_DEFAULT_TIMEOUTr`r\rkrqrtrirwryrrrrrrrrrrrrrrrrrrrrrrMr_rrs33j!q7++++0 )GDDDD"%%%""""""#%#%#%#%J


%%%%%%	%	%	%


(((E-E-E-N$$$$",,,)))4---###6 6 6 6 prMcd}tjddrRtjddkr<|dz}tjd=tjddrtjddk<d}tjddrtjd}d}tjddrHtjd}	t|}n%#t$rt	j|d}YnwxYwt
5}|||||d	|	ddddS#1swxYwYdS)
zTest program for telnetlib.

    Usage: python telnetlib.py [-d] ... [host [port]]

    Default host is localhost; default port is 23.

    rrNz-d	localhostrtcpg?)rR)
rcargvint
ValueErrorre
getservbynamerrtr\r)rOrPrQportstrtns     r_testrsJ

(122,38A;$..\
HQK(122,38A;$..D
x|x{D
x|8(1+	8w<<DD	8	8	8'77DDD	8	R
*%%%
dC(((



s%:C

C,+C,=AEEE__main__)\rrcrertimerrwarnings_deprecatedr__all__rNrbbytesr{rrrrrrNOPDMBRKIPAOAYTECELGArBINARYECHORCPSGANAMSSTATUSTMRCTENAOLNAOPNAOCRDNAOHTSNAOHTDNAOFFDNAOVTSNAOVTDNAOLFDXASCIILOGOUTBMDETSUPDUPSUPDUPOUTPUTSNDLOCTTYPEEORTUIDOUTMRKTTYLOCVT3270REGIMEX3PADNAWSTSPEEDLFLOWLINEMODEXDISPLOCOLD_ENVIRONAUTHENTICATIONENCRYPTNEW_ENVIRONTN3270EXAUTHCHARSETRSPCOM_PORT_OPTIONSUPPRESS_LOCAL_ECHOTLSKERMITSEND_URL	FORWARD_XPRAGMA_LOGON
SSPI_LOGONPRAGMA_HEARTBEATEXOPLrrrJrSelectSelectorrrrrMr_<module>r?sDF






######Xg....*

ucU||ucU||ucU||ucU||ucU||
%**eSElleSElleSElleSElleSElleSElleSElleSElleSElleSElleSEll

suaSzzeQCjjeQCjjuaSzz	s
UA3ZZuaSzzuaSzzuaSzz	t	t	t	t	t	t	t	t	t
UB4[[eRDkk	tubT{{	t
rdeRDkkubT{{	t	tubT{{
rdubT{{	t
rd5";;5";;eRDkkt
%++eRDkk
%++
rd
%++eRDkk%++eRDkkeRDkk	t5";;E2$KK	ucU||
UC5\\
5#<<
se
qc


79n%%/,OO.Oxxxxxxxxv6zDFFFFFrM