This commit is contained in:
Ace Pace 2018-01-09 18:37:59 +02:00
parent fddda34dcd
commit 30d81e05c9
2 changed files with 8 additions and 9 deletions

View File

@ -28,13 +28,12 @@ class TcpScanner(HostScanner, HostFinger):
shuffle(target_ports)
ports, banners = check_tcp_ports(host.ip_addr, target_ports, self._config.tcp_scan_timeout / 1000.0)
if len(ports) != 0:
for target_port, banner in zip(ports, banners):
service = 'tcp-' + str(target_port)
host.services[service] = {}
if banner:
host.services[service]['banner'] = banner
if only_one_port:
break
for target_port, banner in zip(ports, banners):
service = 'tcp-' + str(target_port)
host.services[service] = {}
if banner:
host.services[service]['banner'] = banner
if only_one_port:
break
return len(ports) != 0

View File

@ -132,7 +132,7 @@ def check_tcp_ports(ip, ports, timeout=DEFAULT_TIMEOUT, get_banner=False):
time_left)
# any read_socket is automatically a writesocket
num_replies = len(write_sockets) + len(err_sockets)
if num_replies == len(port_attempts) or time_left == 0:
if num_replies == len(port_attempts) or time_left <= 0:
break
else:
time_left -= SLEEP_BETWEEN_POLL