Various python3 bugfixes

This commit is contained in:
VakarisZ 2019-10-16 18:26:41 +03:00
parent 3ef4780d16
commit 547cfe2f92
5 changed files with 10 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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: