AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/conch/insults/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/twisted/conch/insults/__pycache__/insults.cpython-310.pyc
o

�b2��@s^dZddlmZmZddlmZmZmZddl	m
Z
mZGdd�de�Zee�Gdd�d��Z
Gd	d
�d
ej�ZdZdd
iZGdd�d�ZGdd�d�ZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!Gdd �d �Z"d!d"�Z#d#Z$Gd$d%�d%�Z%d&d'�e$D�Z&ee�Gd(d)�d)ej'��Z(e)e$e&�D]
\Z*Z+e,e(e*e+�q�Gd*d+�d+ej'�Z-gd,�Z.d-S).z?
VT102 and VT220 terminal manipulation.

@author: Jp Calderone
�)�	Interface�implementer)�defer�
interfaces�protocol)�	iterbytes�
networkStringc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ITerminalProtocolcC�dS)zX
        Called with an L{ITerminalTransport} when a connection is established.
        N�)�	transportrr�?/usr/lib/python3/dist-packages/twisted/conch/insults/insults.py�makeConnection�z ITerminalProtocol.makeConnectioncCr
)a`
        A keystroke was received.

        Each keystroke corresponds to one invocation of this method.
        keyID is a string identifier for that key.  Printable characters
        are represented by themselves.  Control keys, such as arrows and
        function keys, are represented with symbolic constants on
        L{ServerProtocol}.
        Nr)�keyID�modifierrrr
�keystrokeReceivedrz#ITerminalProtocol.keystrokeReceivedcCr
)z�
        Called to indicate the size of the terminal.

        A terminal of 80x24 should be assumed if this method is not
        called.  This method might not be called for real terminals.
        Nr)�width�heightrrr
�terminalSize"rzITerminalProtocol.terminalSizecCr
�z�
        Called when an unsupported control sequence is received.

        @type seq: L{str}
        @param seq: The whole control sequence which could not be interpreted.
        Nr��seqrrr
�unhandledControlSequence*rz*ITerminalProtocol.unhandledControlSequencecCr
)zh
        Called when the connection has been lost.

        reason is a Failure describing why.
        Nr)�reasonrrr
�connectionLost2rz ITerminalProtocol.connectionLostN)�__name__�
__module__�__qualname__rrrrrrrrr
r	sr	c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TerminalProtocolcCs||_|��dS�N)�terminal�connectionMade)�selfr!rrr
r<szTerminalProtocol.makeConnectioncCr
)zA
        Called after a connection has been established.
        Nr�r#rrr
r"ArzTerminalProtocol.connectionMadecC�dSr r)r#rrrrr
rF�z"TerminalProtocol.keystrokeReceivedcCr%r r)r#rrrrr
rIr&zTerminalProtocol.terminalSizecCr%r r)r#rrrr
rLr&z)TerminalProtocol.unhandledControlSequencecCr%r r�r#rrrr
rOr&zTerminalProtocol.connectionLostN)	rrrrr"rrrrrrrr
r:src@sdeZdZdVdd�ZdVdd�ZdVdd�ZdVdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdWd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?d@�Z!dAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%dVdIdJ�Z&dVdKdL�Z'dVdMdN�Z(dOdP�Z)dQdR�Z*dSdT�Z+dUS)X�ITerminalTransport�cCr
)z-
        Move the cursor up n lines.
        Nr��nrrr
�cursorUpTrzITerminalTransport.cursorUpcCr
)z/
        Move the cursor down n lines.
        Nrr*rrr
�
cursorDownYrzITerminalTransport.cursorDowncCr
)z2
        Move the cursor right n columns.
        Nrr*rrr
�
cursorForward^rz ITerminalTransport.cursorForwardcCr
)z1
        Move the cursor left n columns.
        Nrr*rrr
�cursorBackwardcrz!ITerminalTransport.cursorBackwardcCr
)z?
        Move the cursor to the given line and column.
        Nr)�column�linerrr
�cursorPositionhrz!ITerminalTransport.cursorPositioncCr
)z'
        Move the cursor home.
        Nrrrrr
�
cursorHomemrzITerminalTransport.cursorHomecCr
)zS
        Move the cursor down one line, performing scrolling if necessary.
        Nrrrrr
�indexrrzITerminalTransport.indexcCr
)zQ
        Move the cursor up one line, performing scrolling if necessary.
        Nrrrrr
�reverseIndexwrzITerminalTransport.reverseIndexcCr
)zl
        Move the cursor to the first position on the next line, performing scrolling if necessary.
        Nrrrrr
�nextLine|rzITerminalTransport.nextLinecCr
)zj
        Save the cursor position, character attribute, character set, and origin mode selection.
        Nrrrrr
�
saveCursor�rzITerminalTransport.saveCursorcCr
)z�
        Restore the previously saved cursor position, character attribute, character set, and origin mode selection.

        If no cursor state was previously saved, move the cursor to the home position.
        Nrrrrr
�
restoreCursor�rz ITerminalTransport.restoreCursorcCr
)z6
        Set the given modes on the terminal.
        Nr��modesrrr
�setModes�rzITerminalTransport.setModescCr
)z8
        Reset the given modes on the terminal.
        Nr)�moderrr
�
resetModes�rzITerminalTransport.resetModescCr
)zB
        Set the given DEC private modes on the terminal.
        Nrr9rrr
�setPrivateModes�rz"ITerminalTransport.setPrivateModescCr
)zD
        Reset the given DEC private modes on the terminal.
        Nrr9rrr
�resetPrivateModes�rz$ITerminalTransport.resetPrivateModescCr
)z�
        Cause keypad to generate control functions.

        Cursor key mode selects the type of characters generated by cursor keys.
        Nrrrrr
�applicationKeypadMode�rz(ITerminalTransport.applicationKeypadModecCr
)z=
        Cause keypad to generate normal characters.
        Nrrrrr
�numericKeypadMode�rz$ITerminalTransport.numericKeypadModecCr
)z�
        Select a character set.

        charSet should be one of CS_US, CS_UK, CS_DRAWING, CS_ALTERNATE, or
        CS_ALTERNATE_SPECIAL.

        which should be one of G0 or G1.
        Nr)�charSet�whichrrr
�selectCharacterSet�rz%ITerminalTransport.selectCharacterSetcCr
)z0
        Activate the G0 character set.
        Nrrrrr
�shiftIn�rzITerminalTransport.shiftIncCr
)z0
        Activate the G1 character set.
        Nrrrrr
�shiftOut�rzITerminalTransport.shiftOutcCr
)zG
        Shift to the G2 character set for a single character.
        Nrrrrr
�singleShift2�rzITerminalTransport.singleShift2cCr
)zG
        Shift to the G3 character set for a single character.
        Nrrrrr
�singleShift3�rzITerminalTransport.singleShift3cGr
)z�
        Enabled one or more character attributes.

        Arguments should be one or more of UNDERLINE, REVERSE_VIDEO, BLINK, or BOLD.
        NORMAL may also be specified to disable all character attributes.
        Nr)�
attributesrrr
�selectGraphicRendition�rz)ITerminalTransport.selectGraphicRenditioncCr
)z@
        Set a tab stop at the current cursor position.
        Nrrrrr
�horizontalTabulationSet�rz*ITerminalTransport.horizontalTabulationSetcCr
)zD
        Clear the tab stop at the current cursor position.
        Nrrrrr
�tabulationClear�rz"ITerminalTransport.tabulationClearcCr
)z&
        Clear all tab stops.
        Nrrrrr
�tabulationClearAll�rz%ITerminalTransport.tabulationClearAllTcCr
)z�
        Make the current line the top or bottom half of a double-height, double-width line.

        If top is True, the current line is the top half.  Otherwise, it is the bottom half.
        Nr)�toprrr
�doubleHeightLine�rz#ITerminalTransport.doubleHeightLinecCr
)zK
        Make the current line a single-width, single-height line.
        Nrrrrr
�singleWidthLine�rz"ITerminalTransport.singleWidthLinecCr
)z<
        Make the current line a double-width line.
        Nrrrrr
�doubleWidthLine�rz"ITerminalTransport.doubleWidthLinecCr
)zV
        Erase from the cursor to the end of line, including cursor position.
        Nrrrrr
�eraseToLineEnd�rz!ITerminalTransport.eraseToLineEndcCr
)zd
        Erase from the cursor to the beginning of the line, including the cursor position.
        Nrrrrr
�eraseToLineBeginning�rz'ITerminalTransport.eraseToLineBeginningcCr
)z/
        Erase the entire cursor line.
        Nrrrrr
�	eraseLine�rzITerminalTransport.eraseLinecCr
)za
        Erase from the cursor to the end of the display, including the cursor position.
        Nrrrrr
�eraseToDisplayEndrz$ITerminalTransport.eraseToDisplayEndcCr
)zg
        Erase from the cursor to the beginning of the display, including the cursor position.
        Nrrrrr
�eraseToDisplayBeginningrz*ITerminalTransport.eraseToDisplayBeginningcCr
)z+
        Erase the entire display.
        Nrrrrr
�eraseDisplayrzITerminalTransport.eraseDisplaycCr
)z�
        Delete n characters starting at the cursor position.

        Characters to the right of deleted characters are shifted to the left.
        Nrr*rrr
�deleteCharacterrz"ITerminalTransport.deleteCharactercCr
)z�
        Insert n lines at the cursor position.

        Lines below the cursor are shifted down.  Lines moved past the bottom margin are lost.
        This command is ignored when the cursor is outside the scroll region.
        Nrr*rrr
�
insertLinerzITerminalTransport.insertLinecCr
)z�
        Delete n lines starting at the cursor position.

        Lines below the cursor are shifted up.  This command is ignored when the cursor is outside
        the scroll region.
        Nrr*rrr
�
deleteLine rzITerminalTransport.deleteLinecCr
)zi
        Return a Deferred that fires with a two-tuple of (x, y) indicating the cursor position.
        Nrrrrr
�reportCursorPosition(rz'ITerminalTransport.reportCursorPositioncCr
)z:
        Reset the terminal to its initial state.
        Nrrrrr
�reset-rzITerminalTransport.resetcCr
rrrrrr
r2rz+ITerminalTransport.unhandledControlSequenceN�r)�T),rrrr,r-r.r/r2r3r4r5r6r7r8r;r=r>r?r@rArDrErFrGrHrJrKrLrMrOrPrQrRrSrTrUrVrWrXrYrZr[r\rrrrr
r(SsT








r(��~stildec@s(eZdZdZdZZdZZdZZ	dS)r:z$
    ECMA 48 standardized modes
    ���N)
rrr�__doc__�KEYBOARD_ACTION�KAM�INSERTION_REPLACEMENT�IRM�LINEFEED_NEWLINE�LNMrrrr
r:?s
	
r:c@s@eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdS)�privateModesz'
    ANSI-Compatible Private Modes
    rr)ra�rb�������N)rrrrd�ERROR�
CURSOR_KEY�	ANSI_VT52�COLUMN�SCROLL�SCREEN�ORIGIN�	AUTO_WRAP�AUTO_REPEAT�PRINTER_FORM_FEED�PRINTER_EXTENT�CURSOR_MODErrrr
rk[srksCS_USsCS_UKs
CS_DRAWINGsCS_ALTERNATEsCS_ALTERNATE_SPECIALsG0sG1sG2sG3r)rbrmroc@seZdZdd�ZdS)�VectorcCs||_||_dSr )�x�y)r#r�r�rrr
�__init__�s
zVector.__init__N)rrrr�rrrr
r��sr�cCsBtdd��}|�t|�d�Wd�dS1swYdS)N�log�a�
)�open�write�str)�s�frrr
r��s"�r�)�UP_ARROW�
DOWN_ARROW�RIGHT_ARROW�
LEFT_ARROW�HOME�INSERT�DELETE�END�PGUP�PGDN�
NUMPAD_MIDDLE�F1�F2�F3�F4�F5�F6�F7�F8�F9�F10�F11�F12�ALT�SHIFT�CONTROLc@s>eZdZdZdeddfdd�Zdefdd�Zdefd	d
�ZdS)�_constz3
    @ivar name: A string naming this constant
    �name�returnNcCs
||_dSr �r�)r#r�rrr
r��s
z_const.__init__cCsd|jdS)N�[�]r�r$rrr
�__repr__��z_const.__repr__cCsd|jd�d�S)Nr�r��ascii)r��encoder$rrr
�	__bytes__��z_const.__bytes__)	rrrrdr�r�r��bytesr�rrrr
r��s
r�cCsg|]}t|����qSr)r�r�)�.0�_namerrr
�
<listcomp>�sr�c@s eZdZdZdZdZdZdZdZe	dd�Z
e	dd�ZdZdZ
d{d	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�d�Ze�Zd|dd�Zd|d d!�Zd|d"d#�Zd|d$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Z d.d/�Z!d0d1�Z"d2d3�Z#d4d5�Z$d6d7�Z%d8d9�Z&d:d;�Z'd<d=�Z(d>d?�Z)d@dA�Z*dBdC�Z+dDdE�Z,dFdG�Z-dHdI�Z.dJdK�Z/dLdM�Z0dNdO�Z1dPdQ�Z2d}dSdT�Z3dUdV�Z4dWdX�Z5dYdZ�Z6d[d\�Z7d]d^�Z8d_d`�Z9dadb�Z:dcdd�Z;d|dedf�Z<d|dgdh�Z=d|didj�Z>d~dkdl�Z?dmdn�Z@dodp�ZAdqdr�ZBdsdt�ZCdudv�ZDdwdx�ZEdydz�ZFdS)�ServerProtocolN�	���data�P�rcOs$|dur||_||_||_g|_dS)a
        @param protocolFactory: A callable which will be invoked with
        *a, **kw and should return an ITerminalProtocol implementor.
        This will be invoked when a connection to this ServerProtocol
        is established.

        @param a: Any positional arguments to pass to protocolFactory.
        @param kw: Any keyword arguments to pass to protocolFactory.
        N)�protocolFactory�protocolArgs�protocolKwArgs�_cursorReports)r#r�r��kwrrr
r��s

zServerProtocol.__init__cC�td��)Nz%Unimplemented: ServerProtocol.getHost��NotImplementedErrorr$rrr
�getHost��zServerProtocol.getHostcCr�)Nz%Unimplemented: ServerProtocol.getPeerr�r$rrr
�getPeer�r�zServerProtocol.getPeercCsZ|jdur+|j|ji|j��|_z|j}Wn	tyYnw||j_|j�|�dSdSr )r�r�r��terminalProtocol�factory�AttributeErrorr)r#r�rrr
r"�s
��
��zServerProtocol.connectionMadecCs�t|�D]v}|jdkr|dkrd|_q|j�|d�q|jdkr<|dkr+d|_g|_q|dkr3d|_qd|_|�|�q|jdkri|dkrId|_q|��sQ|dkrb|�d	�|j�|�|`d|_q|j�	|�q|jdkrw|�
|�d|_qtd
��dS)Nr�r_�escaped�[sbracket-escaped�Oslow-function-escapedr`r��
Illegal state)r�stater�r�escBuf�_handleShortControlSequence�isalpha�_handleControlSequence�join�append�!_handleLowFunctionControlSequence�
ValueError)r#�data�chrrr
�dataReceiveds4




�zServerProtocol.dataReceivedcCs|j�||j�dSr )r�rr�)r#r�rrr
r�!r�z*ServerProtocol._handleShortControlSequencecCsdd|}t|jt�|dd�|dd���d�d�}|dur%|�|�dS|||j|dd��dS)N�[���r�)�getattr�controlSequenceParser�CST�get�decoderr�)r#�bufr�rrr
r�$s �z%ServerProtocol._handleControlSequencecCs|j�|�dSr )r�r)r#r�rrr
r0sz'ServerProtocol.unhandledControlSequencecCsN|j|j|j|jd�}|�|�}|dur|j�|d�dS|j�d|�dS)N)�P�Q�R�Ss)r�r�r�r�r�r�rr)r#r��functionKeysrrrr
r�3s

z0ServerProtocol._handleLowFunctionControlSequencec@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)z$ServerProtocol.ControlSequenceParsercC�,|dkr
|�|jd�dS|�|d�dS)Nr��A)rr�r�r#�proto�handlerr�rrr
�A<�z&ServerProtocol.ControlSequenceParser.AcCr�)Nr��B)rr�rr�rrr
�BBr�z&ServerProtocol.ControlSequenceParser.BcCr�)Nr��C)rr�rr�rrr
�CHr�z&ServerProtocol.ControlSequenceParser.CcCr�)Nr��D)rr�rr�rrr
�DNr�z&ServerProtocol.ControlSequenceParser.DcCr�)Nr��E)rr�rr�rrr
�ETr�z&ServerProtocol.ControlSequenceParser.EcCr�)Nr��F)rr�rr�rrr
�FZr�z&ServerProtocol.ControlSequenceParser.FcCr�)Nr��H)rr�rr�rrr
�H`r�z&ServerProtocol.ControlSequenceParser.Hc	Cs�|js|�|d�dS|�d�r_|dd�}|�d�}t|�dkr+|�|d�dS|\}}zt|�t|�}}WntyK|�|d�YdSw|j�d�}|�|d|df�dS|�|d�dS)Nr�r�ra�;rr))	r�r�
startswith�split�len�intr��pop�callback)	r#r�r�r��report�parts�Pl�Pc�drrr
�Rfs 

�z&ServerProtocol.ControlSequenceParser.RcCs.|dkr|�|j|j�dS|�|d�dS)Nr��Z)r�TABr�rr�rrr
�Zzsz&ServerProtocol.ControlSequenceParser.ZcCs�|j|j|j|j|j|j|j|j|j|j	|j
|j|j|j
d�}|�d�r^|dd�}zt|�}WntyA|�|d�YdSw|�|�}|durU|�||d�dS|�|d�dS|�|d�dS)N)r)rarlrbrmrn��rqrrrc��r�r�rar`)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r)r#r�r�r��mapr��v�symbolicrrr
�tilde�s6�
�
z*ServerProtocol.ControlSequenceParser.tildeN)
rrrr�r�r�r�r�r�r�rr
rrrrr
�ControlSequenceParser;srr)cC�6|dksJ�t|jj|d�|j_|�d|f�dS)Nr)rs[%dA��max�	cursorPosr�r��r#r+rrr
r,��zServerProtocol.cursorUpcC�>|dksJ�t|jj||jjd�|j_|�d|f�dS)Nr)s[%dB��minrr��termSizer�rrrr
r-��zServerProtocol.cursorDowncCr)Nr)s[%dC)rrr�rr�rrrr
r.�rzServerProtocol.cursorForwardcCr)Nr)rs[%dD)rrr�r�rrrr
r/�rzServerProtocol.cursorBackwardcCs|�d|d|df�dS)Ns[%d;%dHr)�r�)r#r0r1rrr
r2�szServerProtocol.cursorPositioncCsd|j_|j_|�d�dS)Nrs)rr�r�r�r$rrr
r3�szServerProtocol.cursorHomecCs,t|jjd|jjd�|j_|�d�dS)Nr)sDrr$rrr
r4�szServerProtocol.indexcCs$t|jjdd�|j_|�d�dS)Nr)rsMrr$rrr
r5�szServerProtocol.reverseIndexcCs4d|j_t|jjd|jjd�|j_|�d�dS)Nrr)�
)rr�rr�rr�r$rrr
r6�szServerProtocol.nextLinecCs"t|jj|jj�|_|�d�dS)Ns7)r�rr�r��_savedCursorPosr�r$rrr
r7�szServerProtocol.saveCursorcCs|j|_|`|�d�dS)Ns8)r!rr�r$rrr
r8�szServerProtocol.restoreCursorcC�*d�dd�|D��}|�d|d�dS)Nr�cs��|]}d|fVqdS��%dNr�r�r<rrr
�	<genexpr>���z*ServerProtocol.setModes.<locals>.<genexpr>r��h�r�r��r#r:�
modesBytesrrr
r;��zServerProtocol.setModescCr")Nr�csr#r$rr&rrr
r'�r(z1ServerProtocol.setPrivateModes.<locals>.<genexpr>�[?r)r*r+rrr
r>��zServerProtocol.setPrivateModescCr")Nr�csr#r$rr&rrr
r'�r(z,ServerProtocol.resetModes.<locals>.<genexpr>r��lr*r+rrr
r=�r-zServerProtocol.resetModescCr")Nr�csr#r$rr&rrr
r'�r(z3ServerProtocol.resetPrivateModes.<locals>.<genexpr>r.r0r*r+rrr
r?�r/z ServerProtocol.resetPrivateModescC�|�d�dS)Ns=rr$rrr
r@�r�z$ServerProtocol.applicationKeypadModecCr1)Ns>rr$rrr
rA�r�z ServerProtocol.numericKeypadModecCs�|tkrd}n|tkrd}ntd��|tkrd}n |tkr d}n|tkr'd}n|tkr.d}n|tkr5d}ntd	��|�d
||�dS)N�(�)z7`which' argument to selectCharacterSet must be G0 or G1r�r��0�1�2z0Invalid `charSet' argument to selectCharacterSetr_)	�G0�G1r��CS_UK�CS_US�
CS_DRAWING�CS_ALTERNATE�CS_ALTERNATE_SPECIALr�)r#rBrCrrr
rD�s"z!ServerProtocol.selectCharacterSetcCr1)N�rr$rrr
rEr�zServerProtocol.shiftIncCr1)N�rr$rrr
rFr�zServerProtocol.shiftOutcCr1)NsNrr$rrr
rG
r�zServerProtocol.singleShift2cCr1)NsOrr$rrr
rH
r�zServerProtocol.singleShift3cGs8g}|D]	}|�t|��q|�dd�|�d�dS)Nr�r��m)r�rr�r�)r#rI�attrsr�rrr
rJsz%ServerProtocol.selectGraphicRenditioncCr1)NsHrr$rrr
rKr�z&ServerProtocol.horizontalTabulationSetcCr1)Nsrr$rrr
rLr�zServerProtocol.tabulationClearcCr1)Nsrr$rrr
rMr�z!ServerProtocol.tabulationClearAllTcCs |r	|�d�dS|�d�dS)Ns#3s#4r)r#rNrrr
rO szServerProtocol.doubleHeightLinecCr1)Ns#5rr$rrr
rP&r�zServerProtocol.singleWidthLinecCr1)Ns#6rr$rrr
rQ)r�zServerProtocol.doubleWidthLinecCr1)Nsrr$rrr
rR,r�zServerProtocol.eraseToLineEndcCr1)Nsrr$rrr
rS/r�z#ServerProtocol.eraseToLineBeginningcCr1)Nsrr$rrr
rT2r�zServerProtocol.eraseLinecCr1)Nsrr$rrr
rU5r�z ServerProtocol.eraseToDisplayEndcCr1)Nsrr$rrr
rV8r�z&ServerProtocol.eraseToDisplayBeginningcCr1)Nsrr$rrr
rW;r�zServerProtocol.eraseDisplaycC�|�d|f�dS)Ns[%dPrrrrr
rX>r�zServerProtocol.deleteCharactercCrB)Ns[%dLrrrrr
rYAr�zServerProtocol.insertLinecCrB)Ns[%dMrrrrr
rZDr�zServerProtocol.deleteLinecCsF|dur
d|f}nd}|durd|f}nd}|�d||f�dS)Nr%r�s[%b;%brr)r#�first�lastrrr
�setScrollRegionGszServerProtocol.setScrollRegioncCs|��dSr )rEr$rrr
�resetScrollRegionR�z ServerProtocol.resetScrollRegioncCs"t��}|j�|�|�d�|S)Ns)r�Deferredr�r�r�)r#rrrr
r[Us
z#ServerProtocol.reportCursorPositioncCs:d|j_|j_z|`Wn	tyYnw|�d�dS)Nrsc)rr�r�r!r�r�r$rrr
r\[s�zServerProtocol.resetcCs>|rt|t�s|�d�}||_|j�d�|�d���dSdS)Nzutf-8s
r )�
isinstancer�r��	lastWriterr�r�r��r#r�rrr
r�ds

�zServerProtocol.writecCs|�d�|��dS)Nr�)r�r�rKrrr
�
writeSequencekr�zServerProtocol.writeSequencecCs|��|j��dSr )r\r�loseConnectionr$rrr
rMnszServerProtocol.loseConnectioncCs0|jdurz|j�|�Wd|_dSd|_wdSr )r�rr'rrr
rrs

�zServerProtocol.connectionLostr r]r^)NN)Grrrr�r�r	�	BACKSPACErJr�r�rr�scrollRegionr�r�r�r�r"r�r�r�rr�rr�r,r-r.r/r2r3r4r5r6r7r8r;r>r=r?r@rArDrErFrGrHrJrKrLrMrOrPrQrRrSrTrUrVrWrXrYrZrErFr[r\r�rLrMrrrrr
r��s�


f








	r�c@s�eZdZdZdZdZdZddddddd	d
ddd
d�Zddddd�Ze	e
eee
d�ZdZd#dd�Zdd�Zdd�Zdd�Zdd�ZGdd �d �Ze�Zd!d"�ZdS)$�ClientProtocolNr�sindexsreverseIndexsnextLines
saveCursors
restoreCursorsapplicationKeypadModesnumericKeypadModessingleShift2ssingleShift3shorizontalTabulationSetsreset)r��Mr��7�8�=�>�Nr�r��c�bracket-escape�	select-g0�	select-g1�select-height-width)r�r2r3�#)r�r�r4r5r6cOs|dur||_||_||_dS)aw
        @param terminalFactory: A callable which will be invoked with
        *a, **kw and should return an ITerminalTransport provider.
        This will be invoked when this ClientProtocol establishes a
        connection.

        @param a: Any positional arguments to pass to terminalFactory.
        @param kw: Any keyword arguments to pass to terminalFactory.
        N)�terminalFactory�terminalArgs�terminalKwArgs)r#r]r�r�rrr
r��s
zClientProtocol.__init__cCs>|jdur|j|ji|j��|_|j|j_|j�|�dSdSr )r]r^r_r!r�rr$rrr
r"�s
��
�zClientProtocol.connectionMadecCs,|jdurz|j�|�W|`dS|`wdSr )r!rr'rrr
r�s

�zClientProtocol.connectionLostcCsVg}t|�D�]}|jdkrz|dkr&|r"|j�d�|��|dd�=d|_q|dkr@|r:|j�d�|��|dd�=|j��q|dkrZ|rT|j�d�|��|dd�=|j��q|dkrt|rn|j�d�|��|dd�=|j��q|�|�q|jdkr�|j	�
|�}|dur�d|_t|j|�d	���q|j
�
|�}|dur�||_q|j�d|�d|_q|jd
kr�|jdur�g|_|��s�|dkr�|�d�|j�|�|`d|_q|j�|�q|jdkr�|j�|j�
||�t�d|_q|jd
k�r|j�|j�
||�t�d|_q|jdk�r|�|�d|_qtd��|�r)|j�d�|��dSdS)z�
        Parse the given data from a terminal server, dispatching to event
        handlers defined by C{self.terminal}.
        r�r_r�Nr�r?r>�r�rXr`rYrZr[r�)rr�r!r�r�rFrEr/r��_shortsr�r�r��_longsr�_escBufr�r�rD�	_charsetsr7r8�_handleHeightWidthr�)r#r��toWrite�b�fNamer�rrr
r��sn









�zClientProtocol.dataReceivedcCsNt|jt�||��d�d�}|dur|j�d||�dS|||j|�dS)Nr�r�)r�r�r�r�r�r!r)r#r�r!r�rrr
r�s�z%ClientProtocol._handleControlSequencec@s�eZdZdd�ZdD]
\ZZeed�q
[dd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)z$ClientProtocol.ControlSequenceParsercsd|���fdd�}|S)N�cursorcs\|st|��d�dSzt|�}Wnty$|�d|��YdSwt|��|�dS)Nr)r�)r�r�r�r)r#r�r�r��m�r�r+rr
�simples�z@ClientProtocol.ControlSequenceParser._makeSimple.<locals>.simpler)r�rhrlrrkr
�_makeSimplesz0ClientProtocol.ControlSequenceParser._makeSimple))r��Up)r��Down)r��Forward)r��Backwardz = _makeSimple(ch, fName)cC�Nzdd�|�d�D�}Wnty|�d|d�YdSw|�|�dS)NcS�g|]}t|��qSr�r�r&rrr
r�0�z:ClientProtocol.ControlSequenceParser.h.<locals>.<listcomp>r�r�r))r�r�rr;�r#r�r�r�r:rrr
�h-��z&ClientProtocol.ControlSequenceParser.hcCrr)NcSrsrrtr&rrr
r�9ruz:ClientProtocol.ControlSequenceParser.l.<locals>.<listcomp>r�r��l)r�r�rr=rvrrr
ry6rxz&ClientProtocol.ControlSequenceParser.lcCs�|�d�}t|�dkr|�dd�dSt|�dkrQz|dr%t|d�}nd}|dr2t|d�}nd}WntyH|�d|d�YdSw|�||�dS|�d|d�dS)Nr�r)rarr��r)r�r�rEr�r�r)r#r�r�r�r�pt�pbrrr
�r?s"
��z&ClientProtocol.ControlSequenceParser.rcC�N|s|��dS|dkr|��dS|dkr|��dS|�d|d�dS)Nr5r6r��K)rRrSrTrr�rrr
�KT�z&ClientProtocol.ControlSequenceParser.KcCs|��dSr )r3r�rrr
r�^rGz&ClientProtocol.ControlSequenceParser.HcCr~)Nr5r6r��J)rUrVrWrr�rrr
�Jar�z&ClientProtocol.ControlSequenceParser.JcC�T|s	|�d�dSzt|�}Wnty"|�d|d�YdSw|�|�dS)Nr)r�r�)rXr�r�r�r#r�r�r�r+rrr
�Pk��z&ClientProtocol.ControlSequenceParser.PcCr�)Nr)r��L)rYr�r�rr�rrr
�Lvr�z&ClientProtocol.ControlSequenceParser.LcCr�)Nr)r�rQ)rZr�r�rr�rrr
�M�r�z&ClientProtocol.ControlSequenceParser.McCsJ|dkr|��\}}|j�d|d|df�dS|�d|d�dS)N�6s[%d;%dRr)r��n)r[rr�r)r#r�r�r�r�r�rrr
r+�s z&ClientProtocol.ControlSequenceParser.nc	Cs^|s	|�t�dSg}|�d�D]}zt|�}Wn	ty!Ynw|�|�q|j|�dS)Nr�)rJ�NORMALr�r�r�r�)r#r�r�r�rAr�rrr
rj�s�z&ClientProtocol.ControlSequenceParser.mN)rrrrmr�rh�execrwryr}r�r�r�r�r�r�r+rjrrrr
rs 		

rcCsp|dkr|j�d�dS|dkr|j�d�dS|dkr#|j��dS|dkr.|j��dS|j�d|�dS)N�3T�4F�5r�s#)r!rOrPrQr)r#rgrrr
re�sz!ClientProtocol._handleHeightWidthr )rrrr]r!r�rcrarbr9r:r;r<r=rdr�r�r"rr�r�rr�rerrrr
rPsL���	
ArP)r	r(r:rk�
FUNCTION_KEYSr:r9r;r<r=r7r8�G2�G3�	UNDERLINE�
REVERSE_VIDEO�BLINK�BOLDr�r�rPN)/rd�zope.interfacerr�twisted.internetrr�	iinternetr�twisted.python.compatrrr	r�
ITransportr(�CSIr�r:rkr:r9r;r<r=r7r8r�r�r�r�r�r�r�r�r��
_KEY_NAMESr�r��Protocolr��zipr��const�setattrrP�__all__rrrr
�<module>sV)i82

Anon7 - 2022
AnonSec Team