From 571b8eb34770c7b416bfb61780d9ec09d03e8060 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Wed, 22 Jun 2022 10:18:52 +0200 Subject: [PATCH 1/4] Update spideyDetector.py --- spideyDetector.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spideyDetector.py b/spideyDetector.py index 72198a1..b1d25c0 100644 --- a/spideyDetector.py +++ b/spideyDetector.py @@ -7,7 +7,7 @@ import argparse import sys -def parse(_args): +def parse(_args): # TODO: Move this to a arg_parsing module parser = argparse.ArgumentParser( prog="Spidey Detector", description='Checks for corrupt discord install' @@ -28,12 +28,13 @@ def parse(_args): parser.add_argument('--analyze', action='store_true', help="Analyze the files in the discord folder for known js obfuscators") parser.add_argument('--all', action='store_true', help="Run all tests in parallel, and wait for a potential interupt") parser.add_argument('--launch', action='store_true', help="Launch the discord client after the tests are done") + parser.add_argument("--force-path", nargs=1, default="", help="Bypass the automatic path discovery with given path") return parser.parse_args(_args) if __name__ == "__main__": args = parse(sys.argv[1:]) - agnostic_path = agnostic_paths.AgnosticPaths(ptb=args.ptb) + agnostic_path = agnostic_paths.AgnosticPaths(ptb=args.ptb, force_path=args.force_path) try: spd = test_interface.run_check(args, agnostic_path) @@ -45,5 +46,5 @@ if __name__ == "__main__": sys.exit(1) if spd == 0: - print("SpideyDetector could not find anything wrong with your discord install!") + print("TestRunner could not find anything wrong with your discord install!") # TODO: Everything should be in the run_all_tests() sys.exit(spd) From e03b8ba8a9f8833c63aafe8c9a12e7c70ca1f9c4 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Wed, 22 Jun 2022 10:19:41 +0200 Subject: [PATCH 2/4] Update test_interface.py --- modules/test_interface.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/test_interface.py b/modules/test_interface.py index 0a58a33..ac571e9 100644 --- a/modules/test_interface.py +++ b/modules/test_interface.py @@ -3,12 +3,17 @@ import re import sys import importlib -_TEST_MODULES = { # argparse argument : [module_name, class_name] +""" +All modules that can be tested +Associate the arguments passed to the command line with the modules to be loaded +argparse argument : [module_name, class_name] +""" +_TEST_MODULES = { "spidey": ["spidey_test", "SpideyTest"], } -class SpideyDetector: +class TestRunner: def __init__(self, args, agnpath): """ Main spidey runner @@ -23,7 +28,7 @@ class SpideyDetector: self.os_name = agnpath.os self.main_path = agnpath.main_path self.version = agnpath.version - # self.is_windows = self.check_os() + self.is_infected = 0 self.detections = 0 self.test_run = {} @@ -56,8 +61,9 @@ class SpideyDetector: def exec_all_tests(self): """ - Executes all the tests - :return: + Executes all the tests (later in parallel), get their result as they finishes + :return: The number of test ran, success, failures, skipped (with ran = success+failures+skip) + :rtype: (int,int,int,int) # TODO: Change this to a nametuple """ for module_name, test_class in self.loaded_test_classes.items(): tc = test_class(self.args, self.agnostic_path, None) @@ -65,8 +71,8 @@ class SpideyDetector: print(tc) -def run_check(args, agnpath): - spd = SpideyDetector(args, agnpath) +def run_check(args, agnpath): # Todo, skip the is_infected check and defer everything to the exec_all_tests + spd = TestRunner(args, agnpath) if not spd.is_infected: return 0 else: @@ -74,4 +80,4 @@ def run_check(args, agnpath): if __name__ == "__main__": - pass \ No newline at end of file + pass From 8a1ee4d82f2be123c2d3ce4561390326746d90d3 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Wed, 22 Jun 2022 10:20:07 +0200 Subject: [PATCH 3/4] Update spidey_test.py --- modules/spidey_test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/spidey_test.py b/modules/spidey_test.py index 43d68cb..7132318 100644 --- a/modules/spidey_test.py +++ b/modules/spidey_test.py @@ -58,3 +58,21 @@ class SpideyTest: discord_modules = self.agnostic_path("modules", "discord_modules-1", "discord_modules") discord_desktop_core = self.agnostic_path("modules", "discord_desktop_core-1", "discord_desktop_core") return discord_modules, discord_desktop_core + + def get_status_code(self): + """ + The status code of the test + :return: 0: The test was not run, 1: The test is running, 2: The test is a success, 3: Test has failed, 4: Test found problems + :rtype: int + """ + # TODO: Add this to a global_dict + return 0 + + def get_status(self): + """ + Return the status of the test, as a string, as the test is ran + :return: "Test is running", "Test was not run", "Test was run and nothing was detected", "Test was run and some problems were detected (list of problems)" + :rtype: (int, str) + """ + # TODO: Make use of a global_dict + return (self.get_status_code(), "") From b65e32dbae4b91acbb97a6df1c5eff47f1d8cd6d Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Wed, 22 Jun 2022 10:20:30 +0200 Subject: [PATCH 4/4] Update agnostic_paths.py --- modules/agnostic_paths.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/agnostic_paths.py b/modules/agnostic_paths.py index a88554b..5a8f9f2 100644 --- a/modules/agnostic_paths.py +++ b/modules/agnostic_paths.py @@ -11,7 +11,7 @@ class AgnosticPaths: An agnostic path object, containing all methods to access the files and folders in a standard discord install """ - def __init__(self, ptb, forced_path=None): + def __init__(self, ptb, force_path=""): """ :param ptb: Whether the discord is a public beta install (ptb="PTB") or not (ptb="") :type ptb: str @@ -20,6 +20,7 @@ class AgnosticPaths: """ self.ptb = ptb self.os = self.get_os() + self.force_path = force_path[0] self.main_path = self._get_path() self.version = self.get_version() self._update_path() @@ -51,6 +52,8 @@ class AgnosticPaths: :return: Base path of the install (minus the version on windows) :rtype: str """ + if self.force_path != "": + return self.force_path if self.os == 'windows': return os.path.join(os.path.expanduser('~'), "AppData", "Local", f"Discord{self.ptb}") elif self.os == 'linux':