
    ;Si                     Z    d dl Z ddlmZ ddlmZ ddlmZ  G d d      Z G d	 d
e      Zy)    N   )AbridgedPacketCodec)ObfuscatedConnection   )
AESModeCTRc                   2    e Zd ZdZd Zed        Zd Zd Zy)ObfuscatedIONc                     |j                   | _         |j                  | _        | j                  |j                        \  | _        | _        | _        y N)_reader_writerinit_headerpacket_codecheader_encrypt_decrypt)self
connections     n/var/www/OnlineNewsSite/project/venv/lib/python3.12/site-packages/telethon/network/connection/tcpobfuscated.py__init__zObfuscatedIO.__init__   sE    !))!)) **:+B+BC			    c                    d}	 t        j                  d      }|d   dk7  r|d d |vr	|dd dk7  rn.t        |      }|dd	d
   }t        |dd       }t        |dd       }t        |d d       }t        |dd       }t	        ||      }t	        ||      }	| j
                  |dd |j                  t        |            dd |dd |||	fS )N)s   PVrGs   GET s   POSTs   @   r            s       7      (   8       0   <   )osurandom	bytearraybytesr   obfuscate_tagencrypt)
r   keywordsrandomrandom_reversedencrypt_key
encrypt_ivdecrypt_key
decrypt_iv	encryptor	decryptors
             r   r   zObfuscatedIO.init_header   s     DZZ^Fq	T!2AJh.1QK;.  6" Ab/ F1RL)6"R=)
OCR01?2b12
{J7	{J7	$22r"!))%-8B?r"	9--r   c                    K   | j                   j                  | j                  j                  |       d {         S 7 wr   )r   r*   r   readexactly)r   ns     r   r5   zObfuscatedIO.readexactly/   s0     }}$$4<<+C+CA+F%FGG%Fs   4A?	Ac                 l    | j                   j                  | j                  j                  |             y r   )r   writer   r*   )r   datas     r   r8   zObfuscatedIO.write2   s#    4==0067r   )	__name__
__module____qualname__r   r   staticmethodr   r5   r8    r   r   r	   r	   	   s,    FD . .4H8r   r	   c                       e Zd ZdZeZeZy)ConnectionTcpObfuscatedz
    Mode that Telegram defines as "obfuscated2". Encodes the packet
    just like `ConnectionTcpAbridged`, but encrypts every message with
    a randomly generated key using the AES-CTR mode so the packets are
    harder to discern.
    N)r:   r;   r<   __doc__r	   obfuscated_ior   r   r>   r   r   r@   r@   6   s     !M&Lr   r@   )	r%   tcpabridgedr   r   r   cryptor   r	   r@   r>   r   r   <module>rE      s)    	 , ,  *8 *8Z'2 'r   