Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/werkzeug/debug/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/werkzeug/debug/__pycache__/__init__.cpython-312.pyc

�

'ٜg0N����UddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
ZddlZddl
mZddlmZddlmZddlmZddlmZddlmZdd	lmZd
dlmZd
dlmZd
d
lmZd
dlm Z d
dl!m"Z"d
dl#m$Z$d
dl%m&Z&d
dl'm(Z(d
dl)m*Z*ddl+m,Z,ddl-m.Z.ddl-m/Z/ddl-m0Z0ejbrddl2m3Z3ddl2m4Z4ddl2m5Z5dZ6d&d�Z7da8de9d<d'd �Z:Gd!�d"�Z;				d(d#�Z<Gd$�d%�Z=y))�)�annotationsN)�	ExitStack)�BytesIO)�chain)�Value)�basename)�join)�adler32�)�_log)�NotFound)�
SecurityError)�parse_cookie)�host_is_trusted)�gen_salt)�	send_file)�Request)�Response�)�Console)�DebugFrameSummary)�DebugTraceback)�render_console_html)�
StartResponse)�WSGIApplication)�WSGIEnvironmenti�:	c�t�tj|�d�jdd��j�ddS)Nz added saltzutf-8�replace�)�hashlib�sha1�encode�	hexdigest)�pins �B/usr/local/lib/python3.12/site-packages/werkzeug/debug/__init__.py�hash_pinr&,s7���<�<�3�%�{�+�2�2�7�I�F�G�Q�Q�S�TW�UW�X�X��str | bytes | None�_machine_idc�<�t�tSdd�}|�atS)Nc���d}dD]?}	t|d�5}|j�j�}ddd�s�:||z
}n	tdd�5}||j�j�j	d�dz
}ddd�|r|S	ddlm}dd	lm}|gd
�|��j�d}tjd|�}|�|jd
�S	tjdk(r�ddl}	|j!|j"dd|j$|j&z�5}	|j)|	d�\}
}||j*k(r|
j-�cddd�S|
cddd�Sy#1swY��MxYw#t$rY���wxYw#1swY��xYw#t$rY��%wxYw#ttf$rY��wxYw#1swYyxYw#t$rYywxYw)Nr')z/etc/machine-idz/proc/sys/kernel/random/boot_id�rbz/proc/self/cgroup�/rr)�PIPE)�Popen)�ioregz-c�IOPlatformExpertDevicez-d�2)�stdouts"serial-number" = <([^>]+)r�win32zSOFTWARE\Microsoft\Cryptography�MachineGuid)�open�readline�strip�OSError�
rpartition�
subprocessr.r/�communicate�re�search�group�ImportError�sys�platform�winreg�OpenKey�HKEY_LOCAL_MACHINE�KEY_READ�KEY_WOW64_64KEY�QueryValueEx�REG_SZr")�linux�filename�f�valuer.r/�dump�matchrC�rk�guid�	guid_types            r%�	_generatez!get_machine_id.<locals>._generate9s�����M�H�
��(�D�)�Q��J�J�L�.�.�0�E�*�
������M�	��)�4�0�A������+�+�-�8�8��>�q�A�A��1�
��L�	�
(�(��D�T���k�m�A��D��I�I�;�T�B�E�� ��{�{�1�~�%�!��<�<�7�"��
��^�^��-�-�7���O�O�f�&<�&<�<�	�
�'-�&9�&9�"�m�&L�O�D�)� �F�M�M�1�#�{�{�}��� ���"�y*�)���
��
��1�0���	��	��(��%�	��	���"���
���
�s��F�E?�F�F)�4F�F)�AF9�5G�54G�)	G�3G�4	G�?F		�F�	F�F�F&�!F)�)	F6�5F6�9G�
G�G�G�G�	G&�%G&��returnr()r))rSs r%�get_machine_idrV3s&������B�H�+�K��r'c� �eZdZdZdd�Zdd�Zy)�
_ConsoleFramez]Helper class so that we can reuse the frame console code for the
    standalone console.
    c�2�t|�|_d|_y)Nr)r�console�id)�self�	namespaces  r%�__init__z_ConsoleFrame.__init__�s���y�)�����r'c�8�|jj|�S�N)rZ�eval)r\�codes  r%raz_ConsoleFrame.eval�s���|�|� � ��&�&r'N)r]zdict[str, t.Any])rb�strrUzt.Any)�__name__�
__module__�__qualname__�__doc__r^ra�r'r%rXrX�s����'r'rXc
�z���tjjd�}d}d�|dk(ry|�)|jdd�j	�r	d|vr|}n|�t|dt
jt|�jj�}	tj�}t j"j|�}||t|dt%|�j&�t|d	d�g}t)t+j,��t/�g}t1j2�}t5||�D]6}	|	s�t7|	t(�r|	j9�}	|j;|	��8|j;d
�d|j=�dd��}
��0|j;d
�t?|j=�d�d�dd�|�NdD]G�tA���zdk(s�djC��fd�tEdtA����D��}||
fS�}||
fS#tttf$rd}Y���wxYw)aQGiven an application object this returns a semi-stable 9 digit pin
    code and a random key.  The hope is that this is stable between
    restarts to not make debugging particularly frustrating.  If the pin
    was forcefully disabled this returns `None`.

    Second item in the resulting tuple is the cookie name for remembering.
    �WERKZEUG_DEBUG_PINN�off)NN�-�rerd�__file__s
cookiesalt�__wzd�spinsalt��09d�	)���rc3�N�K�|]}�||�zj�d����y�w)�0N)�rjust)�.0�x�
group_size�nums  ��r%�	<genexpr>z*get_pin_and_cookie_name.<locals>.<genexpr>�s1������;����A�
�N�+�1�1�*�c�B�;�s�"%)#�os�environ�getr�	isdecimal�getattr�t�cast�object�	__class__re�getpass�getuserr@�KeyErrorr9rA�modules�typerdrc�uuid�getnoderVr r!r�
isinstancer"�updater#�int�lenr	�range)
�appr$�rv�modname�username�mod�probably_public_bits�private_bits�h�bit�cookie_namer|r}s
           @@r%�get_pin_and_cookie_namer��s���
�*�*�.�.�-�
.�C�	
�B�
�C��e�|����3�;�;�s�B�/�9�9�;��#�:��B��C��c�<������)<�)F�)F�)Q�)Q�R�G���?�?�$��
�+�+�/�/�'�
"�C�
	����Z��c��!3�!3�4���Z��&�	�������'��)9�:�L�����A��)�<�8�����c�3���*�*�,�C�	����
�9��H�H�]���!�+�+�-���,�-�.�K��{�	������Q�[�[�]�B�'��,�b�q�1��
�z�!�J��3�x�*�$��)��X�X��"�1�c�#�h�
�;������{�?��"��B�
�{�?���c
��7�+�����s�H � H:�9H:c�"�eZdZUdZded<ded<							d																	dd�Zedd��Zejdd��Zedd	��Z							dd
�Z
								dd�Zdd�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Z						d d�Zy)!�DebuggedApplicationa4Enables debugging support for a given application::

        from werkzeug.debug import DebuggedApplication
        from myapp import app
        app = DebuggedApplication(app, evalex=True)

    The ``evalex`` argument allows evaluating expressions in any frame
    of a traceback. This works by preserving each frame with its local
    state. Some state, such as context globals, cannot be restored with
    the frame by default. When ``evalex`` is enabled,
    ``environ["werkzeug.debug.preserve_context"]`` will be a callable
    that takes a context manager, and can be called multiple times.
    Each context manager will be entered before evaluating code in the
    frame, then exited again, so they can perform setup and cleanup for
    each call.

    :param app: the WSGI application to run debugged.
    :param evalex: enable exception evaluation feature (interactive
                   debugging).  This requires a non-forking server.
    :param request_key: The key that points to the request object in this
                        environment.  This parameter is ignored in current
                        versions.
    :param console_path: the URL for a general purpose console.
    :param console_init_func: the function that is executed before starting
                              the general purpose console.  The return value
                              is used as initial namespace.
    :param show_hidden_frames: by default hidden traceback frames are skipped.
                               You can show them by setting this parameter
                               to `True`.
    :param pin_security: can be used to disable the pin based security system.
    :param pin_logging: enables the logging of the pin system.

    .. versionchanged:: 2.2
        Added the ``werkzeug.debug.preserve_context`` environ key.
    rc�_pin�_pin_cookieNc	��|sd}||_||_i|_i|_||_||_||_||_td�|_	td�|_||_|ratjjd�dk(rF|rDt!dd�|j"�
t!dd�nt!dd	|j"�nd|_d
dg|_y)Nrp�B�WERKZEUG_RUN_MAIN�true�warningz * Debugger is active!z- * Debugger PIN disabled. DEBUGGER UNSECURED!�infoz * Debugger PIN: %sz
.localhostz	127.0.0.1)r��evalex�frames�frame_contexts�request_key�console_path�console_init_func�show_hidden_framesr�secretr�_failed_pin_auth�pin_loggingrr�r�rr$�
trusted_hosts)	r\r�r�r�r�r�r��pin_securityr�s	         r%r^zDebuggedApplication.__init__
s���!� $��������DF���GI���&���(���!2���"4����r�l��� %�c�
���&�����z�z�~�~�1�2�f�<���Y� 8�9��8�8�#���$S�T���!6����A��D�H�)5�{�(C���	r'c�z�t|d�s$t|j�}|\|_|_|jS)Nr���hasattrr�r�r�r��r\�
pin_cookies  r%r$zDebuggedApplication.pin9s3���t�V�$�0����:�J�*4�'�D�I�t�'��y�y�r'c��||_yr`)r�)r\rMs  r%r$zDebuggedApplication.pin@s	����	r'c�z�t|d�s$t|j�}|\|_|_|jS)zThe name of the pin cookie.r�r�r�s  r%�pin_cookie_namez#DebuggedApplication.pin_cookie_nameDs7���t�]�+�0����:�J�*4�'�D�I�t�'����r'c#�rK�g}|jr|j|d<d}	|j||�}|Ed{���t|d�r|j	�yy7�"#t
$�rK}t|d�r|j	�t
|d|j��}|jD]2}||jt|�<||jt|�<�4t|j|��}|j|jxr|j|�|j |��}	t#|	dd�	�}
	|
||�Ed{���7n##t
$r|d
j%d�YnwxYw|d
j%dj'|j)���Yd}~yd}~wwxYw�w)
z6Run the application and conserve the traceback frames.zwerkzeug.debug.preserve_contextN�closer)�skip�hide)r�r��evalex_trustedi��	text/html)�status�mimetypezwsgi.errorszpDebugging middleware caught exception in streamed response at a point where response headers were already sent.
rm)r��appendr�r�r��	Exceptionrr��
all_framesr�r[r��bool�check_pin_trust�render_debugger_html�check_host_trustr�r�writer	�render_traceback_text)r\r��start_response�contexts�app_iter�e�tb�frame�
is_trusted�html�responses           r%�debug_applicationz%DebuggedApplication.debug_applicationLs�����35���;�;�9A���G�5�6���$	N��x�x���8�H�����x��)���� �*�
 ���	N��x��)���� ����D�4K�4K�0K�L�B�����).����B�u�I�&�19��#�#�B�u�I�.�'��d�2�2�7�;�<�J��*�*��{�{�E�t�'<�'<�W�'E��{�{�)�+��D�
 ��S�;�G�H�
�#�G�^�<�<�<���	
�
�
�&�,�,���	
��
�M�"�(�(�����1I�1I�1K�)L�M�M��?	N�so� F7�A�A� A�F7�A�
F4�)CF/�E�E�E�F/�E6�3F/�5E6�64F/�*F7�/F4�4F7c�>�|j|j�s
t�S|jj	t|�g�}t
�5}|D]}|j|��t|j|�d��cddd�S#1swYyxYw)zExecute a command in a console.r��r�N)
r�r�rr�r�r[r�
enter_contextrra)r\�request�commandr�r��
exit_stack�cms       r%�execute_commandz#DebuggedApplication.execute_command|sx���$�$�W�_�_�5� �?�"��&�&�*�*�2�e�9�b�9��
�[�J����(�(��,���E�J�J�w�/�+�F�	�[�[�s�4B�Bc��|j|j�s
t�Sd|jvr\|j�i}nt|j	��}|j
d|j�t|�|jd<t|j|j��}tt|j|��d��S)zDisplay a standalone shell.rr�)r�r�r�r�)r�r�rr�r��dict�
setdefaultr�rXr�r�rrr�)r\r��nsr�s    r%�display_consolez#DebuggedApplication.display_console�s����$�$�W�_�_�5� �?�"��D�K�K���%�%�-����$�0�0�2�3���M�M�%����*�*�2�.�D�K�K��N��$�.�.�w���?�@�
���t�{�{�:�N� �
�	
r'c��tdt|��}	tjt|�}|�
t�St
t|�dz�}tt|�|j||��S#t$r
t�cYSwxYw)z0Return a static resource from the shared folder.�sharedl��)�
download_name�etag)r	r�pkgutil�get_data�__package__r
rcr
rrr�r9)r\r�rK�path�datar�s      r%�get_resourcez DebuggedApplication.get_resource�s����H�h�x�0�1��	��#�#�K��6�D��|��z�!��w�t�}�z�1�2�D����
�w���h�T��
���	��:��	�s�A6�6B�Bc�@�|j�yt|�j|j�}|rd|vry|j	dd�\}}	t|�}|t|j�k7rytj�tz
|kS#t$rYywxYw)a!Checks if the request passed the pin test.  This returns `True` if the
        request is trusted on a pin/cookie basis and returns `False` if not.
        Additionally if the cookie's stored pin hash is wrong it will return
        `None` so that appropriate action can be taken.
        NT�|Fr)
r$rr�r��splitr��
ValueErrorr&�time�PIN_TIME)r\r��val�ts_str�pin_hash�tss      r%r�z#DebuggedApplication.check_pin_trust�s����8�8����7�#�'�'��(<�(<�=���c��n���9�9�S�!�,����	��V��B��x����)�)���	�	��h�&�"�,�,���	��	�s�B�	B�Bc�L�t|jd�|j�S)N�	HTTP_HOST)rr�r�)r\r�s  r%r�z$DebuggedApplication.check_host_trust�s���w�{�{�;�7��9K�9K�L�Lr'c��|jj�5|jj}|dz|j_ddd�tjdkDrd�yd�y#1swY�+xYw)Nrrtg@g�?)r��get_lockrMr��sleep)r\�counts  r%�_fail_pin_authz"DebuggedApplication._fail_pin_auth�s^��
�
"�
"�
+�
+�
-��)�)�/�/�E�*/�!�)�D�!�!�'�.�	
�
�
�%�!�)�3�-��-�	.�
-�s�+A0�0A9c�@�|j|j�s
t�Sd}d}|j|j�}t	j
t|j�}d}|�|j�d}n�|rd}n�|jjdkDrd}nf|jd}|j�jdd�|jdd�k(rd|j_
d}n|j�ttj ||d��d	�
�}|rU|j#|j$t't)j(���dt+|���dd|j,�
�|S|r|j/|j$�|S)zAuthenticates with the pin.FT�
r$rlrmr)�auth�	exhaustedzapplication/jsonr�r��Strict)�httponly�samesite�secure)r�r�rr�r�r�rcr$r�r�rM�argsr8rr�json�dumps�
set_cookier�r�r�r&�	is_secure�
delete_cookie)	r\r�rr�trustr$�
bad_cookie�entered_pinr�s	         r%�pin_authzDebuggedApplication.pin_auth�sw���$�$�W�_�_�5� �?�"��	����$�$�W�_�_�5���f�f�S�$�(�(�#���
��=����!��J���D��
"�
"�
(�
(�2�
-��I�"�,�,�u�-�K�� � �"�*�*�3��3�s�{�{�3��7K�K�./��%�%�+����#�#�%�
��J�J��9�=�>�'�
����M�M��$�$��t�y�y�{�#�$�A�h�s�m�_�5��!��(�(�
�
��	�����T�1�1�2��	r'c���|j|j�s
t�S|jr/|j�#tdd�tdd|j�t
d�S)zLog the pin if needed.r�z= * To enable the debugger you need to enter the security pin:z * Debugger pin code: %srm)r�r�rr�r$rr)r\r�s  r%�log_pin_requestz#DebuggedApplication.log_pin_requestsY���$�$�W�_�_�5� �?�"������� 4���W�
�
��3�T�X�X�>���|�r'c�n�t|�}|j}|jjd�dk(�r5|jjd�}|jjd�}|jjd�}|jj|jjdt
���}|dk(r|r|j
||�}n�|d	k(r!||jk(r|j|�}n�|d
k(r!||jk(r|j|�}n�|jrz|�x|�v|j|k(rg|j|�rV|j|||�}nB|jr6|j�*|j|jk(r|j|�}|||�S)zDispatch the requests.�__debugger__�yes�cmdrL�s�frm)r��resource�pinauth�printpin)rr�rr�r�r�r�r�rrr�r�r�r�r�r�)	r\r�r�r�r�r�argr�r�s	         r%�__call__zDebuggedApplication.__call__st���'�"���)�)���<�<���N�+�u�4��,�,�"�"�5�)�C��,�,�"�"�3�'�C��\�\�%�%�c�*�F��K�K�O�O�G�L�L�$4�$4�U��$4�$E�F�E��j� �S��,�,�W�c�:���	�!�f����&;��=�=��1���
�"�v����'<��/�/��8������O��%��K�K�6�)��(�(��1��/�/���e�D���K�K��!�!�-����� 1� 1�1��+�+�G�4�H����0�0r')Fzwerkzeug.requestz/consoleNFTT)r�rr�r�r�rcr�rcr�z't.Callable[[], dict[str, t.Any]] | Noner�r�r�r�r�r�rU�None)rUz
str | None)rMrcrUr)rUrc)r�rr�rrUzt.Iterator[bytes])r�rr�rcr�z!DebugFrameSummary | _ConsoleFramerUr)r�rrUr)r�rrKrcrUr)r�rrUzbool | None)r�rrUr�)rUr)r�rr�rrUzt.Iterable[bytes])rdrerfrg�__annotations__r^�propertyr$�setterr�r�r�r�r�r�r�r�rrrrhr'r%r�r��s_��"�H�I���
�-�&�EI�#(�!� �*�
�*��*��	*�
�*�C�
*�!�*��*��*�
�*�X����	�Z�Z����� �� �.N�&�.N�8E�.N�	�.N�`G��G��G�1�	G�

�G�$
�$�"-�,M�.�4�l
�"1�&�"1�8E�"1�	�"1r'r�)r$rcrUrcrT)r�rrUz#tuple[str, str] | tuple[None, None])>�
__future__rr�r r	rr�r=rAr��typingr�r��
contextlibr�ior�	itertoolsr�multiprocessingr�os.pathrr	�zlibr
�	_internalr�
exceptionsr
r�httpr�sansio.utilsr�securityr�utilsr�wrappers.requestr�wrappers.responserrZr�tbtoolsrrr�
TYPE_CHECKING�_typeshed.wsgirrrr�r&r)r rVrXr�r�rhr'r%�<module>r6s���"����	��	�
���� ���!�����!�&��*���&�(��&�#�(��?�?�,�.�.���Y�#'��
�&�K�\
'�
'�T�	�T�(�T�nP1�P1r'

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists