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__/forwarding.cpython-310.pyc
o

�b! �@s�dZddlZddlmZmZddlmZmZddlm	Z	m
Z
Gdd�dej�ZGdd	�d	ej
�ZGd
d�de�ZGdd
�d
e�ZGdd�dej
�Zdd�ZGdd�dej�Zdd�ZeZdd�ZeZdd�Zdd�ZdS)z�
This module contains the implementation of the TCP forwarding, which allows
clients and servers to forward arbitrary TCP data across the connection.

Maintainer: Paul Swartz
�N)�channel�common)�protocol�reactor)�HostnameEndpoint�connectProtocolc@seZdZdd�Zdd�ZdS)�SSHListenForwardingFactorycCs||_||_||_dS�N)�conn�hostport�klass)�self�
connectionrr�r�>/usr/lib/python3/dist-packages/twisted/conch/ssh/forwarding.py�__init__s
z#SSHListenForwardingFactory.__init__cCsF|j|jd�}t|�}||_|j|jf}t|j|�}|j�||�|S)N)r
)	rr
�SSHForwardingClient�client�host�port�packOpen_direct_tcpipr�openChannel)r
�addrrr�	addrTuple�channelOpenDatarrr�
buildProtocolsz(SSHListenForwardingFactory.buildProtocolN)�__name__�
__module__�__qualname__rrrrrrrsrc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�SSHListenForwardingChannelcCsH|jjd|jd�t|jj�dkr|jjdd�}|�|�d|j_dS)Nzopened forwarding channel {id}��id��)�_log�infor!�lenr�buf�write)r
�specificData�brrr�channelOpen$s

z&SSHListenForwardingChannel.channelOpencCs|��dSr	)�closed�r
�reasonrrr�
openFailed+sz%SSHListenForwardingChannel.openFailedcCs|jj�|�dSr	)r�	transportr(�r
�datarrr�dataReceived.sz'SSHListenForwardingChannel.dataReceivedcCs|jj��dSr	)rr0�loseConnection�r
rrr�eofReceived1sz&SSHListenForwardingChannel.eofReceivedcCs4t|d�r|jjd|jd�|jj��|`dSdS)Nrz%closing local forwarding channel {id}r )�hasattrr$r%r!rr0r4r5rrrr,4s

�z!SSHListenForwardingChannel.closedN)rrrr+r/r3r6r,rrrrr#src@�eZdZdZdS)� SSHListenClientForwardingChannelsdirect-tcpipN�rrr�namerrrrr9;�r9c@r8)� SSHListenServerForwardingChannelsforwarded-tcpipNr:rrrrr=@r<r=c@sDeZdZdZeZdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�ZdS)�SSHConnectForwardingChannela�
    Channel used for handling server side forwarding request.
    It acts as a client for the remote forwarding destination.

    @ivar hostport: C{(host, port)} requested by client as forwarding
        destination.
    @type hostport: L{tuple} or a C{sequence}

    @ivar client: Protocol connected to the forwarding destination.
    @type client: L{protocol.Protocol}

    @ivar clientBuf: Data received while forwarding channel is not yet
        connected.
    @type clientBuf: L{bytes}

    @var  _reactor: Reactor used for TCP connections.
    @type _reactor: A reactor.

    @ivar _channelOpenDeferred: Deferred used in testing to check the
        result of C{channelOpen}.
    @type _channelOpenDeferred: L{twisted.internet.defer.Deferred}
    cOs0tjj|g|�Ri|��||_d|_d|_dS)Nr#)r�
SSHChannelrrr�	clientBuf)r
r�args�kwrrrr_s
z$SSHConnectForwardingChannel.__init__cCs`|jjd|jd|jdd�t|j|jd|jd�}t|t|��}|�|j|j	�||_
dS)�,
        See: L{channel.SSHChannel}
        zconnecting to {host}:{port}rr"�rrN)r$r%rr�_reactorrr�addCallbacks�
_setClient�_close�_channelOpenDeferred)r
r)�ep�drrrr+es�
z'SSHConnectForwardingChannel.channelOpencCsr||_|jjd|jd|jdd�|jr |jj�|j�d|_|jjdd�r3|�|jjdd��d|j_dS)z�
        Called when the connection was established to the forwarding
        destination.

        @param client: Client protocol connected to the forwarding destination.
        @type  client: L{protocol.Protocol}
        zconnected to {host}:{port}rr"rDNr#)rr$r%rr@r0r(r')r
rrrrrGqs�z&SSHConnectForwardingChannel._setClientcCs,|jjd|jd|jd|d�|��dS)z�
        Called when failed to connect to the forwarding destination.

        @param reason: Reason why connection failed.
        @type  reason: L{twisted.python.failure.Failure}
        z,failed to connect to {host}:{port}: {reason}rr")rrr.N)r$�errorrr4r-rrrrH�s�z"SSHConnectForwardingChannel._closecCs*|jr|jj�|�dS|j|7_dS)rCN)rr0r(r@r1rrrr3�sz(SSHConnectForwardingChannel.dataReceivedcCs@|jr|jjd|jd�|jjr|��|jj��|`dSdS)rCz%closed remote forwarding channel {id}r N)rr$r%r!rr4r0r5rrrr,�s�z"SSHConnectForwardingChannel.closedN)rrr�__doc__rrErr+rGrHr3r,rrrrr>Es	r>cCst|�\}}t||||d�S)N)�remoteWindow�remoteMaxPacket�avatar)�unpackOpen_direct_tcpipr>)rNrOr2rP�remoteHP�origHPrrr�openConnectForwardingClient�s�rTc@s$eZdZdd�Zdd�Zdd�ZdS)rcCs||_d|_dS)N�)rr')r
rrrrr�s
zSSHForwardingClient.__init__cCs(|jr|j|7_dS|j�|�dSr	)r'rr(r1rrrr3�sz SSHForwardingClient.dataReceivedcCs|jr
|j��d|_dSdSr	)rr4r-rrr�connectionLost�s

�z"SSHForwardingClient.connectionLostN)rrrrr3rVrrrrr�srcCsl|\}}|\}}t|t�r|�d�}t|t�r|�d�}t�|�t�d|�}t�|�t�d|�}||S)a
    Pack the data suitable for sending in a CHANNEL_OPEN packet.

    @type destination: L{tuple}
    @param destination: A tuple of the (host, port) of the destination host.

    @type source: L{tuple}
    @param source: A tuple of the (host, port) of the source host.
    �utf-8�>L)�
isinstance�str�encoder�NS�struct�pack)�destination�source�connHost�connPort�origHost�origPortr
�origrrrr�s




rcCs�t�|�\}}t|t�r|�d�}tt�d|dd��d�}t�|dd��\}}t|t�r4|�d�}tt�d|dd��d�}||f||ffS)z#Unpack the data to a usable format.rWrXN�r�r�getNSrY�bytes�decode�intr]�unpack)r2ra�restrbrcrdrrrrQ�s



rQcCs|\}}t�|�t�d|�S)zv
    Pack the data for tcpip forwarding.

    @param peer: A tuple of the (host, port) .
    @type peer: L{tuple}
    rX)rr\r]r^)�peerrrrrr�packGlobal_tcpip_forward�srocCsFt�|�\}}t|t�r|�d�}tt�d|dd��d�}||fS)NrWrXrfrrg)r2rrmrrrr�unpackGlobal_tcpip_forward�s


rp)rMr]�twisted.conch.sshrr�twisted.internetrr�twisted.internet.endpointsrr�Factoryrr?rr9r=r>rT�Protocolrr�packOpen_forwarded_tcpiprQ�unpackOpen_forwarded_tcpiprorprrrr�<module>s&c



Spamworldpro Mini