diff --git a/modules/spidey_detector.py b/modules/spidey_detector.py index 11bf972..fb1d62c 100644 --- a/modules/spidey_detector.py +++ b/modules/spidey_detector.py @@ -2,6 +2,10 @@ import os import re import sys +_TEST_MODULES = { # argparse argument : [module_name, class_name] + "spidey": ["spidey_test", "spidey"], +} + class SpideyDetector: def __init__(self, args, agnpath): @@ -18,13 +22,24 @@ class SpideyDetector: self.main_path = agnpath.main_path self.latest_version = agnpath.latest_version # self.is_windows = self.check_os() - self.is_infected = False + self.is_infected = 0 self.detections = 0 self.test_run = {} - # self.paths = self.check_paths(*self.get_path()) - # self.spidey_check() + self.loaded_modules = self.get_module_list() + self.spidey_check() + def get_module_list(self): + """ + Gets the list of modules to be loaded (in accordance to the config) + :return: List of modules + :rtype: list + """ + modules = [] + for module in _TEST_MODULES: + + if module[0] in self.loaded_modules: + modules.append(module[1]) def check_os(self): # noqa if not sys.platform.startswith('win'): raise OSError("This script can only check for Spideys on Windows.") diff --git a/modules/spidey_test.py b/modules/spidey_test.py new file mode 100644 index 0000000..7353fa9 --- /dev/null +++ b/modules/spidey_test.py @@ -0,0 +1,16 @@ +class SpideyTest: + def __init__(self, args, agnpath, test_data): + """ + Simple test runner, for testing the detection of Spidey viruses. + :param args: List of arguments + :type args: argparse.Namespace + :param agnpath: The path to the discord folder + :type agnpath: agnostic_path.AgnosticPath + :param test_data: The data to be tested + :type test_data: str + """ + self.ptb = args.ptb + self.agnostic_path = agnpath + self.os_name = agnpath.os + self.main_path = agnpath.main_path + self.test_data = test_data diff --git a/spideyDetector.py b/spideyDetector.py index 8ccab05..8dc783a 100644 --- a/spideyDetector.py +++ b/spideyDetector.py @@ -16,6 +16,7 @@ def parse(_args): parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0') parser.add_argument('-d', '--debug', action='store_true', help='Debug mode') parser.add_argument('-s', '--silent', action='store_true', help='Silent mode') + parser.add_argument('--spidey', action='store_true', help='Runs the spidey test') parser.add_argument('--line-count', action='store_true', help='Test all known files for line count') parser.add_argument('--file-count', action='store_true', help="Test the number of files in the discord folder") parser.add_argument('--file-size', action='store_true', help="Test the size of the files in the discord folder")