RCayre / mirage

Mirage is a powerful and modular framework dedicated to the security analysis of wireless communications.
https://homepages.laas.fr/rcayre/mirage-documentation
MIT License
272 stars 50 forks source link

loadModule issue #24

Open tlechien opened 3 years ago

tlechien commented 3 years ago

Hello,

Great repo,

I encounter an issue when trying to load a module:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/mirage-1.1-py3.7.egg/mirage/libs/utils.py", line 230, in loadModule
    return app.App.Instance.loader.load(name)
AttributeError: 'NoneType' object has no attribute 'loader'

Following the breadcrumbs I found out that there is an issue in the loader:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'mirage.modules' has no attribute '__modules__'

Cordially,

tlechien

RCayre commented 3 years ago

Hi, weird issue... can you provide me more details ? How are you running Mirage ? sudo ./mirage_launcher ? sudo mirage ? Are you trying to run a module directly from an external python script ? Can you provide me a code snippet allowing to reproduce the issue ? Thanks.

tlechien commented 3 years ago

Hello, I admit I could have been clearer. I'm importing Mirage as a library. Tried both to call loadModule as a standalone function and in a new module. It seems there is sth going on with the loader and the paths ( generated in modules/init.py & libs/utils.py). I modified init in mirage/core/loader.py with

                self.modulesList = {}
                modulesPath = next(iter(modules.__path__))
                mList = modules.generateModulesDictionary(modulesPath, modulesPath)
                for moduleName,module in mList.items():
                        current = module#__import__("modules."+module, fromlist=module)
                        moduleClass = getattr(current,moduleName)
                        self.modulesList[moduleName] = moduleClass

to fix it (and it works as long as i initialize app.App() beforehand) but it's more of a bandaid than an actual fix.

Cordially,

tlechien