Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
payload_data = cipher.encrypt(payload_data)
return payload_data
class AES256Payload(DecryptedPayload):
def get_cipher(self, master_key, encryption_iv):
return AES.new(master_key, AES.MODE_CBC, encryption_iv)
class ChaCha20Payload(DecryptedPayload):
def get_cipher(self, master_key, encryption_iv):
return ChaCha20.new(key=master_key, nonce=encryption_iv)
class TwoFishPayload(DecryptedPayload):
def get_cipher(self, master_key, encryption_iv):
return Twofish.new(master_key, mode=Twofish.MODE_CBC, IV=encryption_iv)
class Decompressed(Adapter):
"""Compressed Bytes <---> Decompressed Bytes"""
def _decode(self, data, con, path):
return zlib.decompress(data, 16 + 15)
def _encode(self, data, con, path):
compressobj = zlib.compressobj(
6,
zlib.DEFLATED,
16 + 15,
zlib.DEF_MEM_LEVEL,
payload_data = CryptoPadding.pad(payload_data, 16)
cipher = self.get_cipher(
con.master_key,
con._.header.value.dynamic_header.encryption_iv.data
)
payload_data = cipher.encrypt(payload_data)
return payload_data
class AES256Payload(DecryptedPayload):
def get_cipher(self, master_key, encryption_iv):
return AES.new(master_key, AES.MODE_CBC, encryption_iv)
class ChaCha20Payload(DecryptedPayload):
def get_cipher(self, master_key, encryption_iv):
return ChaCha20.new(key=master_key, nonce=encryption_iv)
class TwoFishPayload(DecryptedPayload):
def get_cipher(self, master_key, encryption_iv):
return Twofish.new(master_key, mode=Twofish.MODE_CBC, IV=encryption_iv)
class Decompressed(Adapter):
"""Compressed Bytes <---> Decompressed Bytes"""
def _decode(self, data, con, path):
return zlib.decompress(data, 16 + 15)
def _encode(self, data, con, path):
payload_data = cipher.decrypt(payload_data)
return payload_data
def _encode(self, payload_data, con, path):
payload_data = CryptoPadding.pad(payload_data, 16)
cipher = self.get_cipher(
con.master_key,
con._.header.value.dynamic_header.encryption_iv.data
)
payload_data = cipher.encrypt(payload_data)
return payload_data
class AES256Payload(DecryptedPayload):
def get_cipher(self, master_key, encryption_iv):
return AES.new(master_key, AES.MODE_CBC, encryption_iv)
class ChaCha20Payload(DecryptedPayload):
def get_cipher(self, master_key, encryption_iv):
return ChaCha20.new(key=master_key, nonce=encryption_iv)
class TwoFishPayload(DecryptedPayload):
def get_cipher(self, master_key, encryption_iv):
return Twofish.new(master_key, mode=Twofish.MODE_CBC, IV=encryption_iv)
class Decompressed(Adapter):
"""Compressed Bytes <---> Decompressed Bytes"""