예제 #1
0
파일: Menu.py 프로젝트: KurSh/netzob
 def updateMenuWithPlugins(self):
     # Show plugins
     logging.debug("Retrieve plugins for Menu")
     for pluginExtension in NetzobPlugin.getLoadedPluginsExtension(GlobalMenuExtension):
         try:
             logging.debug("Menu available : {0}".format(pluginExtension))
             for menuEntry in pluginExtension.getMenuEntries():
                 if not menuEntry in self.menu_items:
                     self.item_factory.create_items([menuEntry])
                     self.menu_items.append(menuEntry)
         except Exception, e:
             logging.warning("An error occurred when computing menu entry for plugin {0} ({1})".format(pluginExtension, e))
예제 #2
0
    def __init__(self, controller, parent=None):
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(ResourcesConfiguration.getStaticResources(),
                                                "ui",
                                                "availablePluginsDialog.glade"))
        self._getObjects(self.builder, ["availablePluginsDialog", "pluginsListStore"])
        self.controller = controller
        self.builder.connect_signals(self.controller)

        # Retrieve the list of available plugins and display it
        availablePlugins = NetzobPlugin.getLoadedPlugins(NetzobPlugin)
        for plugin in availablePlugins:
            # add plugin in the list store
            i = self.pluginsListStore.append()
            self.pluginsListStore.set(i, 0, str(plugin.getName()))
            self.pluginsListStore.set(i, 1, str(plugin.getVersion()))
            self.pluginsListStore.set(i, 2, str(plugin.getDescription()))

        self.availablePluginsDialog.set_transient_for(parent)
예제 #3
0
    def __init__(self, controller, parent=None):
        self.builder = Gtk.Builder()
        self.builder.add_from_file(
            os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                         "availablePluginsDialog.glade"))
        self._getObjects(self.builder,
                         ["availablePluginsDialog", "pluginsListStore"])
        self.controller = controller
        self.builder.connect_signals(self.controller)

        # Retrieve the list of available plugins and display it
        availablePlugins = NetzobPlugin.getLoadedPlugins(NetzobPlugin)
        for plugin in availablePlugins:
            # add plugin in the list store
            i = self.pluginsListStore.append()
            self.pluginsListStore.set(i, 0, str(plugin.getName()))
            self.pluginsListStore.set(i, 1, str(plugin.getVersion()))
            self.pluginsListStore.set(i, 2, str(plugin.getDescription()))

        self.availablePluginsDialog.set_transient_for(parent)
예제 #4
0
    def importMessagesFromFile_activate_cb(self, action):
        """Execute all the plugins associated with
        file import."""
        if self.getCurrentProject() is None:
            NetzobErrorMessage(_("No project selected."))
            return

        importerPlugins = NetzobPlugin.getLoadedPlugins(FileImporterPlugin)
        if len(importerPlugins) < 1:
            NetzobErrorMessage(_("No importer plugin available."))
            return

        chooser = ImportFileChooserDialog(importerPlugins)
        res = chooser.run()
        plugin = None
        if res == chooser.RESPONSE_OK:
            (filePathList, plugin) = chooser.getFilenameListAndPlugin()
        chooser.destroy()
        if plugin is not None:
            plugin.setFinish_cb(self.view.updateSymbolList)
            plugin.importFile(filePathList)
예제 #5
0
    def importMessagesFromFile_activate_cb(self, action):
        """Execute all the plugins associated with
        file import."""
        if self.getCurrentProject() is None:
            NetzobErrorMessage(_("No project selected."))
            return

        importerPlugins = NetzobPlugin.getLoadedPlugins(FileImporterPlugin)
        if len(importerPlugins) < 1:
            NetzobErrorMessage(_("No importer plugin available."))
            return

        chooser = ImportFileChooserDialog(importerPlugins)
        res = chooser.run()
        plugin = None
        if res == chooser.RESPONSE_OK:
            (filePathList, plugin) = chooser.getFilenameListAndPlugin()
        chooser.destroy()
        if plugin is not None:
            plugin.setFinish_cb(self.view.updateSymbolList)
            plugin.importFile(filePathList)
예제 #6
0
 def __init__(self, netzob):
     NetzobPlugin.__init__(self, netzob)
예제 #7
0
 def __init__(self, netzob):
     NetzobPlugin.__init__(self, netzob)
     self.finish = None
예제 #8
0
 def updateListOfCapturerPlugins(self):
     """Fetch the list of available capturer plugins, and provide
     them to its associated view"""
     pluginExtensions = NetzobPlugin.getLoadedPluginsExtension(
         CapturerMenuExtension)
     self.view.updateListCapturerPlugins(pluginExtensions)
예제 #9
0
 def updateListOfCapturerPlugins(self):
     """Fetch the list of available capturer plugins, and provide
     them to its associated view"""
     pluginExtensions = NetzobPlugin.getLoadedPluginsExtension(CapturerMenuExtension)
     self.view.updateListCapturerPlugins(pluginExtensions)
예제 #10
0
 def __init__(self, netzob):
     NetzobPlugin.__init__(self, netzob)
예제 #11
0
    def __init__(self):
        # Parse command line arguments
        cmdLine = CommandLine()
        cmdLine.parse()
        opts = cmdLine.getOptions()

        # Current workspace path can be provided in command line argument
        if opts.workspace is None:
            workspaceDir = ResourcesConfiguration.getWorkspaceDir()
        else:
            workspaceDir = opts.workspace

        # Start the workspace management
        self.workspaceSelectorController = WorkspaceSelectorController(self)
        self.currentWorkspace = self.workspaceSelectorController.getWorkspace(workspaceDir)

        if self.currentWorkspace is None:
            sys.exit()

        #self.currentWorkspace = self._loadWorkspace(opts)
        self.currentProjet = None

        # Enable bug reporting, if workspace is configured so or if
        # netzob was explicitly started with the "-b" command line
        # option.
        enableBugReports = self.currentWorkspace.enableBugReporting
        if enableBugReports != opts.bugReport:
            enableBugReports = opts.bugReport
        self.enableBugReporter(enableBugReports)

        # Initialize everything else
        self._initLogging(opts)
        self._initResourcesAndLocales()

        # Intialize signals manager
        self.signalsManager = SignalsManager()

        # Loading the last project
        self.currentProject = self.currentWorkspace.getLastProject()

        # Initialize a clipboard object
        self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

        # Check dependencies
        if not DepCheck.checkRequiredDependency():
            self.log.fatal("Netzob could not start because some of its required dependencies were not found.")
            sys.exit()

        # Initialize main view
        self.log.info("Starting netzob UI")
        self.view = None    # small hack since the attribute need to exists when the main glade is loaded
        self.view = NetzobMainView(self)

        # Load all available plugins
        NetzobPlugin.loadPlugins(self)

        self.view.registerPerspectives()

        # Refresh list of available exporter plugins
        self.updateListOfExporterPlugins()

        # Refresh list of available projects
        self.updateListOfAvailableProjects()
예제 #12
0
 def __init__(self, netzob):
     NetzobPlugin.__init__(self, netzob)
     self.finish = None
예제 #13
0
파일: NetzobGui.py 프로젝트: KurSh/netzob
    def __init__(self):

        # Command line commands
        parser = CommandLine.get_parser()
        opts, args = parser.parse_args()

        gettext.bindtextdomain("netzob", ResourcesConfiguration.getLocaleLocation())
        gettext.textdomain("netzob")

        try:
            locale.getlocale()
        except:
            logging.exception("setlocale failed, resetting to C")
            locale.setlocale(locale.LC_ALL, "C")

        (status, version) = DepCheck.test_lxml()
        if status == False:
            logging.fatal("Version of python-lxml ({0}) is too old for Netzob. Please install a recent version (>= 2.3)".format(version))
            sys.exit()

        # First we initialize and verify all the resources
        if not ResourcesConfiguration.initializeResources():
            logging.fatal("Error while configuring the resources of Netzob")
            sys.exit()

        if opts.workspace == None:
            workspace = str(ResourcesConfiguration.getWorkspaceFile())
        else:
            workspace = opts.workspace

        logging.debug("The workspace: {0}".format(str(workspace)))

        # loading the workspace
        self.currentWorkspace = (Workspace.loadWorkspace(workspace))

        # the semi-automatic loading of the workspace has failed (second attempt)
        if self.currentWorkspace == None:
            # we force the creation (or specification) of the workspace
            if not ResourcesConfiguration.initializeResources(True):
                logging.fatal("Error while configuring the resources of Netzob")
                sys.exit()
            workspace = str(ResourcesConfiguration.getWorkspaceFile())
            logging.debug("The workspace: {0}".format(str(workspace)))
            # loading the workspace
            self.currentWorkspace = (Workspace.loadWorkspace(workspace))
            if self.currentWorkspace == None:
                logging.fatal("Stopping the execution (no workspace computed)!")
                sys.exit()

        self.currentProject = self.currentWorkspace.getLastProject()

        # Second we create the logging infrastructure
        LoggingConfiguration().initializeLogging(self.currentWorkspace)

        # Now we load all the available plugins
        NetzobPlugin.loadPlugins(self)

        # create logger with the given configuration
        self.log = logging.getLogger('netzob.py')
        self.log.info(_("Starting netzob"))

        # Main window definition
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.set_default_size(800, 600)
        self.set_title(_("Netzob: Inferring communication protocols"))

        self.set_icon_from_file(("%s/logo.png" %
                                 ResourcesConfiguration.getStaticResources()))
        self.connect("delete_event", self.evnmtDelete)
        self.connect("destroy", self.destroy)
        main_vbox = gtk.VBox(False, spacing=0)

        # Create and display the menu

        self.menu = Menu(self)
        menubar = self.menu.getMenuBar(self)
        menubar.show()
        self.menu.update()
        main_vbox.pack_start(menubar, False, True, 0)

        # Notebook definition
        self.notebook = gtk.Notebook()
        self.notebook.set_tab_pos(gtk.POS_TOP)
        self.notebook.connect("switch-page", self.notebookFocus)
        main_vbox.pack_start(self.notebook, True, True, 0)

        self.pageList = []
        # Adding the different notebook
        self.modelization = UImodelization(self)
        self.grammarInference = UIGrammarInference(self)
#        self.fuzzing = UIfuzzing(self)
        self.simulator = UISimulator(self)

        self.pageList.append([_("Vocabulary inference"), self.modelization])
        self.pageList.append([_("Grammar inference"), self.grammarInference])
#        self.pageList.append(["Fuzzing", self.fuzzing])
        self.pageList.append([_("Simulator"), self.simulator])

        for page in self.pageList:
            self.notebook.append_page(page[1].panel, gtk.Label(page[0]))

        # Initialize a clipboard object
        self.clipboard = (gtk.Clipboard(gtk.gdk.display_get_default(),
                                        "CLIPBOARD"))

        # Show every widgets
        self.notebook.show()
        main_vbox.show()
        self.add(main_vbox)
        self.show()
예제 #14
0
    def __init__(self):
        # Parse command line arguments
        cmdLine = CommandLine()
        cmdLine.parse()
        opts = cmdLine.getOptions()

        # Current workspace path can be provided in command line argument
        if opts.workspace is None:
            workspaceDir = ResourcesConfiguration.getWorkspaceDir()
        else:
            workspaceDir = opts.workspace

        # Start the workspace management
        self.workspaceSelectorController = WorkspaceSelectorController(self)
        self.currentWorkspace = self.workspaceSelectorController.getWorkspace(workspaceDir)

        if self.currentWorkspace is None:
            sys.exit()

        #self.currentWorkspace = self._loadWorkspace(opts)
        self.currentProjet = None

        # Enable bug reporting, if workspace is configured so or if
        # netzob was explicitly started with the "-b" command line
        # option.
        enableBugReports = self.currentWorkspace.enableBugReporting
        if enableBugReports != opts.bugReport:
            enableBugReports = opts.bugReport
        self.enableBugReporter(enableBugReports)

        # Initialize everything else
        self._initLogging(opts)
        self._initResourcesAndLocales()

        # Intialize signals manager
        self.signalsManager = SignalsManager()

        # Loading the last project
        self.currentProject = self.currentWorkspace.getLastProject()

        # Initialize a clipboard object
        self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

        # Check dependencies
        if not DepCheck.checkRequiredDependency():
            self.log.fatal("Netzob could not start because some of its required dependencies were not found.")
            sys.exit()

        # Initialize main view
        self.log.info("Starting netzob UI")
        self.view = None    # small hack since the attribute need to exists when the main glade is loaded
        self.view = NetzobMainView(self)

        # Load all available plugins
        NetzobPlugin.loadPlugins(self)

        self.view.registerPerspectives()

        # Refresh list of available exporter plugins
        self.updateListOfExporterPlugins()

        # Refresh list of available projects
        self.updateListOfAvailableProjects()