Ejemplo n.º 1
0
 def getMiscSettings( self ):
     '''
     Get the misc settings options.
     @return: The misc settings in an optionList object
     '''
     import core.controllers.miscSettings as miscSettings
     misc_settings = miscSettings.miscSettings()
     return self._get_x_settings('misc-settings', misc_settings)
Ejemplo n.º 2
0
 def __init__(self, name, console, core, parent=None):
     menu.__init__(self, name, console, core, parent)
     self._loadHelp( 'root' )
     
     #   At first, there is no scan thread
     self._scan_thread = None
     
     mapDict(self.addChild, {
         'plugins': pluginsMenu,
         'target' : (configMenu, self._w3af.target),
         'misc-settings' : (configMenu, ms.miscSettings()),
         'http-settings' : (configMenu, self._w3af.uriOpener.settings),
         'profiles' : profilesMenu,
         'exploit' : exploit,
         'kb': kbMenu
     })
Ejemplo n.º 3
0
 def saveCurrentToProfile(self, profile_name, prof_desc='', prof_path=''):
     '''
     Save the current configuration of the core to the profile called 
     profile_name.
     
     @return: The new profile instance if the profile was successfully saved.
         otherwise raise a w3afException.
     '''
     # Open the already existing profile
     new_profile = profile(profile_name, workdir=os.path.dirname(prof_path))
     
     # Save the enabled plugins
     for pType in self._w3af_core.plugins.getPluginTypes():
         enabledPlugins = []
         for pName in self._w3af_core.plugins.getEnabledPlugins(pType):
             enabledPlugins.append( pName )
         new_profile.setEnabledPlugins(pType, enabledPlugins)
     
     # Save the profile options
     for pType in self._w3af_core.plugins.getPluginTypes():
         for pName in self._w3af_core.plugins.getEnabledPlugins(pType):
             pOptions = self._w3af_core.plugins.getPluginOptions(pType, pName)
             if pOptions:
                 new_profile.setPluginOptions(pType, pName, pOptions)
             
     # Save the profile targets
     targets = cf.cf.getData('targets')
     if targets:
         new_profile.setTarget(' , '.join(t.url_string for t in targets))
             
     # Save the misc and http settings
     misc_settings = miscSettings.miscSettings()
     new_profile.setMiscSettings(misc_settings.getOptions())
     new_profile.setHttpSettings(self._w3af_core.uriOpener.settings.getOptions())
     
     # Save the profile name and description
     new_profile.setDesc(prof_desc)
     new_profile.setName(profile_name)
     
     # Save the profile to the file
     new_profile.save(profile_name)
     
     return new_profile
Ejemplo n.º 4
0
    def __init__(self, name, console, core, parent=None):
        menu.__init__(self, name, console, core, parent)
        self._loadHelp("root")

        #   At first, there is no scan thread
        self._scan_thread = None

        mapDict(
            self.addChild,
            {
                "plugins": pluginsMenu,
                "target": (configMenu, self._w3af.target),
                "misc-settings": (configMenu, ms.miscSettings()),
                "http-settings": (configMenu, self._w3af.uriOpener.settings),
                "profiles": profilesMenu,
                "bug-report": bug_report_menu,
                "exploit": exploit,
                "kb": kbMenu,
            },
        )
Ejemplo n.º 5
0
 def useProfile(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 w3afException: 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
     
     try:            
         profileInstance = profile(profile_name, workdir) 
     except w3afException:
         # The profile doesn't exist!
         raise
     else:
         # It exists, work with it!
         for pluginType in self._w3af_core.plugins.getPluginTypes():
             pluginNames = profileInstance.getEnabledPlugins( pluginType )
             
             # Handle errors that might have been triggered from a possibly invalid profile
             unknown_plugins = self._w3af_core.plugins.setPlugins( pluginNames, pluginType )
             if unknown_plugins:
                 om.out.error('The profile references the following missing plugins:')
                 for unknown_plugin_name in unknown_plugins:
                     om.out.error('- ' + unknown_plugin_name)
                 
             # Now we set the plugin options, which can also trigger errors with "outdated"
             # profiles that users could have in their ~/.w3af/ directory.
             for pluginName in profileInstance.getEnabledPlugins( pluginType ):
                 pluginOptions = profileInstance.getPluginOptions( pluginType, pluginName )
                 try:
                     # FIXME: Does this work with output plugin options?
                     # What about target, http-settings, etc?
                     self._w3af_core.plugins.setPluginOptions( pluginType, 
                                                               pluginName,
                                                               pluginOptions )
                 except Exception, e:
                     # This is because of an invalid plugin, or something like that...
                     # Added as a part of the fix of bug #1937272
                     msg = ('The profile you are trying to load seems to be'
                     ' outdated, one of the enabled plugins has a bug or an'
                     ' plugin option that was valid when you created the '
                     'profile was now removed from the framework. The plugin'
                     ' that triggered this exception is "%s", and the '
                     'original exception is: "%s"' % (pluginName, e))
                     om.out.error(msg)
                 
         # Set the target settings of the profile to the core
         self._w3af_core.target.setOptions( profileInstance.getTarget() )
         
         # Set the misc and http settings
         #
         # IGNORE the following parameters from the profile:
         #   - miscSettings.localAddress
         #
         profile_misc_settings = profileInstance.getMiscSettings()
         if 'localAddress' in profileInstance.getMiscSettings():
             profile_misc_settings['localAddress'].setValue(get_local_ip())
         
         misc_settings = miscSettings.miscSettings()
         misc_settings.setOptions( profile_misc_settings )
         self._w3af_core.uriOpener.settings.setOptions( profileInstance.getHttpSettings() )