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/scripts/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

�bG�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZmZddl
mZddlmZddlmZmZmZmZmZddlmZmZmZddlmZmZdd	lmZm Z Gd
d�de�Z!da"da#da$da%da&da'dd
�Z(dd�Z)dd�Z*dd�Z+dd�Z,dd�Z-dd�Z.dd�Z/dd�Z0Gdd�d�Z1Gd d!�d!ej2�Z2Gd"d#�d#ej3�Z4Gd$d%�d%ej5�Z5Gd&d'�d'ej6�Z6d(d)�Z7d*d+�Z8e9d,kr�e(�dSdS)-�N)�List�Tuple)�connect�default)�ConchOptions)�
ConchError)�channel�common�
connection�
forwarding�session)�reactor�stdio�task)�log�usage)�ioType�
networkStringc	@s�eZdZUdZdZgd�gd�gd�gZgd�gd�gd�gd	�gd
�gd�gZejdgej	d
d�ej	d
d�d�e�
�ej	dd�ej	ddd�gd�ZgZe
eeeeeffed<gZe
eeeeeffed<dd�Zdd�Zdd�Zdd�ZdS) �
ClientOptionsz(Usage:   conch [options] host [command]
zYconch is a SSHv2 client that allows logging into a remote machine and executing commands.)�escape�e�~)�localforward�LNz<listen-port:host:port   Forward local port to remote address)�
remoteforward�RNz<listen-port:host:port   Forward remote port to local address)�null�nzRedirect input from /dev/null.)�fork�fz(Fork to background after authentication.)�tty�tz-Tty; allocate a tty even if command is given.)�notty�TzDo not allocate a tty.)�noshell�Nz"Do not execute a shell or command.)�	subsystem�sz-Invoke command (mandatory) as SSH2 subsystem.)r r"zlisten-port:host:port)�descr)rr�command�argumentT)r(�repeat)�mutuallyExclusive�
optActions�extraActions�
localForwards�remoteForwardscCsv|dkr
d|d<dS|ddkr$t|�dkr$tt|d�d�|d<dSt|�dkr0||d<dSt�d	|�d
��dS)z:
        Set escape character; ``none'' = disable
        �noneNrr�^���@zBad escape character 'z'.)�len�chr�ord�sys�exit)�self�esc�r=�=/usr/lib/python3/dist-packages/twisted/conch/scripts/conch.py�
opt_escapePszClientOptions.opt_escapecC�8|�d�\}}}t|�}t|�}|j�|||ff�dS)zH
        Forward local port to remote address (lport:host:port)
        �:N)�split�intr/�append)r;r�	localPort�
remoteHost�
remotePortr=r=r>�opt_localforward]�zClientOptions.opt_localforwardcCr@)zH
        Forward remote port to local address (rport:host:port)
        rAN)rBrCr0rD)r;rrG�connHost�connPortr=r=r>�opt_remoteforwardfrIzClientOptions.opt_remoteforwardcGs||d<d�|�|d<dS)N�host� r))�join)r;rMr)r=r=r>�	parseArgsoszClientOptions.parseArgsN)�__name__�
__module__�__qualname__�synopsis�longdesc�
optParameters�optFlagsr�Completions�	Completer�CompleteUserAtHost�compDatar/rrrC�__annotations__r0r?rHrLrPr=r=r=r>rs>
���	

�
�� 
 
		rcCs�tjdd�}d|vr#|�d�}|||d�|}||d|d�=|dd�D],}z!|�|�}|dd�dkrK||dddkrKg|||d�<Wq)tyUYq)wt�azt�|�Wn#tjy�}zt	d|���t�
�t�d�WYd}~nd}~wwtd	r�td
r�td
dkr�tj}nt
td
d�}ntj}tj}t�|�|t_nt��t�tj��}zt�|�aWnty�daYnwzt�tjdd
��}Wnty�d}Ynwz0t��Wtr�t�|tjt�|r�t�tj|�td�rtd�std�st�tjtj �n.t�rt�|tjt�|�r)t�tj|�td�r3td�s8td�sAt�tjtj �wwtj�!��rVtd�sVt	d�"td��t�t#�dS)Nr4z-lr3�z-or�-zERROR: r�logfileza+cWst�dt�S�Nr)r
�	callLater�	reConnect)�ar=r=r>�<lambda>�szrun.<locals>.<lambda>r)r r"zConnection to {} closed.rM)$r9�argv�index�
ValueErrorr�options�parseOptionsr�
UsageError�print�opt_helpr:�stdout�open�stderrr�startLogging�discardLogs�	doConnect�stdin�filenor �	tcgetattr�old�
BaseException�signal�SIGUSR1r
�run�	tcsetattr�TCSANOW�SIGWINCH�SIG_DFL�isatty�format�
exitStatus)�args�i�arg�ur�realout�fd�oldUSR1r=r=r>rz}s�

$����

�
��
���rzcCs,ddlm}dat�dt�t�|����)Nr��failurer3g{�G�z�?)	�twisted.pythonr�r�r
ra�_stopReactorr�err�Failurer�r=r=r>�handleError�s
r�cCs$zt��WdStyYdSw�N)r
�stoprwr=r=r=r>r��s
�r�cCs�dtdvrtd�dd�\td<td<tjsddgt_td}tds*t��td<tds3dtd<nttd�td<td}td}tj}td	sRt�|t�td	<t�	tdtt
��}t�||t||��t
�dS)
N�@rMr4�userz
~/.ssh/id_rsaz
~/.ssh/id_dsa�port�zhost-key-algorithms)rhrB�	identitys�getpass�getuserrCr�
verifyHostKey�getHostKeyAlgorithms�SSHUserAuthClient�
SSHConnectionr�
addErrback�_ebExit)rMr��vhk�uaor=r=r>rr�s"

rrcCsd|��at�dt�dS)Nzconch: exiting with error 皙�����?)r�r
rar�)rr=r=r>r��s
r�cCs.ttjd�r
tt�tjr&tjD]\}}t�|t�	t|t
��}tj�|�qtjrItjD]\}}t
�d|�d|���t�||�q,t�ddt�tdrQtdrWt�t��tdr�t��rdt�d	�t��td
�D](}zt�|�Wqlty�}zd	dl}|j|jkr��WYd}~qld}~wwdSdS)N�
sendIgnorez!asking for remote forwarding for rA�before�shutdownr$�agentrr�)�hasattr�conn�	transport�
_KeepAliverhr/r
�	listenTCPr�SSHListenForwardingFactory� SSHListenClientForwardingChannelrDr0r�msg�requestRemoteForwarding�addSystemEventTrigger�beforeShutdown�openChannel�
SSHSession�osr�_exit�setsid�range�close�OSError�errno�EBADF)rE�hostportr'rGr�rr�r=r=r>�	onConnect�sD��
����r�cCst�tjj��dSr�)r�r�r��loseConnectionr=r=r=r>rb	srbcCs8tj}|D]\}}t�d|�d|���t�|�qdS)Nzcancelling rA)rhr0rr�r��cancelRemoteForwarding)r0rGr�r=r=r>r�s
�r�cCstdst�dt�dSdS)N�	reconnectr�)rhr
rar�r=r=r=r>�stopConnections�r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r�cCs*||_d|_t�|j�|_|j�d�dS)Ni,)r��
globalTimeoutr�LoopingCall�
sendGlobal�lc�start)r;r�r=r=r>�__init__sz_KeepAlive.__init__cCs2|jjdddd�}|�|j�t�d|j�|_dS)Ns"conch-keep-alive@twistedmatrix.com�r4��	wantReply�)r��sendGlobalRequest�addBoth�	_cbGlobalr
ra�	_ebGlobalr�)r;�dr=r=r>r�!s
�z_KeepAlive.sendGlobalcCs|jr
|j��d|_dSdSr�)r��cancel)r;�resr=r=r>r�(s

�z_KeepAlive._cbGlobalcCs |jrd|_|jj��dSdSr�)r�r�r�r��r;r=r=r>r�-s�z_KeepAlive._ebGlobalN)rQrRrSr�r�r�r�r=r=r=r>r�s
r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)r�cCs|ag|_i|_t�dSr�)r�r/r0r�r�r=r=r>�serviceStarted4s
zSSHConnection.serviceStartedcCs(|j}g|_|D]}|��qt�dSr�)r/r�r�)r;�lfr'r=r=r>�serviceStopped;s


zSSHConnection.serviceStoppedcCsXt�d|f�}|jd|dd�}t�d|�d|���|�|j||�|�|j||�dS)N�0.0.0.0s
tcpip-forwardr4r�zrequesting remote forwarding rA)	r�packGlobal_tcpip_forwardr�rr��addCallback�_cbRemoteForwardingr��_ebRemoteForwarding)r;rGr��datar�r=r=r>r�Bs
z%SSHConnection.requestRemoteForwardingcCs4t�d|�d|���||j|<t�t|j��dS)Nzaccepted remote forwarding rA)rr�r0�repr)r;�resultrGr�r=r=r>r�Is
z!SSHConnection._cbRemoteForwardingcCs&t�d|�d|�d��t�|�dS)Nzremote forwarding rAz failed�rr�)r;rrGr�r=r=r>r�Nsz!SSHConnection._ebRemoteForwardingcCs^t�d|f�}|�d|�t�d|���z|j|=Wn	ty$Ynwt�t|j��dS)Nr�scancel-tcpip-forwardzcancelling remote forwarding )rr�r�rr�r0�	Exceptionr�)r;rGr�r=r=r>r�Rs�z$SSHConnection.cancelRemoteForwardingcCs|t�d|���t�|�\}}t�|j�t�|�|d|jvr8|j|d}t�d|���t||||d�Sttjd��)NzFTCP r4zconnect forwarding )�remoteWindow�remoteMaxPacketr�zdon't know about that port)	rr�r�unpackOpen_forwarded_tcpipr0�SSHConnectForwardingChannelrr
�OPEN_CONNECT_FAILED)r;�
windowSize�	maxPacketr��remoteHP�origHP�	connectHPr=r=r>�channel_forwarded_tcpip\s
��z%SSHConnection.channel_forwarded_tcpipcCsVt�d|���t�|j�t|j�dkrt�d�t�dS|jjd�||�dS)Nzconnection closing r4zstopping connectionr)rr��channelsr6r��	__class__�	__bases__�
channelClosed)r;rr=r=r>r�ls

zSSHConnection.channelClosedN)rQrRrSr�r�r�r�r�r�r�r�r=r=r=r>r�3s
r�c@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)r�ssessionc	s�t�d�j�d��tdr�jj�dddd�}|�dd	��td
r%dStdr-tds1td
s4t�t�	�}tdrHtd
sHd�_
�j|_n�j
|_�fdd	�|_t�|��_d}tdrn�j��dt�td��dStdr�tdr�tjd}t�|tjd�}t�d|�}t�||d�}�j��d|�t�tj�j��j��dt�td��dStd
s�tjd}t�|tjd�}t�d|�}t�||d�}�j��d|�t�tj�j��j��dd�dS)Nzsession z openr�sauth-agent-req@openssh.comr�r4r�cSs
t�|�Sr�r���xr=r=r>rd�s
z(SSHSession.channelOpen.<locals>.<lambda>r$r)r r"rcs���Sr�)�sendEOFr�r�r=r>rd�srr&s	subsystem�TERM�12345678�4H�spty-reqsexecsshell)rr��idrhr��sendRequestr��
_enterRawModer�SSHSessionClient�
escapeMode�handleInput�dataReceived�write�connectionLostr�
StandardIOr	�NSr��environ�fcntl�ioctlr �
TIOCGWINSZ�struct�unpack�packRequest_pty_reqrxr}�_windowResized)	r;�foor��cr��term�winsz�winSize�
ptyReqDatar=r�r>�channelOpen{sJ�


zSSHSession.channelOpenc	Cs&|dvrd|_|�|�dS|jdkr|tdkrd|_dS|jdkr�d|_|dkr4t�d�t�dS|dkrDdd	�}t�d
|�dS|dkrUt�d�|jj	�
�dS|d
kr�|j�d�|jj�
�}|��|D]}|j�td�||jj|���qkdS|�d|�dSd
|_|�|�dS)N)�
�
r4rr3�.zdisconnecting from escape�cSs6t�tj��tj��t�t��tj	�t
�dSr�)�
_leaveRawModer9rm�flushrsr��kill�getpidrx�SIGTSTPr�r=r=r=r>�_�s



z!SSHSession.handleInput.<locals>._r�Rzrekeying connection�#s'
The following connections are open:
z
  #{} {}
�~)r�r�rhrr�r�r
rar�r��sendKexInitrr��keys�sortrr�)r;�charrr��	channelIdr=r=r>r��sF



���zSSHSession.handleInputcCs|j�|�dSr�)rr��r;r�r=r=r>r���zSSHSession.dataReceivedcCsT|tjkr(t�dt|��d��ttj�tkr tjj	�
|�dStj�
|�dSdS)Nzgot z stderr data)r
�EXTENDED_DATA_STDERRrr�r6rr9ro�str�bufferr�)r;r!r�r=r=r>�extReceived�s
�zSSHSession.extReceivedcCst�d�|j��dS)Nzgot eof)rr�r�loseWriteConnectionr�r=r=r>�eofReceived�s
zSSHSession.eofReceivedcCs t�d|���|j�|�dS)Nzremote side closed )rr�r��	sendCloser�r=r=r>�
closeReceived�szSSHSession.closeReceivedcCs&t�d|���t�t|jj��dS)Nzclosed )rr�r�r�r�r�r=r=r>�closed�szSSHSession.closedcCs(tt�d|�d�at�dt���dS)Nz>Lrz
exit status: )rCrrr�rr�r#r=r=r>�request_exit_status�szSSHSession.request_exit_statuscCs|j�|�dSr�)r�r�r�r=r=r>r��r$zSSHSession.sendEOFcC�|j��dSr�)r�pauseProducingr�r=r=r>�stopWriting��zSSHSession.stopWritingcCr/r�)r�resumeProducingr�r=r=r>�startWriting�r2zSSHSession.startWritingcGsZt�dtjd�}t�d|�}|d|d|d|df}|j�|dtjdg|�R��dS)	Nrr�r�r4r3r�s
window-changez!4L)	rrr rrrr�r��pack)r;r�r
r�newSizer=r=r>r	�s"zSSHSession._windowResizedN)rQrRrS�namerr�r�r(r*r,r-r.r�r1r4r	r=r=r=r>r�ws+-r�c@�eZdZdS)r�N�rQrRrSr=r=r=r>r��r�c@r8)r�Nr9r=r=r=r>r�r:r�cCs*tsdStj��}t�|tjt�dadSr`)�
_inRawModer9rsrtr r{r|�
_savedRawMode)r�r=r=r>rs

rcCsVtrdStj��}z
t�|�}|dd�}Wnty%t�d�YdSw|dtj	B|d<|dtj
tjBtjBtj
BtjBtjBtjB@|d<ttd�rZ|dtj@|d<|dtjtjBtjBtjBtjBtjBtjB@|d<ttd�r�|dtj@|d<|dtj@|d<d|dtj<d|dtj<|at�|tj|�dadS)Nznot a typewriter!r�IUCLCr��IEXTENr4�) r;r9rsrtr rurwrr��IGNPAR�ISTRIP�INLCR�IGNCR�ICRNL�IXON�IXANY�IXOFFr�r=�ISIG�ICANON�ECHO�ECHOE�ECHOK�ECHONLr>�OPOST�VMIN�VTIMEr<r{r|)r�rv�newr=r=r>r�sd

�������
�
	������
�
	r��__main__):rr�r�rxrr9r �typingrr�twisted.conch.clientrr�twisted.conch.client.optionsr�twisted.conch.errorr�twisted.conch.sshrr	r
rr�twisted.internetr
rrr�rr�twisted.python.compatrrrrhr�r�rvr;r<rzr�r�rrr�r�rbr�r�r�r��
SSHChannelr�r�r�rr�rQr=r=r=r>�<module>sTW<
$D
	2
�

Spamworldpro Mini