示例#1
0
 def _load_all_plugin(self):
     for plugin_name in self.__all_plugin_name:
         try:
             self._load_plugin_by_name(plugin_name)
         except LalascanFileNotFoundException, e:
             logger.log_error(str(e))
         except LalascanSystemException, e:
             logger.log_error(str(e))
示例#2
0
    def _load_plugin_by_name(self, plugin_name):
        try:
            fplugin = self.__get_plugin_by_name(plugin_name)

            plugin_module = plugin_name + PLUGIN_SUFFIX
            retval = self.__load_plugin(plugin_module, fplugin)
            #print retval[plugin_module]

            if retval[plugin_module] != '':
                importer = PluginImporter(plugin_name, retval[plugin_module])
                importer.load_module(plugin_name)

        except LalascanFileNotFoundException, e:
            logger.log_error(str(e))
示例#3
0
def initOptions(inputOptions=AttribDict()):

    try:

        #========================
        # api interface must be first
        if inputOptions['leakinfo']:
            from lalascan.api.leak_generate import generate_leak_info
            generate_leak_info()

        conf.url = inputOptions.url
        if conf.url is None:
            logger.log_error("no target resource!")
            sys.exit()

        if inputOptions['process_num'] is not None:
            conf.threads = inputOptions.process_num
        else:
            conf.threads = cpu_count()

        if inputOptions['plugin'] is not None:
            conf.plugins = inputOptions.plugin
        else:
            conf.plugins = None

        #conf.audit_conf.cookie = inputOptions['cookie'] if inputOptions['cookie'] is not None else None

        conf.post_data = inputOptions['post_data'] if inputOptions[
            'post_data'] is not None else None
        conf.cookie = inputOptions['cookie'] if inputOptions[
            'cookie'] is not None else None

        conf.bspider = inputOptions['bspider']
        conf.targets = []
    except LalascanDataException:
        logger.log_error("init args option error!")
        sys.exit()
示例#4
0
class PluginManager(object):
    def __init__(self, audit=None):

        self.__audit = audit

        self.__all_plugin_name = set()  #contains sqli,reflect_xss
        self.__all_fplugin = set()

        #或许所有的插件
        self.__get_all_plugin()

    def set_plugin(self):
        """
        @function 设置载入的plugin
        """
        if conf.plugins is not None:
            if len(conf.plugins.split(",")) > 1:
                for _ in conf.plugins.split(","):
                    plugin_name = _.strip(' ')
                    retval = self._load_plugin_by_name(plugin_name)
            else:
                plugin_name = conf.plugins
                self._load_plugin_by_name(plugin_name)

        else:
            # all plugin load
            # conf.pocFile = None
            self._load_all_plugin()

    def _load_all_plugin(self):
        for plugin_name in self.__all_plugin_name:
            try:
                self._load_plugin_by_name(plugin_name)
            except LalascanFileNotFoundException, e:
                logger.log_error(str(e))
            except LalascanSystemException, e:
                logger.log_error(str(e))

            except ImportError, ex:
                errmsg = "%s register failed \"%s\"" % (plugin_name, str(ex))
                logger.log_error(errmsg)
示例#5
0
        try:
            fplugin = self.__get_plugin_by_name(plugin_name)

            plugin_module = plugin_name + PLUGIN_SUFFIX
            retval = self.__load_plugin(plugin_module, fplugin)
            #print retval[plugin_module]

            if retval[plugin_module] != '':
                importer = PluginImporter(plugin_name, retval[plugin_module])
                importer.load_module(plugin_name)

        except LalascanFileNotFoundException, e:
            logger.log_error(str(e))

        except LalascanSystemException, e:
            logger.log_error(str(e))

        except ImportError, ex:
            errmsg = "%s register failed \"%s\"" % (plugin_name, str(ex))
            logger.log_error(errmsg)
            #logger.log(CUSTOM_LOGGING.ERROR, errMsg)

        return

    def __get_plugin_by_name(self, plugin_name):
        for fplugin in self.__all_fplugin:
            try:
                plugin_module = plugin_name + PLUGIN_SUFFIX
                if plugin_module == fplugin[fplugin.rindex('/') + 1:]:
                    return fplugin
            except LalascanValueError: