diff --git a/monkey/infection_monkey/exploit/sshexec.py b/monkey/infection_monkey/exploit/sshexec.py index fc8260904..f7abd3ce0 100644 --- a/monkey/infection_monkey/exploit/sshexec.py +++ b/monkey/infection_monkey/exploit/sshexec.py @@ -138,7 +138,7 @@ class SSHExploiter(HostExploiter): if not self.host.os.get('machine'): try: _, stdout, _ = ssh.exec_command('uname -m') - uname_machine = stdout.read().lower().strip() + uname_machine = stdout.read().lower().strip().decode() if '' != uname_machine: self.host.os['machine'] = uname_machine except Exception as exc: diff --git a/monkey/monkey_island/cc/encryptor.py b/monkey/monkey_island/cc/encryptor.py index 2ee19cb11..585c84f87 100644 --- a/monkey/monkey_island/cc/encryptor.py +++ b/monkey/monkey_island/cc/encryptor.py @@ -38,10 +38,10 @@ class Encryptor: def _unpad(self, message: str): return message[0:-ord(message[len(message) - 1])] - def enc(self, message): + def enc(self, message: str): cipher_iv = Random.new().read(AES.block_size) cipher = AES.new(self._cipher_key, AES.MODE_CBC, cipher_iv) - return base64.b64encode(cipher_iv + cipher.encrypt(self._pad(message).encode())) + return base64.b64encode(cipher_iv + cipher.encrypt(self._pad(message).encode())).decode() def dec(self, enc_message): enc_message = base64.b64decode(enc_message) diff --git a/monkey/monkey_island/cc/resources/telemetry_feed.py b/monkey/monkey_island/cc/resources/telemetry_feed.py index e271c45c5..d6d14229d 100644 --- a/monkey/monkey_island/cc/resources/telemetry_feed.py +++ b/monkey/monkey_island/cc/resources/telemetry_feed.py @@ -33,7 +33,7 @@ class TelemetryFeed(flask_restful.Resource): 'timestamp': datetime.now().isoformat() } except KeyError as err: - logger.error("Failed parsing telemetries. Error: {0}.".format(err.message)) + logger.error("Failed parsing telemetries. Error: {0}.".format(err)) return {'telemetries': [], 'timestamp': datetime.now().isoformat()} @staticmethod diff --git a/monkey/monkey_island/cc/services/telemetry/processing/exploit.py b/monkey/monkey_island/cc/services/telemetry/processing/exploit.py index cf6e9b544..9b25c97ef 100644 --- a/monkey/monkey_island/cc/services/telemetry/processing/exploit.py +++ b/monkey/monkey_island/cc/services/telemetry/processing/exploit.py @@ -55,4 +55,4 @@ def encrypt_exploit_creds(telemetry_json): for field in ['password', 'lm_hash', 'ntlm_hash']: credential = attempts[i][field] if len(credential) > 0: - attempts[i][field] = encryptor.enc(credential.encode('utf-8')) + attempts[i][field] = encryptor.enc(credential) diff --git a/monkey/monkey_island/cc/services/telemetry/processing/processing.py b/monkey/monkey_island/cc/services/telemetry/processing/processing.py index 154096f79..36f75fdbd 100644 --- a/monkey/monkey_island/cc/services/telemetry/processing/processing.py +++ b/monkey/monkey_island/cc/services/telemetry/processing/processing.py @@ -26,4 +26,4 @@ def process_telemetry(telemetry_json): else: logger.info('Got unknown type of telemetry: %s' % telem_category) except Exception as ex: - logger.error("Exception caught while processing telemetry. Info: {}".format(ex.message), exc_info=True) + logger.error("Exception caught while processing telemetry. Info: {}".format(ex), exc_info=True) diff --git a/monkey/monkey_island/cc/services/telemetry/processing/system_info.py b/monkey/monkey_island/cc/services/telemetry/processing/system_info.py index ebf11c219..a43934a09 100644 --- a/monkey/monkey_island/cc/services/telemetry/processing/system_info.py +++ b/monkey/monkey_island/cc/services/telemetry/processing/system_info.py @@ -43,7 +43,7 @@ def encrypt_system_info_ssh_keys(ssh_info): for idx, user in enumerate(ssh_info): for field in ['public_key', 'private_key', 'known_hosts']: if ssh_info[idx][field]: - ssh_info[idx][field] = encryptor.enc(ssh_info[idx][field].encode('utf-8')) + ssh_info[idx][field] = encryptor.enc(ssh_info[idx][field]) def process_credential_info(telemetry_json): @@ -77,7 +77,7 @@ def encrypt_system_info_creds(creds): for field in ['password', 'lm_hash', 'ntlm_hash']: if field in creds[user]: # this encoding is because we might run into passwords which are not pure ASCII - creds[user][field] = encryptor.enc(creds[user][field].encode('utf-8')) + creds[user][field] = encryptor.enc(creds[user][field]) def process_mimikatz_and_wmi_info(telemetry_json):