Implement and use TCP obfuscated as a PoC (#112)

Credits to MadelineProto/Connection.php by @danog
This commit is contained in:
Lonami Exo
2017-08-28 20:25:44 +02:00
parent adfebfc82c
commit 5404670469
5 changed files with 251 additions and 25 deletions

View File

@@ -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

View 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