Skip to content

Commit a4ef19e

Browse files
authored
Only import enabled auxiliary modules (#2294)
* Only start enabled auxiliary modules * Only import enabled modules
1 parent 3faa463 commit a4ef19e

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

analyzer/windows/analyzer.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -497,46 +497,34 @@ def run(self):
497497
Auxiliary()
498498
prefix = f"{auxiliary.__name__}."
499499

500-
# disable_screens = True
501-
# if self.options.get("disable_screens") == "0":
502-
# disable_screens = False
503-
504500
for _, name, _ in pkgutil.iter_modules(auxiliary.__path__, prefix):
505501
try:
506-
log.debug('Importing auxiliary module "%s"...', name)
507-
__import__(name, globals(), locals(), ["dummy"])
508-
# log.debug('Imported auxiliary module "%s"', name)
502+
mod_name = name.split(".")[-1]
503+
if hasattr(self.config, mod_name) and getattr(self.config, mod_name, False):
504+
log.debug('Importing auxiliary module "%s"...', name)
505+
__import__(name, globals(), locals(), ["dummy"])
506+
# log.debug('Imported auxiliary module "%s"', name)
509507
except ImportError as e:
510508
log.warning('Unable to import the auxiliary module "%s": %s', name, e)
509+
511510
# Walk through the available auxiliary modules.
512511
aux_modules = []
513512

514513
for module in sorted(Auxiliary.__subclasses__(), key=lambda x: x.start_priority, reverse=True):
515-
# Try to start the auxiliary module.
516-
# if module.__name__ == "Screenshots" and disable_screens:
517-
# continue
518514
try:
519515
aux = module(self.options, self.config)
520516
log.debug('Initialized auxiliary module "%s"', module.__name__)
521517
aux_modules.append(aux)
522-
523-
# The following commented out code causes the monitor to not upload logs.
524-
# If the auxiliary module is not enabled, we shouldn't start it
525-
# if hasattr(aux, "enabled") and not getattr(aux, "enabled", False):
526-
# log.debug('Auxiliary module "%s" is disabled.', module.__name__)
527-
# # We continue so that the module is not added to AUX_ENABLED
528-
# continue
529-
# else:
530-
log.debug('Trying to start auxiliary module "%s"...', module.__name__)
518+
log.debug('Trying to start auxiliary module "%s"...', module.__module__)
531519
aux.start()
532520
except (NotImplementedError, AttributeError) as e:
533521
log.warning("Auxiliary module %s was not implemented: %s", module.__name__, e)
534522
except Exception as e:
535-
log.warning("Cannot execute auxiliary module %s: %s", module.__name__, e)
523+
log.warning("Cannot execute auxiliary module %s: %s", module.__module__, e)
536524
else:
537-
log.debug("Started auxiliary module %s", module.__name__)
525+
log.debug("Started auxiliary module %s", module.__module__)
538526
AUX_ENABLED.append(aux)
539-
527+
540528
"""
541529
# Inform zer0m0n of the ResultServer address.
542530
zer0m0n.resultserver(self.config.ip, self.config.port)

0 commit comments

Comments
 (0)