shell bypass 403
�
%f�@ � �L � d Z ddlZdZddlZddlZddlmZ ddlmZ ddl m
Z
mZmZ dd l
mZ dd
lmZmZ ddlmZmZmZ ddlmZmZ d
ZdZ G d� de� Zd� Z G d� de� Z G d� de� Z G d� de� Z G d� de� Z! G d� de!� Z" G d� de!� Z#y# dZY ��xY w)z4Implementation of communication for MySQL X servers.� NTF��wraps� )�MySQL41AuthPlugin)�InterfaceError�OperationalError�ProgrammingError��Schema)�Protocol�MessageReaderWriter)�Result� RowResult� DocResult)�SqlStatement�AddStatementzDROP DATABASE IF EXISTS `{0}`z#CREATE DATABASE IF NOT EXISTS `{0}`c �4 � e Zd Zd� Zd� Zd� Zd� Zd� Zi fd�Zy)�SocketStreamc � � d | _ d| _ y )NF)�_socket�_is_ssl��selfs �H/usr/local/python-3.12/lib/python3.12/site-packages/mysqlx/connection.py�__init__zSocketStream.__init__2 s � ������� c �� � t |t � rt j nt j }t j |t j
� | _ | j j |� y �N)�
isinstance�tuple�socket�AF_INET�AF_UNIX�SOCK_STREAMr �connect)r �params�s_types r r% zSocketStream.connect6 sD � �#-�f�e�#<����&�.�.���}�}�V�V�-?�-?�@��������V�$r c � � | j �t d� �g }|dkD rP| j j |� }|dk( rt d� �|j |� |t |� z }|dkD r�Pdj
|� S )N�MySQLx Connection not availabler r zUnexpected connection close)r r �recv�RuntimeError�append�len�join)r �count�buf�datas r �readzSocketStream.read; s~ � ��<�<��"�#D�E�E����a�i��<�<�$�$�U�+�D��s�{�"�#@�A�A��J�J�t���S��Y��E� �a�i� �x�x��}�r c �h � | j �t d� �| j j |� y )Nr) )r r �sendall�r r1 s r r4 zSocketStream.sendallG s* � ��<�<��"�#D�E�E������T�"r c �` � | j sy | j j � d | _ y r )r �closer s r r7 zSocketStream.closeL s# � ��|�|����������r c � � t s| j � t d� �t j t j
� }|j
� d|v r* |j |d � t j |_ d|v r* |j |d � t j |_ d|v r' |j |d |j! dd � � nd|v r| j � t d � �|j# | j$ � | _ d
| _ y # t t j f$ r | j � t d� �w xY w# t t j f$ r | j � t d� �w xY w# t t j f$ r | j � t d� �w xY w)Nz'Python installation has no SSL support.zssl-cazInvalid CA certificate.zssl-crlzInvalid CRL.zssl-certzssl-keyzInvalid Client Certificate/Key.z Client Certificate not provided.T)�
SSL_AVAILABLEr7 r+ �ssl�
SSLContext�PROTOCOL_SSLv23�load_default_certs�load_verify_locations�
CERT_REQUIRED�verify_mode�IOError�SSLErrorr �VERIFY_CRL_CHECK_CHAIN�verify_flags�load_cert_chain�get�wrap_socketr r )r �ssl_opts�contexts r �set_sslzSocketStream.set_sslS s� � ���J�J�L��H�I�I��.�.��!4�!4�5���"�"�$��x��
@��-�-�h�x�.@�A�&)�&7�&7��#� �� �
5��-�-�h�y�.A�B�'*�'A�'A��$� ��!�
H��'�'���(<��L�L��D�1�3�
�(�
"��J�J�L� �!C�D�D��*�*�4�<�<�8�������- �S�\�\�*�
@��
�
��$�%>�?�?�
@�� �S�\�\�*�
5��
�
��$�^�4�4�
5�� �S�\�\�*�
H��
�
��$�%F�G�G�
H�s$ �)D# �)E �6%F �#5E�5F�5GN) �__name__�
__module__�__qualname__r r% r2 r4 r7 rJ � r r r r 1 s% � ��%�
�#�
� "� !r r c �. � � t � � � fd�� }|S )Nc � �� �| g|��i |��S # t j t f$ r | j � t d� �w xY w)NzCannot connect to host.)r! �errorr+ �
disconnectr )r �args�kwargs�funcs �r �wrapperz(catch_network_exception.<locals>.wrapperx sK �� � <���.�t�.�v�.�.�����l�+� <��O�O�� �!:�;�;� <�s � �5Ar )rU rV s ` r �catch_network_exceptionrW w s �� �
�4�[�<� �<� �Nr c �� � e Zd Zd� Zd� Zd� Zd� Zd� Zd� Ze d� � Z
e d� � Ze d � � Ze d
� � Z
e d� � Ze dd�� Ze d
� � Ze d� � Ze d� � Ze d� � Ze d� � Zd� Zd� Zd� Zy)�
Connectionc �� � |j d� | _ |j d� | _ |j d� | _ d | _ || _ t
� | _ d | _ d | _ y )N�user�password�schema)
rF �_user� _password�_schema�_active_result�settingsr �stream�
reader_writer�protocol�r rb s r r zConnection.__init__� sY � ��\�\�&�)��
�!���j�1����|�|�H�-���"��� ��
�"�n���!�����
r c �` � | j �"| j j � d | _ y y r )ra � fetch_allr s r �fetch_active_resultzConnection.fetch_active_result� s- � ����*����)�)�+�"&�D�� +r c � � d| j v r+| j d | j j dd� fS d| j v r| j d S y)N�host�port�$� r! )� localhostrm )rb rF r s r �_connection_paramszConnection._connection_params� sQ � ��T�]�]�"��=�=��(�$�-�-�*;�*;�F�E�*J�J�J��t�}�}�$��=�=��*�*�$r c � � | j j | j � � t | j � | _ t | j � | _ | j � | j � y r ) rc r% ro r
rd r re �_handle_capabilities�
_authenticater s r r% zConnection.connect� sX � ������D�3�3�5�6�0����=��� ��!3�!3�4��
��!�!�#����r c � � | j j � j }|r!|d j j � dk( s:n | j
j
dd� r| j � t d� �y t j dk r8| j
j
dd� r| j � t d� �y | j j d� � | j j | j
� y )
Nr �tlsFz
ssl-enablezSSL not enabled at server.)� � � z=The support for SSL is not available for this Python version.T)rt )re �get_capabilites�capabilities�name�lowerrb rF r7 r �sys�version_infor+ �set_capabilitiesrc rJ r5 s r rq zConnection._handle_capabilities� s� � ��}�}�,�,�.�;�;��15��Q����"�"�$��-�5��}�}� � ��u�5��
�
��&�'C�D�D�����i�'��}�}� � ��u�5��
�
��"� $+� ,� ,���
�
�&�&�4�&�0������D�M�M�*r c �R � t | j | j � }| j j |j � � | j j
� }| j j |j |� � | j j � y r )
r r^ r_ re �send_auth_start� auth_name�read_auth_continue�send_auth_continue�build_authentication_response�read_auth_ok)r �plugin�
extra_datas r rr zConnection._authenticate� ss � �"�4�:�:�t�~�~�>���
�
�%�%�f�&6�&6�&8�9��]�]�5�5�7�
��
�
�(�(��0�0��<� >��
�
�"�"�$r c �>