예제 #1
0
파일: profiles.py 프로젝트: 0x554simon/w3af
            profile_misc_settings = profile_inst.get_misc_settings()
        except BaseFrameworkException, e:
            msg = ('Setting the framework misc-settings raised an exception'
                   ' due to unknown or invalid configuration parameters. %s')
            error_messages.append(msg % e)
        else:
            #
            # IGNORE the following parameters from the profile:
            #   - misc_settings.local_ip_address
            #
            if 'local_ip_address' in profile_inst.get_misc_settings():
                local_ip = get_local_ip()
                profile_misc_settings['local_ip_address'].set_value(local_ip)

            misc_settings = MiscSettings()
            misc_settings.set_options(profile_misc_settings)

        try:
            http_settings = profile_inst.get_http_settings()
        except BaseFrameworkException, e:
            msg = ('Setting the framework http-settings raised an exception'
                   ' due to unknown or invalid configuration parameters. %s')
            error_messages.append(msg % e)
        else:
            self._w3af_core.uri_opener.settings.set_options(http_settings)

        #
        #    Handle plugin options
        #
        error_fmt = ('The profile you are trying to load (%s) seems to be'
                     ' outdated, this is a common issue which happens when the'
예제 #2
0
파일: profiles.py 프로젝트: shiham101/w3af
            profile_misc_settings = profile_inst.get_misc_settings()
        except BaseFrameworkException, e:
            msg = ('Setting the framework misc-settings raised an exception'
                   ' due to unknown or invalid configuration parameters. %s')
            error_messages.append(msg % e)
        else:
            #
            # IGNORE the following parameters from the profile:
            #   - misc_settings.local_ip_address
            #
            if 'local_ip_address' in profile_inst.get_misc_settings():
                local_ip = get_local_ip()
                profile_misc_settings['local_ip_address'].set_value(local_ip)

            misc_settings = MiscSettings()
            misc_settings.set_options(profile_misc_settings)

        try:
            http_settings = profile_inst.get_http_settings()
        except BaseFrameworkException, e:
            msg = ('Setting the framework http-settings raised an exception'
                   ' due to unknown or invalid configuration parameters. %s')
            error_messages.append(msg % e)
        else:
            self._w3af_core.uri_opener.settings.set_options(http_settings)

        #
        #    Handle plugin options
        #
        error_fmt = (
            'The profile you are trying to load (%s) seems to be'
예제 #3
0
파일: profiles.py 프로젝트: cathartic/w3af
    def use_profile(self, profile_name, workdir=None):
        """
        Gets all the information from the profile and stores it in the
        w3af core plugins / target attributes for later use.

        :raise BaseFrameworkException: if the profile to load has some type of
                                       problem, or the plugins are incorrectly
                                       configured.
        """
        # Clear all enabled plugins if profile_name is None
        if profile_name is None:
            self._w3af_core.plugins.zero_enabled_plugins()
            return

        # This might raise an exception (which we don't want to handle) when
        # the profile does not exist
        profile_inst = profile(profile_name, workdir)

        # It exists, work with it!

        # Set the target settings of the profile to the core
        self._w3af_core.target.set_options(profile_inst.get_target())

        # Set the misc and http settings
        #
        # IGNORE the following parameters from the profile:
        #   - misc_settings.local_ip_address
        #
        profile_misc_settings = profile_inst.get_misc_settings()
        if "local_ip_address" in profile_inst.get_misc_settings():
            profile_misc_settings["local_ip_address"].set_value(get_local_ip())

        misc_settings = MiscSettings()
        misc_settings.set_options(profile_misc_settings)
        self._w3af_core.uri_opener.settings.set_options(profile_inst.get_http_settings())

        #
        #    Handle plugin options
        #
        error_fmt = (
            "The profile you are trying to load (%s) seems to be"
            " outdated, this is a common issue which happens when the"
            " framework is updated and one of its plugins adds/removes"
            " one of the configuration parameters referenced by a"
            " profile, or the plugin is removed all together.\n\n"
            "The profile was loaded but some of your settings might"
            " have been lost. This is the list of issues that were"
            " found:\n\n"
            "    - %s\n"
            "\nWe recommend you review the specific plugin"
            " configurations, apply the required changes and save"
            " the profile in order to update it and avoid this"
            " message. If this warning does not disappear you can"
            " manually edit the profile file to fix it."
        )

        error_messages = []
        core_set_plugins = self._w3af_core.plugins.set_plugins

        for plugin_type in self._w3af_core.plugins.get_plugin_types():
            plugin_names = profile_inst.get_enabled_plugins(plugin_type)

            # Handle errors that might have been triggered from a possibly
            # invalid profile
            try:
                unknown_plugins = core_set_plugins(plugin_names, plugin_type, raise_on_error=False)
            except KeyError:
                msg = 'The profile references the "%s" plugin type which is' " unknown to the w3af framework."
                error_messages.append(msg % plugin_type)
                continue

            for unknown_plugin in unknown_plugins:
                msg = 'The profile references the "%s.%s" plugin which is' " unknown in the current framework version."
                error_messages.append(msg % (plugin_type, unknown_plugin))

            # Now we set the plugin options, which can also trigger errors with
            # "outdated" profiles that users could have in their ~/.w3af/
            # directory.
            for plugin_name in set(plugin_names) - set(unknown_plugins):

                try:
                    plugin_options = profile_inst.get_plugin_options(plugin_type, plugin_name)
                    self._w3af_core.plugins.set_plugin_options(plugin_type, plugin_name, plugin_options)
                except BaseFrameworkException, w3e:
                    msg = (
                        'Setting the options for plugin "%s.%s" raised an'
                        " exception due to unknown or invalid configuration"
                        " parameters. %s"
                    )
                    error_messages.append(msg % (plugin_type, plugin_name, w3e))
예제 #4
0
파일: profiles.py 프로젝트: intfrr/Tortazo
    def use_profile(self, profile_name, workdir=None):
        """
        Gets all the information from the profile and stores it in the
        w3af core plugins / target attributes for later use.

        @raise BaseFrameworkException: if the profile to load has some type of problem.
        """
        # Clear all enabled plugins if profile_name is None
        if profile_name is None:
            self._w3af_core.plugins.zero_enabled_plugins()
            return

        # This might raise an exception (which we don't want to handle) when
        # the profile does not exist
        profile_inst = profile(profile_name, workdir)
        
        # It exists, work with it!

        # Set the target settings of the profile to the core
        self._w3af_core.target.set_options(profile_inst.get_target())

        # Set the misc and http settings
        #
        # IGNORE the following parameters from the profile:
        #   - misc_settings.local_ip_address
        #
        profile_misc_settings = profile_inst.get_misc_settings()
        if 'local_ip_address' in profile_inst.get_misc_settings():
            profile_misc_settings['local_ip_address'].set_value(get_local_ip())

        misc_settings = MiscSettings()
        misc_settings.set_options(profile_misc_settings)
        self._w3af_core.uri_opener.settings.set_options(
            profile_inst.get_http_settings())

        #
        #    Handle plugin options
        #
        error_fmt = ('The profile you are trying to load (%s) seems to be'
                     ' outdated, this is a common issue which happens when the'
                     ' framework is updated and one of its plugins adds/removes'
                     ' one of the configuration parameters referenced by a profile'
                     ', or the plugin is removed all together.\n\n'
                     'The profile was loaded but some of your settings might'
                     ' have been lost. This is the list of issues that were found:\n\n'
                     '    - %s\n'
                     '\nWe recommend you review the specific plugin configurations,'
                     ' apply the required changes and save the profile in order'
                     ' to update it and avoid this message. If this warning does not'
                     ' disappear you can manually edit the profile file to fix it.')

        error_messages = []

        for plugin_type in self._w3af_core.plugins.get_plugin_types():
            plugin_names = profile_inst.get_enabled_plugins(plugin_type)

            # Handle errors that might have been triggered from a possibly
            # invalid profile
            try:
                unknown_plugins = self._w3af_core.plugins.set_plugins(plugin_names,
                                                                      plugin_type,
                                                                      raise_on_error=False)
            except KeyError:
                msg = 'The profile references the "%s" plugin type which is'\
                      ' unknown to the w3af framework.'
                error_messages.append(msg % plugin_type)
                continue
                
            for unknown_plugin in unknown_plugins:
                msg = 'The profile references the "%s.%s" plugin which is unknown.'
                error_messages.append(msg % (plugin_type, unknown_plugin))

            # Now we set the plugin options, which can also trigger errors with "outdated"
            # profiles that users could have in their ~/.w3af/ directory.
            for plugin_name in set(plugin_names) - set(unknown_plugins):

                try:
                    plugin_options = profile_inst.get_plugin_options(
                        plugin_type,
                        plugin_name)
                    self._w3af_core.plugins.set_plugin_options(plugin_type,
                                                               plugin_name,
                                                               plugin_options)
                except BaseFrameworkException, w3e:
                    msg = 'Setting the options for plugin "%s.%s" raised an' \
                          ' exception due to unknown or invalid configuration' \
                          ' parameters.'
                    msg += ' ' + str(w3e)
                    error_messages.append(msg % (plugin_type, plugin_name))