Various python3 bugfixes
This commit is contained in:
parent
3ef4780d16
commit
547cfe2f92
|
@ -1,4 +1,4 @@
|
||||||
from abc import ABCMeta, abstractmethod, abstractproperty
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
__author__ = 'itamar'
|
__author__ = 'itamar'
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ class HostScanner(object, metaclass=ABCMeta):
|
||||||
|
|
||||||
|
|
||||||
class HostFinger(object, metaclass=ABCMeta):
|
class HostFinger(object, metaclass=ABCMeta):
|
||||||
@abstractproperty
|
@property
|
||||||
|
@abstractmethod
|
||||||
def _SCANNED_SERVICE(self):
|
def _SCANNED_SERVICE(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ class WinAdvFirewall(FirewallApp):
|
||||||
def close(self):
|
def close(self):
|
||||||
try:
|
try:
|
||||||
for rule in list(self._rules.keys()):
|
for rule in list(self._rules.keys()):
|
||||||
self.remove_firewall_rule({'name': rule})
|
self.remove_firewall_rule(name=rule)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ else:
|
||||||
|
|
||||||
|
|
||||||
def get_routes(): # based on scapy implementation for route parsing
|
def get_routes(): # based on scapy implementation for route parsing
|
||||||
LOOPBACK_NAME = "lo"
|
LOOPBACK_NAME = b"lo"
|
||||||
SIOCGIFADDR = 0x8915 # get PA address
|
SIOCGIFADDR = 0x8915 # get PA address
|
||||||
SIOCGIFNETMASK = 0x891b # get network PA mask
|
SIOCGIFNETMASK = 0x891b # get network PA mask
|
||||||
RTF_UP = 0x0001 # Route usable
|
RTF_UP = 0x0001 # Route usable
|
||||||
|
@ -85,7 +85,7 @@ else:
|
||||||
routes.append((dst, msk, "0.0.0.0", LOOPBACK_NAME, ifaddr))
|
routes.append((dst, msk, "0.0.0.0", LOOPBACK_NAME, ifaddr))
|
||||||
|
|
||||||
for l in f.readlines()[1:]:
|
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)
|
flags = int(flags, 16)
|
||||||
if flags & RTF_UP == 0:
|
if flags & RTF_UP == 0:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import errno
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ class MSSQLFinger(HostFinger):
|
||||||
sock.close()
|
sock.close()
|
||||||
return False
|
return False
|
||||||
except socket.error as e:
|
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.'
|
LOG.info('Connection was forcibly closed by the remote host. The host: {0} is rejecting the packet.'
|
||||||
.format(host))
|
.format(host))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -96,7 +96,7 @@ def check_udp_port(ip, port, timeout=DEFAULT_TIMEOUT):
|
||||||
is_open = False
|
is_open = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sock.sendto("-", (ip, port))
|
sock.sendto(b"-", (ip, port))
|
||||||
data, _ = sock.recvfrom(BANNER_READ)
|
data, _ = sock.recvfrom(BANNER_READ)
|
||||||
is_open = True
|
is_open = True
|
||||||
except socket.error:
|
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.
|
: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))]
|
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 = []
|
possible_ports = []
|
||||||
connected_ports_sockets = []
|
connected_ports_sockets = []
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue