From a83c97519cbe8d31c88613ea2a5124c4fdc551a5 Mon Sep 17 00:00:00 2001 From: Shreya Date: Thu, 18 Mar 2021 13:14:26 +0530 Subject: [PATCH] CR changes --- .../system_info/windows_info_collector.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/monkey/infection_monkey/system_info/windows_info_collector.py b/monkey/infection_monkey/system_info/windows_info_collector.py index 81b0c8125..8a53898c7 100644 --- a/monkey/infection_monkey/system_info/windows_info_collector.py +++ b/monkey/infection_monkey/system_info/windows_info_collector.py @@ -48,17 +48,11 @@ class WindowsInfoCollector(InfoCollector): def get_installed_packages(self): LOG.info('Getting installed packages') - packages = subprocess.Popen("dism /online /get-packages", shell=True, stdout=subprocess.PIPE).stdout.read() - try: - self.info["installed_packages"] = packages.decode('utf-8') - except UnicodeDecodeError: - self.info["installed_packages"] = packages.decode('raw-unicode-escape') + packages = subprocess.check_output("dism /online /get-packages", shell=True) + self.info["installed_packages"] = packages.decode('utf-8', errors='ignore') - features = subprocess.Popen("dism /online /get-features", shell=True, stdout=subprocess.PIPE).stdout.read() - try: - self.info["installed_features"] = features.decode('utf-8') - except UnicodeDecodeError: - self.info["installed_features"] = features.decode('raw-unicode-escape') + features = subprocess.check_output("dism /online /get-features", shell=True) + self.info["installed_features"] = features.decode('utf-8', errors='ignore') LOG.debug('Got installed packages')