From 99b22cfa56d60ab89636962683479f20a7ef3dfe Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Mon, 2 Apr 2018 16:49:18 +0300 Subject: [PATCH] Fail gracefully in case of no open ports on Windows --- infection_monkey/network/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infection_monkey/network/tools.py b/infection_monkey/network/tools.py index 9f0cb8dee..5053b6c32 100644 --- a/infection_monkey/network/tools.py +++ b/infection_monkey/network/tools.py @@ -139,7 +139,7 @@ def check_tcp_ports(ip, ports, timeout=DEFAULT_TIMEOUT, get_banner=False): "On host %s discovered the following ports %s" % (str(ip), ",".join([str(s[0]) for s in connected_ports_sockets]))) banners = [] - if get_banner: + if get_banner and (len(connected_ports_sockets) != 0): readable_sockets, _, _ = select.select([s[1] for s in connected_ports_sockets], [], [], 0) # read first BANNER_READ bytes banners = [sock.recv(BANNER_READ) if sock in readable_sockets else ""