From 63d0e57bb740fad42dbb9fc3dc9bfddfcbca4df4 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 5 Nov 2019 13:11:15 +0200 Subject: [PATCH] Added documentation on why we ignore errors when getting tcp banner --- monkey/infection_monkey/network/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/infection_monkey/network/tools.py b/monkey/infection_monkey/network/tools.py index ee20af834..20d004aff 100644 --- a/monkey/infection_monkey/network/tools.py +++ b/monkey/infection_monkey/network/tools.py @@ -158,7 +158,7 @@ def check_tcp_ports(ip, ports, timeout=DEFAULT_TIMEOUT, get_banner=False): banners = [] 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 + # read first BANNER_READ bytes. We ignore errors because service might not send a decodable byte string. banners = [sock.recv(BANNER_READ).decode(errors='ignore') if sock in readable_sockets else "" for port, sock in connected_ports_sockets] pass