diff --git a/monkey/infection_monkey/network/__init__.py b/monkey/infection_monkey/network/__init__.py index 33a6871e2..fe3e6cb7a 100644 --- a/monkey/infection_monkey/network/__init__.py +++ b/monkey/infection_monkey/network/__init__.py @@ -1,4 +1,4 @@ -from abc import ABCMeta, abstractmethod, abstractproperty +from abc import ABCMeta, abstractmethod __author__ = 'itamar' @@ -10,7 +10,8 @@ class HostScanner(object, metaclass=ABCMeta): class HostFinger(object, metaclass=ABCMeta): - @abstractproperty + @property + @abstractmethod def _SCANNED_SERVICE(self): pass diff --git a/monkey/infection_monkey/network/firewall.py b/monkey/infection_monkey/network/firewall.py index 88171ecda..16af673b1 100644 --- a/monkey/infection_monkey/network/firewall.py +++ b/monkey/infection_monkey/network/firewall.py @@ -92,7 +92,7 @@ class WinAdvFirewall(FirewallApp): def close(self): try: for rule in list(self._rules.keys()): - self.remove_firewall_rule({'name': rule}) + self.remove_firewall_rule(name=rule) except: pass diff --git a/monkey/infection_monkey/network/info.py b/monkey/infection_monkey/network/info.py index 50cd7aa0a..e41be20ac 100644 --- a/monkey/infection_monkey/network/info.py +++ b/monkey/infection_monkey/network/info.py @@ -63,7 +63,7 @@ else: def get_routes(): # based on scapy implementation for route parsing - LOOPBACK_NAME = "lo" + LOOPBACK_NAME = b"lo" SIOCGIFADDR = 0x8915 # get PA address SIOCGIFNETMASK = 0x891b # get network PA mask RTF_UP = 0x0001 # Route usable @@ -85,7 +85,7 @@ else: routes.append((dst, msk, "0.0.0.0", LOOPBACK_NAME, ifaddr)) for l in f.readlines()[1:]: - iff, dst, gw, flags, x, x, x, msk, x, x, x = l.split() + iff, dst, gw, flags, x, x, x, msk, x, x, x = [var.encode() for var in l.split()] flags = int(flags, 16) if flags & RTF_UP == 0: continue diff --git a/monkey/infection_monkey/network/mssql_fingerprint.py b/monkey/infection_monkey/network/mssql_fingerprint.py index 7b666bf9f..e6130732d 100644 --- a/monkey/infection_monkey/network/mssql_fingerprint.py +++ b/monkey/infection_monkey/network/mssql_fingerprint.py @@ -1,3 +1,4 @@ +import errno import logging import socket @@ -54,7 +55,7 @@ class MSSQLFinger(HostFinger): sock.close() return False except socket.error as e: - if e.errno == socket.errno.ECONNRESET: + if e.errno == errno.ECONNRESET: LOG.info('Connection was forcibly closed by the remote host. The host: {0} is rejecting the packet.' .format(host)) else: diff --git a/monkey/infection_monkey/network/tools.py b/monkey/infection_monkey/network/tools.py index abcd5a5cd..8fcc2892e 100644 --- a/monkey/infection_monkey/network/tools.py +++ b/monkey/infection_monkey/network/tools.py @@ -96,7 +96,7 @@ def check_udp_port(ip, port, timeout=DEFAULT_TIMEOUT): is_open = False try: - sock.sendto("-", (ip, port)) + sock.sendto(b"-", (ip, port)) data, _ = sock.recvfrom(BANNER_READ) is_open = True except socket.error: @@ -116,7 +116,7 @@ def check_tcp_ports(ip, ports, timeout=DEFAULT_TIMEOUT, get_banner=False): :return: list of open ports. If get_banner=True, then a matching list of banners. """ sockets = [socket.socket(socket.AF_INET, socket.SOCK_STREAM) for _ in range(len(ports))] - [s.setblocking(0) for s in sockets] + [s.setblocking(False) for s in sockets] possible_ports = [] connected_ports_sockets = [] try: