MCPcopy
hub / github.com/Pennyw0rth/NetExec / init_module

Method init_module

nxc/loaders/moduleloader.py:61–85  ·  view source on GitHub ↗

Initialize a module for execution

(self, module_path)

Source from the content-addressed store, hash-verified

59 self.logger.debug(traceback.format_exc())
60
61 def init_module(self, module_path):
62 """Initialize a module for execution"""
63 module = None
64 module = self.load_module(module_path)
65
66 if module:
67 self.logger.debug(f"Supported protocols: {module.supported_protocols}")
68 self.logger.debug(f"Protocol: {self.args.protocol}")
69 if self.args.protocol in module.supported_protocols:
70 try:
71 module_logger = NXCAdapter(extra={"module_name": module.name.upper()})
72 except Exception as e:
73 self.logger.fail(f"Error loading NXCAdaptor for module {module.name.upper()}: {e}")
74 context = Context(self.db, module_logger, self.args)
75 module_options = {}
76
77 for option in self.args.module_options:
78 key, value = option.split("=", 1)
79 module_options[str(key).upper()] = value
80
81 module.options(context, module_options)
82 return module
83 else:
84 self.logger.fail(f"Module {module.name.upper()} is not supported for protocol {self.args.protocol}")
85 sys.exit(1)
86
87 def get_module_info(self, module_path):
88 """Get the path, description, and options from a module"""

Callers 2

mainFunction · 0.95
load_modulesMethod · 0.95

Calls 5

load_moduleMethod · 0.95
NXCAdapterClass · 0.90
ContextClass · 0.90
failMethod · 0.80
optionsMethod · 0.45

Tested by

no test coverage detected