Projects STRLCPY SharPyShell Commits da6b20ab
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    core/ChannelAES.py
    1 1  from utils.Singleton import Singleton
    2 2  from Crypto.Cipher import AES
     3 +from Crypto.Util.Padding import pad
     4 +from Crypto.Util.Padding import unpad
    3 5   
    4 6   
    5 7  class ChannelAES(Singleton):
    skipped 6 lines
    12 14   self.IV = self.hashed_password[0:self.BS]
    13 15   
    14 16   def encrypt(self, plain_data):
    15  - pad = lambda s: s + (self.BS - len(s) % self.BS) * chr(self.BS - len(s) % self.BS)
    16  - plain_data_pad = pad(plain_data)
     17 + plain_data_pad = pad(plain_data, self.BS)
    17 18   aes = AES.new(self.hashed_password, AES.MODE_CBC, self.IV)
    18 19   encrypted_data = aes.encrypt(plain_data_pad)
    19 20   return encrypted_data
    20 21   
    21 22   def decrypt(self, encrypted_data):
    22 23   aes = AES.new(self.hashed_password, AES.MODE_CBC, self.IV)
    23  - unpad = lambda s: s[:-ord(s[len(s) - 1:])]
    24 24   decrypted_data = aes.decrypt(encrypted_data)
    25  - return unpad(decrypted_data).decode()
     25 + return unpad(decrypted_data, self.BS)
    26 26   
  • ■ ■ ■ ■ ■
    core/Module.py
    skipped 55 lines
    56 56   # End Override this method
    57 57   
    58 58   def _encrypt_request(self, request_clear):
    59  - request_encrypted = self._channel_enc_obj.encrypt(request_clear)
     59 + request_encrypted = self._channel_enc_obj.encrypt(request_clear.encode())
    60 60   request_encrypted_encoded = base64.b64encode(request_encrypted)
    61  - return request_encrypted_encoded
     61 + return request_encrypted_encoded.decode()
    62 62   
    63 63   def _post_request(self, request_encrypted_encoded):
    64 64   response_status_code, response_headers, response_text = \
    skipped 10 lines
    75 75   return response_clear
    76 76   
    77 77   def _parse_response(self, response):
     78 + response = response.decode()
    78 79   if '{{{' + self._exception_class.__name__ + '}}}' in response:
    79 80   raise self._exception_class(str(response))
    80 81   if '{{{SharPyShellError}}}' in response or '{{{PythonError}}}' in response:
    skipped 17 lines
Please wait...
Page is in error, reload to recover