From 33a94fdd91dde9ad445f0ca0f9b8cf892376dbf9 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sun, 23 Aug 2020 02:47:14 +0000 Subject: [PATCH] improve win service get --- _modules/win_agent.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/_modules/win_agent.py b/_modules/win_agent.py index b631a3a5..a8e42c3b 100644 --- a/_modules/win_agent.py +++ b/_modules/win_agent.py @@ -23,7 +23,26 @@ TEMP_DIR = os.path.join("C:\\Windows", "Temp") def get_services(): - return [svc.as_dict() for svc in psutil.win_service_iter()] + # see https://github.com/wh1te909/tacticalrmm/issues/38 + # for why I am manually implementing the svc.as_dict() method of psutil + ret = [] + for svc in psutil.win_service_iter(): + i = {} + try: + i["display_name"] = svc.display_name() + i["binpath"] = svc.binpath() + i["username"] = svc.username() + i["start_type"] = svc.start_type() + i["status"] = svc.status() + i["pid"] = svc.pid() + i["name"] = svc.name() + i["description"] = svc.description() + except Exception: + continue + else: + ret.append(i) + + return ret def run_python_script(filename, timeout, script_type="userdefined"):