mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-11-10 19:10:37 +00:00
Implement and use TCP obfuscated as a PoC (#112)
Credits to MadelineProto/Connection.php by @danog
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from .aes import AES
|
||||
from .aes_ctr import AESModeCTR
|
||||
from .auth_key import AuthKey
|
||||
from .factorization import Factorization
|
||||
from .cdn_decrypter import CdnDecrypter
|
||||
|
||||
29
telethon/crypto/aes_ctr.py
Normal file
29
telethon/crypto/aes_ctr.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import pyaes
|
||||
|
||||
|
||||
class AESModeCTR:
|
||||
"""Wrapper around pyaes.AESModeOfOperationCTR mode with custom IV"""
|
||||
# TODO Maybe make a pull request to pyaes to support iv on CTR
|
||||
|
||||
def __init__(self, key, iv):
|
||||
# TODO Use libssl if available
|
||||
assert isinstance(key, bytes)
|
||||
self._aes = pyaes.AESModeOfOperationCTR(key)
|
||||
|
||||
assert isinstance(iv, bytes)
|
||||
assert len(iv) == 16
|
||||
self.iv = iv
|
||||
self._aes._counter._counter = list(self.iv)
|
||||
|
||||
def reset(self):
|
||||
pass
|
||||
|
||||
def encrypt(self, data):
|
||||
result = self._aes.encrypt(data)
|
||||
self.reset()
|
||||
return result
|
||||
|
||||
def decrypt(self, data):
|
||||
result = self._aes.decrypt(data)
|
||||
self.reset()
|
||||
return result
|
||||
Reference in New Issue
Block a user