コード例 #1
0
    async def send(self, data: bytes, *args):
        length = len(data) // 4

        await super().send(
            aes.ctr256_encrypt((bytes([length]) if length <= 126 else b"\x7f" +
                                length.to_bytes(3, "little")) + data,
                               *self.encrypt))
コード例 #2
0
    async def connect(self, address: tuple):
        await super().connect(address)

        while True:
            nonce = bytearray(os.urandom(64))

            if nonce[0] != b"\xef" and nonce[:4] not in self.RESERVED and nonce[4:4] != b"\x00" * 4:
                nonce[56] = nonce[57] = nonce[58] = nonce[59] = 0xef
                break

        temp = bytearray(nonce[55:7:-1])

        self.encrypt = (nonce[8:40], nonce[40:56], bytearray(1))
        self.decrypt = (temp[0:32], temp[32:48], bytearray(1))

        nonce[56:64] = aes.ctr256_encrypt(nonce, *self.encrypt)[56:64]

        await super().send(nonce)
コード例 #3
0
ファイル: tcp_intermediate_o.py プロジェクト: Alimov-IQ/Bots
 async def send(self, data: bytes, *args):
     await super().send(
         aes.ctr256_encrypt(pack("<i", len(data)) + data, *self.encrypt))