CasperSecurity

Current Path : /lib/python3/dist-packages/serial/urlhandler/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/serial/urlhandler/__pycache__/protocol_spy.cpython-310.pyc

o

�1�_�#�@s�ddlmZddlZddlZddlZddlmZzddlZWney-ddl	m
ZYnwdd�Zdd�ZGdd	�d	e
�ZGd
d�de
�ZGdd
�d
ej�Zedkr`ed�Zde_ee�dSdS)�)�absolute_importN)�to_bytesccs��d}t�|�D]2}d�t|��d|krdkr!nn|�d�ndfV|d7}|dkr1d	Vq|d
kr:dVd}q|dkrZ|d
krU|d7}|dkrNd	VdV|d
ksCdVd
Sd
S)z�    yield tuples of hex and ASCII display in multiples of 16. Includes a
    space after 8 bytes and (None, None) after 16 bytes and at the end.
    rz{:02X} � ��ascii�.��)� ��)NN)z   r
N)�serial�	iterbytes�format�ord�decode)�data�n�b�r�@/usr/lib/python3/dist-packages/serial/urlhandler/protocol_spy.py�sixteen%s(�6��
�rccs~�g}g}d}t|�D]1\}}|dur2|d�d�|�d�|�g�fV|dd�=|dd�=|d7}q|�|�|�|�qdS)z yield lines with hexdump of datarNr
rr)r�join�append)r�valuesr�offset�h�arrr�hexdump<s� 



�rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�	FormatRawz&Forward only RX and TX data to output.cCs||_||_d|_d|_dS)N��)�output�color�rx_color�tx_color��selfr"r#rrr�__init__Os
zFormatRaw.__init__cC�.|jr
|j�|j�|j�|�|j��dS)zshow received dataN)r#r"�writer$�flush�r'rrrr�rxU�zFormatRaw.rxcCr))zshow transmitted dataN)r#r"r*r%r+r,rrr�tx\r.zFormatRaw.txcCsdS)z(do not) show control callsNr�r'�name�valuerrr�controlcszFormatRaw.controlN)�__name__�
__module__�__qualname__�__doc__r(r-r/r3rrrrrLsrc@s:eZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
S)�
FormatHexdumpax    Create a hex dump of RX ad TX data, show when control lines are read or
    written.

    output example::

        000000.000 Q-RX flushInput
        000002.469 RTS  inactive
        000002.773 RTS  active
        000003.001 TX   48 45 4C 4C 4F                                    HELLO
        000003.102 RX   48 45 4C 4C 4F                                    HELLO

    cCs,t��|_||_||_d|_d|_d|_dS)Nr r!z)�time�
start_timer"r#r$r%�
control_colorr&rrrr(ws

zFormatHexdump.__init__rcCs&|j�d�||||��|j��dS)Nz{:010.3f} {:4} {}{}
)r"r*rr+)r'�	timestamp�labelr2�value2rrr�
write_lineszFormatHexdump.write_linecCsj|jr
|j�|j�|r't|�D]\}}|�t��|jdd�|�|�qdS|�t��|jdd�dS)zshow received data as hex dump�RX�{:04X}  z<empty>N)	r#r"r*r$rr?r9r:r�r'rr�rowrrrr-�s"�zFormatHexdump.rxcCsJ|jr
|j�|j�t|�D]\}}|�t��|jdd�|�|�qdS)z!show transmitted data as hex dump�TXrAN)	r#r"r*r%rr?r9r:rrBrrrr/�s
"�zFormatHexdump.txcCs0|jr
|j�|j�|�t��|j||�dS)zshow control callsN)r#r"r*r;r?r9r:r0rrrr3�szFormatHexdump.controlN)r)	r4r5r6r7r(r?r-r/r3rrrrr8hs

r8csTeZdZdZ�fdd�Zejjjdd��Zdd�Z	�fdd	�Z
d,�fdd�	Zeejd
�r2�fdd�Z
eejd�r>�fdd�Ze�fdd��Z�fdd�Z�fdd�Z�fdd�Zd-�fdd�	Zejjjdd��Zejjjd d!��Zejjjd"d#��Zejjj�fd$d%��Zejjj�fd&d'��Zejjj�fd(d)��Zejjj�fd*d+��Z�ZS).�Serialzc    Inherit the native Serial port implementation and wrap all the methods and
    attributes.
    cs&tt|�j|i|��d|_d|_dS)NF)�superrEr(�	formatter�show_all)r'�args�kwargs��	__class__rrr(�s
zSerial.__init__cCs&|durtjj�||�|��dSdS�N)r
rE�port�__set__�from_url)r'r2rrrrN�s�zSerial.portc	
Cs�t�|�}|jdkrt�d�|j���t}d}tj}z8t�	|j
d���D],\}}|dkr4t|dd�}q$|dkr;d}q$|d	krBt
}q$|d
krJd|_q$td�|���Wntyf}zt�d�|���d
}~ww|||�|_d�|j|jg�S)z(extract host and port from an URL string�spyzmexpected a string in the form "spy://port[?option[=value][&option[=value]]]": not starting with spy:// ({!r})FT�filer�wr#�raw�allzunknown option: {!r}zPexpected a string in the form "spy://port[?option[=value][&option[=value]]]": {}Nr)�urlparse�urlsplit�schemer
�SerialExceptionrr8�sys�stderr�parse_qs�query�items�openrrH�
ValueErrorrGr�netloc�path)	r'�url�partsrGr#r"�optionr�errrrP�s<

�����zSerial.from_urlcs$t|�}|j�|�tt|��|�SrM)rrGr/rFrEr*)r'r/rKrrr*�szSerial.writercs*tt|��|�}|s
|jr|j�|�|SrM)rFrE�readrHrGr-)r'�sizer-rKrrrg�s
zSerial.read�cancel_readc� |j�dd�tt|���dS)N�Q-RXri)rGr3rFrEri�r'rKrrri��zSerial.cancel_read�cancel_writecrj)N�Q-TXrn)rGr3rFrErnrlrKrrrn�rmzSerial.cancel_writecs*tt|�j}|jr|j�dd�|��|S)Nrkzin_waiting -> {})rFrE�
in_waitingrHrGr3r)r'rrKrrrp�szSerial.in_waitingcrj)Nror+)rGr3rFrEr+rlrKrrr+�rmzSerial.flushcrj)Nrk�reset_input_buffer)rGr3rFrErqrlrKrrrq�rmzSerial.reset_input_buffercrj)Nro�reset_output_buffer)rGr3rFrErrrlrKrrrr�rmzSerial.reset_output_buffer��?cs(|j�dd�|��tt|��|�dS)N�BRKzsend_break {}s)rGr3rrFrE�
send_break)r'�durationrKrrru�szSerial.send_breakcC�*|j�d|rdnd�tjj�||�dS)Nrt�active�inactive)rGr3r
rE�break_conditionrO�r'�levelrrrrz��zSerial.break_conditioncCrw)N�RTSrxry)rGr3r
rE�rtsrOr{rrrr�r}z
Serial.rtscCrw)N�DTRrxry)rGr3r
rE�dtrrOr{rrrr�r}z
Serial.dtrc�,tt|�j}|j�d|rd�|Sd�|S)N�CTSrxry)rFrE�ctsrGr3r{rKrrr��
�z
Serial.ctscr�)N�DSRrxry)rFrE�dsrrGr3r{rKrrr�r�z
Serial.dsrcr�)N�RIrxry)rFrE�rirGr3r{rKrrr�r�z	Serial.ricr�)N�CDrxry)rFrE�cdrGr3r{rKrrr�r�z	Serial.cd)r)rs)r4r5r6r7r(r
rErN�setterrPr*rg�hasattrrirn�propertyrpr+rqrrrurzrr�r��getterr�r�r��
__classcell__rrrKrrE�s@



rE�__main__zspy:///dev/ttyS0)�
__future__rrZr9r
�serial.serialutilrrV�ImportError�urllib.parse�parserr�objectrr8rEr4�serrN�printrrrr�<module>s*�3�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY