diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 35bda0bd2..787c9e073 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -287,7 +287,7 @@ class Configuration(object): :param sensitive_data: the data to hash. :return: the hashed data. """ - password_hashed = hashlib.sha512(sensitive_data).hexdigest() + password_hashed = hashlib.sha512(sensitive_data.encode()).hexdigest() return password_hashed diff --git a/monkey/infection_monkey/exploit/vsftpd.py b/monkey/infection_monkey/exploit/vsftpd.py index 744853bdf..136a8a36b 100644 --- a/monkey/infection_monkey/exploit/vsftpd.py +++ b/monkey/infection_monkey/exploit/vsftpd.py @@ -71,9 +71,9 @@ class VSFTPDExploiter(HostExploiter): if self.socket_connect(ftp_socket, self.host.ip_addr, FTP_PORT): ftp_socket.recv(RECV_128).decode('utf-8') - if self.socket_send_recv(ftp_socket, USERNAME + '\n'): + if self.socket_send_recv(ftp_socket, USERNAME + b'\n'): time.sleep(FTP_TIME_BUFFER) - self.socket_send(ftp_socket, PASSWORD + '\n') + self.socket_send(ftp_socket, PASSWORD + b'\n') ftp_socket.close() LOG.info('Backdoor Enabled, Now we can run commands') else: diff --git a/monkey/infection_monkey/network/ping_scanner.py b/monkey/infection_monkey/network/ping_scanner.py index 659722bc2..bf215168e 100644 --- a/monkey/infection_monkey/network/ping_scanner.py +++ b/monkey/infection_monkey/network/ping_scanner.py @@ -55,7 +55,8 @@ class PingScanner(HostScanner, HostFinger): PING_TIMEOUT_FLAG, str(timeout), host.ip_addr], stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE, + text=True) output = " ".join(sub_proc.communicate()) regex_result = self._ttl_regex.search(output) diff --git a/monkey/monkey_island/cc/services/node.py b/monkey/monkey_island/cc/services/node.py index 6bff2b54a..3931ad009 100644 --- a/monkey/monkey_island/cc/services/node.py +++ b/monkey/monkey_island/cc/services/node.py @@ -52,7 +52,7 @@ class NodeService: exploit["origin"] = NodeService.get_monkey_label(NodeService.get_monkey_by_id(edge["from"])) exploits.append(exploit) - exploits.sort(key=NodeService._cmp_exploits_by_timestamp) + exploits = sorted(exploits, key=lambda exploit: exploit['timestamp']) new_node["exploits"] = exploits new_node["accessible_from_nodes"] = accessible_from_nodes @@ -71,14 +71,6 @@ class NodeService: domain_name = " (" + node["domain_name"] + ")" return node["os"]["version"] + " : " + node["ip_addresses"][0] + domain_name - @staticmethod - def _cmp_exploits_by_timestamp(exploit_1, exploit_2): - if exploit_1["timestamp"] == exploit_2["timestamp"]: - return 0 - if exploit_1["timestamp"] > exploit_2["timestamp"]: - return 1 - return -1 - @staticmethod def get_monkey_os(monkey): os = "unknown"