Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/conch/ssh/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

�b�5�@s"dZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZm
Z
mZddlmZmZddlmZddlmZe�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�d�Zdd�Zdd�Zgd�Zeej�Gdd�dej��Z Gdd�dej!�Z"dd�Z#dd�Z$dd�Z%dd�Z&dS) z�
This module contains the implementation of SSHSession, which (by default)
allows access to a shell and a python interpreter over SSH.

Maintainer: Paul Swartz
�N)�implementer)�EnvironmentVariableNotPermitted�ISession�ISessionSetEnv)�channel�common�
connection)�
interfaces�protocol)�Logger)�
networkStringc@steZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�
SSHSessiona�
    A generalized implementation of an SSH session.

    See RFC 4254, section 6.

    The precise implementation of the various operations that the remote end
    can send is left up to the avatar, usually via an adapter to an
    interface such as L{ISession}.

    @ivar buf: a buffer for data received before making a connection to a
        client.
    @type buf: L{bytes}
    @ivar client: a protocol for communication with a shell, an application
        program, or a subsystem (see RFC 4254, section 6.5).
    @type client: L{SSHSessionProcessProtocol}
    @ivar session: an object providing concrete implementations of session
        operations.
    @type session: L{ISession}
    ssessioncOs0tjj|g|�Ri|��d|_d|_d|_dS�N�)r�
SSHChannel�__init__�buf�client�session)�self�args�kw�r�;/usr/lib/python3/dist-packages/twisted/conch/ssh/session.pyr8s
zSSHSession.__init__cCsnt�|�\}}tjd|d�|j�||�}|r0t|�}t|�}|�|�|�t	|��||_
dSt�d�dS)Nz"Asking for subsystem "{subsystem}")�	subsystem�zFailed to get subsystemr)r�getNS�log�info�avatar�lookupSubsystem�SSHSessionProcessProtocol�wrapProcessProtocol�makeConnection�wrapProtocolr�error)r�datar�ignoredr�pp�protorrr�request_subsystem>s

zSSHSession.request_subsystemcCs^t�d�|jst|j�|_zt|�}|j�|�Wnty)t�d�YdSw||_	dS)Nz
Getting shellzError getting shellrr)
rrrrrr!�	openShell�	Exception�failurer)rr&r(rrr�
request_shellMs

�zSSHSession.request_shellcCsv|js	t|j�|_t�|�\}}tjd|d�z
t|�}|j�||�Wnt	y5tj
d|d�YdSw||_dS)NzExecuting command "{f}")�fzError executing command "{f}"rr)rrrrrrrr!�execCommandr,r-r)rr&r/r(rrr�request_exec[s�zSSHSession.request_execcCsf|js	t|j�|_t|�\}}}tjd||d�z|j�|||�WdSty2t�d�YdSw)Nz-Handling pty request: {term!r} {windowSize!r})�term�
windowSizezError handling pty requestrr)	rrr�parseRequest_pty_reqrr�getPtyr,r-)rr&r2r3�modesrrr�request_pty_reqjs��
�zSSHSession.request_pty_reqcCs�|js	t|j�|_t�|j�stjd|j|jd�dSt�|d�\}}}z
|j�	||�WdSt
y8YdStyHtjd|d�YdSw)ag
        Process a request to pass an environment variable.

        @param data: The environment variable name and value, each encoded
            as an SSH protocol string and concatenated.
        @type data: L{bytes}
        @return: A true value if the request to pass this environment
            variable was accepted, otherwise a false value.
        z�Can't handle environment variables for SSH avatar {avatar}: {session} does not provide ISessionSetEnv interface. It should be decorated with @implementer(ISession, ISessionSetEnv) to support env variables.)rrr�z)Error setting environment variable {name})�namer)
rrrr�
providedByr�warnrr�setEnvrr,r-)rr&r9�valuerrr�request_env{s&
���zSSHSession.request_envcCsL|js	t|j�|_t|�}z	|j�|�WdSty%t�d�YdSw)NzError changing window sizerr)rrr�parseRequest_window_change�
windowChangedr,rr-)rr&�winSizerrr�request_window_change�s�
�z SSHSession.request_window_changecCs*|js|j|7_dS|jj�|�dS�N)rr�	transport�write�rr&rrr�dataReceived�szSSHSession.dataReceivedcCsJ|tjkr|jrt|jjd�r|jj�|�dSdSdStjd|d�dS)N�writeErrzWeird extended data: {dataType})�dataType)r�EXTENDED_DATA_STDERRr�hasattrrDrHrr;)rrIr&rrr�extReceived�s

�zSSHSession.extReceivedcCs.|jr
|j��dS|jr|j�|�dSdSrC)r�eofReceivedr�conn�	sendClose�rrrrrM��
�zSSHSession.eofReceivedcCs.|jr
|j��dS|jr|jj��dSdSrC)r�closedrrD�loseConnectionrPrrrrR�rQzSSHSession.closedcCs"|jr	|jj��tj�|�dSrC)rrDrSrrrPrrrrS�szSSHSession.loseConnectionN)�__name__�
__module__�__qualname__�__doc__r9rr*r.r1r7r>rBrGrLrMrRrSrrrrr
!s!	r
c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�_ProtocolWrapperzS
    This class wraps a L{Protocol} instance in a L{ProcessProtocol} instance.
    cC�
||_dSrC�r)�rr)rrrr��
z_ProtocolWrapper.__init__cC�|j��dSrC)r)�connectionMaderPrrrr^��z_ProtocolWrapper.connectionMadecC�|j�|�dSrC�r)rGrFrrr�outReceived��z_ProtocolWrapper.outReceivedcCr`rC)r)�connectionLost�r�reasonrrr�processEnded�rcz_ProtocolWrapper.processEndedN)rTrUrVrWrr^rbrgrrrrrX�srXc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�_DummyTransportcCrYrCrZr[rrrr�r\z_DummyTransport.__init__cCs|jj�|�dSrC)r)rDrErFrrrrG��z_DummyTransport.dataReceivedcCr`rCrarFrrrrE�rcz_DummyTransport.writecCs|�d�|��dSr)rE�join�r�seqrrr�
writeSequence��z_DummyTransport.writeSequencecCs|j�tj�dSrC)r)rdr
�connectionDonerPrrrrS�riz_DummyTransport.loseConnectionN)rTrUrVrrGrErmrSrrrrrh�srhcCst|tj�r
t|�S|SrC)�
isinstancer
�ProtocolrX)�instrrrr"�sr"cCst|�SrC)rhrZrrrr$�sr$)
�ABRT�ALRM�FPE�HUP�ILL�INT�KILL�PIPE�QUIT�SEGV�TERM�USR1�USR2c@s�eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
ddd�Zdd�Zddd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS) r!z�I am both an L{IProcessProtocol} and an L{ITransport}.

    I am a transport to the remote endpoint and a process protocol to the
    local subsystem.
    NcCs||_d|_dS)NF)r�lostOutOrErrFlag)rrrrrrs
z"SSHSessionProcessProtocol.__init__cCs(|jjr|j�|jj�d|j_dSdSrC)rrrDrErPrrrr^s�z(SSHSessionProcessProtocol.connectionMadecCr`rC�rrErFrrrrb!rcz%SSHSessionProcessProtocol.outReceivedcCs|j�tj|�dSrC)r�
writeExtendedrrJ)r�errrrr�errReceived$rnz%SSHSessionProcessProtocol.errReceivedcCs$|jr
|jj�|j�dSd|_dS)zW
        EOF should only be sent when both STDOUT and STDERR have been closed.
        TN)r�rrN�sendEOFrPrrr�outConnectionLost's
z+SSHSessionProcessProtocol.outConnectionLostcCs|��dS)z*
        See outConnectionLost().
        N)r�rPrrr�errConnectionLost0sz+SSHSessionProcessProtocol.errConnectionLostcCr]rC�rrSrerrrrd6r_z(SSHSessionProcessProtocol.connectionLostcCs�|jdurCi|_tD]}d|}tt|d�}|dur||j|<q
tj��D]\}}|�d�rB|�d�sB||jvrB|dtj|j|<q%|j|S)z:
        Get a signal name given a signal number.
        N�SIG�SIG_�@)	�_signalValuesToNames�SUPPORTED_SIGNALS�getattr�signal�__dict__�items�
startswith�sys�platform)r�signum�signame�sigvalue�k�vrrr�_getSignalName9s

�
�
z(SSHSessionProcessProtocol._getSignalNamec
Cs�|durs|j}|jdurW|�|j�}ttdd�dur*t�|j�r*tjd|d�d}n	tjd|d�d}|j	j
�|j	dt�
t|d	d���|rHd
ndt�
d�t�
d��n|jdurstjd
|jd�|j	j
�|j	dt�d|j��|j	��dS)z�
        When we are told the process ended, try to notify the other side about
        how the process ended using the exit-signal or exit-status requests.
        Also, close the channel.
        N�	WCOREDUMPz#exitSignal: {signame} (core dumped))r�TzexitSignal: {}Fsexit-signal���rzexitCode: {exitCode!r})�exitCodesexit-status�>L)r=r�r�r��osr��statusrrrrN�sendRequestr�NSrr��struct�packrS)rrfr�r��
coreDumpedrrrrgMs8
�
����
�z&SSHSessionProcessProtocol.processEndedcC�|jjj��S)z>
        Return the host from my session's transport.
        )rrNrD�getHostrPrrrr�n�z!SSHSessionProcessProtocol.getHostcCr�)z>
        Return the peer from my session's transport.
        )rrNrD�getPeerrPrrrr�tr�z!SSHSessionProcessProtocol.getPeercCr`rCr�rFrrrrEzrczSSHSessionProcessProtocol.writecCs|j�d�|��dSr)rrErjrkrrrrm}sz'SSHSessionProcessProtocol.writeSequencecCr]rCr�rPrrrrS�r_z(SSHSessionProcessProtocol.loseConnectionrC)rTrUrVrWr�rr^rbr�r�r�rdr�rgr�r�rErmrSrrrrr!s"	

!r!c@seZdZdd�ZdS)�SSHSessionClientcCs|jr|j�|�dSdSrC)rDrErFrrrrG�s�zSSHSessionClient.dataReceivedN)rTrUrVrGrrrrr��sr�c	sxt�|�\}}t�d|dd��\}}}}t�|dd��\�}||||f}�fdd�tdt��dd�D��||�fS)	z�Parse the data from a pty-req request into usable data.

    @returns: a tuple of (terminal type, (rows, cols, xpixel, ypixel), modes)
    �>4LN�c
s@g|]}t�||d��t�d�|d|d��df�qS)rr��r)�ordr��unpack)�.0�i�r6rr�
<listcomp>�s2��z(parseRequest_pty_req.<locals>.<listcomp>rrr�)rrr�r��range�len)	r&r2�rest�cols�rows�xpixel�ypixelr'rArr�rr4�s
�
r4c
Cs>|\}}}}t�|�}t�d||||�}t�|�}	|||	S)z�
    Pack a pty-req request so that it is suitable for sending.

    NOTE: modes must be packed before being sent here.

    @type geometry: L{tuple}
    @param geometry: A tuple of (rows, columns, xpixel, ypixel)
    r�)rr�r�r�)
r2�geometryr6r�r�r�r��
termPacked�
winSizePacked�modesPackedrrr�packRequest_pty_req�s
	

r�cCs t�d|�\}}}}||||fS)zzParse the data from a window-change request into usuable data.

    @returns: a tuple of (rows, cols, xpixel, ypixel)
    r�)r�r�)r&r�r�r�r�rrrr?�sr?cCs|\}}}}t�d||||�S)z�
    Pack a window-change request so that it is suitable for sending.

    @type geometry: L{tuple}
    @param geometry: A tuple of (rows, columns, xpixel, ypixel)
    r�)r�r�)r�r�r�r�r�rrr�packRequest_window_change�sr�)'rWr�r�r�r��zope.interfacer�twisted.conch.interfacesrrr�twisted.conch.sshrrr�twisted.internetr	r
�twisted.loggerr�twisted.python.compatrrrr
�ProcessProtocolrXrhr"r$r��
ITransportr!rqr�r4r�r?r�rrrr�<module>s4+w	

Spamworldpro Mini