Esempio n. 1
0
 def CommandDump(self, CommandIntro, OutputIntro, ResourceList, PluginInfo, PreviousOutput):
     output_list = []
     PluginOutputDir = self.InitPluginOutputDir(PluginInfo)
     for Name, Command in ResourceList:
         dump_file_name = os.path.splitext(Name)[0] + ".txt"  # Add txt extension to avoid wrong mimetypes
         plugin_output = dict(PLUGIN_OUTPUT)
         ModifiedCommand, FrameworkAbort, PluginAbort, TimeStr, RawOutput, PluginOutputDir = self.RunCommand(Command,
                                                                                                             PluginInfo,
                                                                                                             PluginOutputDir)
         plugin_output["type"] = "CommandDump"
         plugin_output["output"] = {
             "Name": self.GetCommandOutputFileNameAndExtension(Name)[0],
             "CommandIntro": CommandIntro,
             "ModifiedCommand": ModifiedCommand,
             "RelativeFilePath": self.plugin_handler.DumpOutputFile(dump_file_name, RawOutput, PluginInfo,
                                                                    RelativePath=True),
             "OutputIntro": OutputIntro,
             "TimeStr": TimeStr
         }
         plugin_output = [plugin_output]
         if Name == self.config.FrameworkConfigGet('EXTRACT_URLS_RESERVED_RESOURCE_NAME'):  # This command returns URLs for processing
             #  The plugin_output output dict will be remade if the resource is of this type
             plugin_output = self.LogURLsFromStr(RawOutput)
         # TODO: Look below to handle streaming report
         # if self.config.Get( 'UPDATE_REPORT_AFTER_EACH_COMMAND' ) == 'Yes':
         # self.reporter.SavePluginReport( Content, PluginInfo ) # Keep updating the report after each command/scanner runs
         if PluginAbort:  # Pass partial output to external handler:
             raise PluginAbortException(PreviousOutput + plugin_output)
         if FrameworkAbort:
             raise FrameworkAbortException(PreviousOutput + plugin_output)
         output_list += plugin_output
     return (output_list)
Esempio n. 2
0
 def FrameworkConfigGet(self, key):
     """Transparently gets config info from Target or General."""
     try:
         key = self.PadKey(key)
         return self.GetKeyValue(key)
     except KeyError:
         message = "The configuration item: '" + key + "' does not exist!"
         self.error_handler.Add(message)
         # Raise plugin-level exception to move on to next plugin.
         raise PluginAbortException(message)
Esempio n. 3
0
 def UserAbort(self, level, partial_output=''):
     # Levels so far can be Command or Plugin
     message = logging.info(
         "\nThe %s was aborted by the user: Please check the report and plugin output files" % level)
     message = (
         "\nThe %s was aborted by the user: Please check the report and plugin output files" % level)
     options = ""
     if 'Command' == level:
         options = ", 'p'+Enter= Move on to next plugin"
         option = 'p'
         if 'e' == option:
             if 'Command' == level:  # Try to save partial plugin results.
                 raise FrameworkAbortException(partial_output)
         elif 'p' == option:  # Move on to next plugin.
             # Jump to next handler and pass partial output to avoid losing
             # results.
             raise PluginAbortException(partial_output)
     return message