shell bypass 403
o
_bTR � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
Z
ddlZddlZdd� Zdd� Zd*dd�ZG d d
� d
ej�ZdZdZG d
d� de
j�Zi Ze�d�Ze�d�ZG dd� d�ZG dd� d�Zdd� ZG dd� d�Z G dd� de
j!e�Z"G dd� de�Z#G dd� d�Z$dd� Z%dd � Z&G d!d"� d"�Z'd#d$� Z(e)d%kr�dd&l*m+Z+ e+d'd(d)� dS dS )+a RPC Implementation, originally written for the Python Idle IDE
For security reasons, GvR requested that Idle's Python execution server process
connect to the Idle process, which listens for the connection. Since Idle has
only one client per server, this was not a limitation.
+---------------------------------+ +-------------+
| socketserver.BaseRequestHandler | | SocketIO |
+---------------------------------+ +-------------+
^ | register() |
| | unregister()|
| +-------------+
| ^ ^
| | |
| + -------------------+ |
| | |
+-------------------------+ +-----------------+
| RPCHandler | | RPCClient |
| [attribute of RPCServer]| | |
+-------------------------+ +-----------------+
The RPCServer handler class is expected to provide register/unregister methods.
RPCHandler inherits the mix-in class SocketIO, which provides these methods.
See the Idle run.main() docstring for further information on how this was
accomplished in Idle.
� Nc C s t �| �}|S )z*Return code object from marshal string ms.)�marshal�loads)�ms�co� r �4/usr/local/python-3.10/lib/python3.10/idlelib/rpc.py�
unpickle_code- s
r c C s t �| �}t|ffS )zBReturn unpickle function and tuple with marshalled co code object.)r �dumpsr )r r r r r �pickle_code3 s
r
c C s$ t �� }t||�}|�| � |�� S )z.Return pickled (or marshalled) string for obj.)�io�BytesIO�CodePickler�dump�getvalue)�obj�protocol�f�pr r r r 9 s
r c @ s e Zd Zejeiej�ZdS )r
N)�__name__�
__module__�__qualname__�types�CodeTyper
�copyreg�dispatch_tabler r r r r
B s r
i z 127.0.0.1c @ s6 e Zd Zddd�Zdd� Zdd� Zdd � Zd
d� ZdS )
� RPCServerNc C s |d u rt }tj�| ||� d S �N)�
RPCHandler�socketserver� TCPServer�__init__)�self�addrZhandlerclassr r r r K s zRPCServer.__init__c C � dS )z@Override TCPServer method, no bind() phase for connecting entityNr �r! r r r �server_bindP � zRPCServer.server_bindc C s | j �| j� dS )z�Override TCPServer method, connect() instead of listen()
Due to the reversed connection, self.server_address is actually the
address of the Idle Client to which we are connecting.
N)�socket�connect�server_addressr$ r r r �server_activateT s zRPCServer.server_activatec C s | j | jfS )z:Override TCPServer method, return already connected socket)r'