HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/websocket/__pycache__/_wsdump.cpython-310.pyc
o

�hb�
@sBdZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlZzddlZWn	e
y;Ynwdefdd�ZejjejjfZe�ZGdd�dej�Zdejfd	d
�ZGdd�d�ZGd
d�deej�ZGdd�de�Zddd�Zedkr�ze�WdSey�Zze e�WYdZ[dSdZ[wwdS)a`
wsdump.py
websocket - WebSocket client library for Python

Copyright 2024 engn33r

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
�N)�urlparse�returncCsttjdd�}|sdS|��S)N�encoding��utf-8)�getattr�sys�stdin�lower)r�r�D/usr/local/CyberCP/lib/python3.10/site-packages/websocket/_wsdump.py�get_encoding(sr
c@s0eZdZ	d	dejdedededdf
dd�ZdS)
�VActionN�parser�args�values�
option_stringrcCsL|durd}zt|�}Wnty|�d�d}Ynwt||j|�dS)N�1�v�)�int�
ValueError�count�setattr�dest)�selfrrrrrrr�__call__5s�zVAction.__call__)N)�__name__�
__module__�__qualname__�argparse�	Namespace�tuple�strrrrrrr4s������rc	Cs�tjdd�}|jdddd�|jddd	d
�|jddd
dtddd�|jddddd�|jddddd�|jddddd�|jdd d!d
�|jd"d
td#d$�|jd%d&d'd
�|jd(dd)d�|jd*d+d
�|��S),NzWebSocket Simple Dump Tool)�description�url�ws_urlz.websocket url. ex. ws://echo.websocket.events/)�metavar�helpz-pz--proxyz$proxy url. ex. http://127.0.0.1:8080)r(z-vz	--verboser�?�verbosezZset verbose mode. If set to 1, show opcode. If set to 2, enable to trace  websocket module)�default�nargs�actionrr(z-nz--nocert�
store_truezIgnore invalid SSL cert)r-r(z-rz--rawz
raw outputz-sz--subprotocols�*zSet subprotocols)r,r(z-oz--originz
Set originz
--eof-waitz'wait time(second) after 'EOF' received.)r+�typer(z-tz--textzSend initial textz	--timingszPrint timings in secondsz	--headersz(Set custom headers. Use ',' as separator)r �ArgumentParser�add_argumentrr�
parse_args)rrrrr3Es@��
���r3c@s eZdZddedefdd�ZdS)�RawInputr�promptrcCsJt|�}trtdkrt|t�s|�t��d�}|St|t�r#|�d�}|S)Nr)�input�ENCODING�
isinstancer#�decode�encode)rr5�linerrr�	raw_inputks
�
zRawInput.raw_inputN)r)rrrr#r<rrrrr4jsr4c@�,eZdZdeddfdd�Zdefdd�ZdS)�InteractiveConsole�datarNcCs:tj�d�tj�d|d�tj�d�tj��dS)Nzz< zz
> �r�stdout�write�flush�rr?rrrrBwszInteractiveConsole.writecC�
|�d�S)Nz> �r<�rrrr�read~�
zInteractiveConsole.read�rrrr#rBrHrrrrr>vsr>c@r=)�NonInteractiver?rNcCs&tj�|�tj�d�tj��dS)N�
r@rDrrrrB�szNonInteractive.writecCrE)NrrFrGrrrrH�rIzNonInteractive.readrJrrrrrK�srKcsvt���t���jdkrt�d�i}�jr%t�j�}|j|d<|j|d<�j	r-�j	|d<�j
r5�j
|d<i}�jr@tj
dd�}�jrQtttj�j�d	���|d
<tj�jfd|i|����jrdt��nt��td�d
tf�fdd��d����fdd�}tj|d�}d|_|���jr��� �j�	z��!�}�� |�Wnt"y�YdSt#y�t�$�j%�YdSwq�)NrT�http_proxy_host�http_proxy_port�origin�subprotocolsF)�	cert_reqs�check_hostname�,�header�ssloptzPress Ctrl+C to quitrcs�z���}WntjytjjdfYSw|s!t�d|����|jtvr,|j|jfS|jtjjkr<���|jdfS|jtjj	krO��
|j�|j|jfS|j|jfS)NrzNot a valid frame )�
recv_frame�	websocket�WebSocketException�ABNF�OPCODE_CLOSE�opcode�OPCODE_DATAr?�
send_close�OPCODE_PING�pong)�frame)�wsrr�recv�s �

zmain.<locals>.recvcs*	��\}}d}|tjjkrt|t�rt|d�}t|t�r=t|�dkr=|dd�dkr=zdtt�|�d�}WnYnt|t�rVzdtt	�|t	j
�d�}WnYt|t�r_t|�}�jrotjj
�|��d|��}n|}|dur��jr���t����d|���n��|�|tjjkr�dSq)NTr�s�z[gzip] z[zlib] z: )rWrY�OPCODE_TEXTr8�bytesr#�len�gzip�
decompress�zlib�	MAX_WBITS�reprr*�
OPCODE_MAP�get�timingsrB�timerZ)r[r?�msg)r�consolerb�
start_timerr�recv_ws�s>

�

�

�zmain.<locals>.recv_ws)�target�rN)&ror3r*rW�enableTrace�proxyr�hostname�portrOrP�nocert�ssl�	CERT_NONE�headers�list�mapr#�strip�split�create_connectionr%�rawrKr>�printr"�	threading�Thread�daemon�start�text�sendrH�KeyboardInterrupt�EOFError�sleep�eof_wait)�options�p�optsrs�thread�messager)rrqrbrrrar�main�sR






&��r��__main__ru)!�__doc__r �codergr{rr�rori�urllib.parserrW�readline�ImportErrorr#r
rYrd�
OPCODE_BINARYr\r7�Actionrr!r3r4r>rKr�r�	Exception�er�rrrr�<module>sB�%

d���