From 769dd67b668ed737a97fc058b03f58e1167b8ddd Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 13 Aug 2021 08:39:08 -0400 Subject: [PATCH] Agent: Automatically select correct output encoding for ping command --- monkey/infection_monkey/network/ping_scanner.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/monkey/infection_monkey/network/ping_scanner.py b/monkey/infection_monkey/network/ping_scanner.py index d01a9c56b..f43412064 100644 --- a/monkey/infection_monkey/network/ping_scanner.py +++ b/monkey/infection_monkey/network/ping_scanner.py @@ -43,13 +43,12 @@ class PingScanner(HostScanner, HostFinger): if not "win32" == sys.platform: timeout /= 1000 - Encoding = "cp850" sub_proc = subprocess.Popen( ["ping", PING_COUNT_FLAG, "1", PING_TIMEOUT_FLAG, str(timeout), host.ip_addr], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, - encoding=Encoding, + encoding=os.device_encoding(1), ) output = " ".join(sub_proc.communicate())