forked from savon-noir/python-libnmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackendpluginFactory.py
More file actions
22 lines (19 loc) · 863 Bytes
/
backendpluginFactory.py
File metadata and controls
22 lines (19 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
import sys
import inspect
class BackendPluginFactory(object):
def create(self, plugin_name="mongodb", **kwargs):
"""Import the needed lib and return an object NmapBackendPlugin
representing the backend of your desire.
NmapBackendPlugin is an abstract class, to know what argument
need to be given, review the code of the subclass you need
"""
backendplugin = None
plugin_path = "libnmap.plugins.%s" % (plugin_name)
__import__(plugin_path)
pluginobj = sys.modules[plugin_path]
pluginclasses = inspect.getmembers(pluginobj, inspect.isclass)
for classname, classobj in pluginclasses:
if inspect.getmodule(classobj).__name__.find(plugin_path) == 0:
backendplugin = classobj(**kwargs)
return backendplugin