def findSizeFields(self):
        # Save the current encapsulation level of each field
        savedEncapsulationLevel = []
        for field in self.vocabularyController.treeSymbolController.selectedSymbol.getExtendedFields():
            savedEncapsulationLevel.append(field.getEncapsulationLevel())

        sizeFieldIdentifier = SizeFieldIdentifier()

        # Show the progression dialog
        dialog = Gtk.Dialog(title=_("Size Fields Identifications"), flags=0, buttons=None)
        panel = Gtk.Table(rows=2, columns=2, homogeneous=False)
        panel.show()

        # Progress bar
        self.progressBarSizeField = NetzobProgressBar()
        panel.attach(self.progressBarSizeField, 0, 2, 0, 1, xoptions=Gtk.AttachOptions.FILL, yoptions=0, xpadding=5, ypadding=5)

        # Buttons
        cancelSizeFieldButton = NetzobButton(_("Cancel"))
        startSizeFieldButton = NetzobButton(_("Start"))

        cancelSizeFieldButton.set_sensitive(False)
        cancelSizeFieldButton.connect("clicked", self.cancelfindSizeFields_cb, dialog, startSizeFieldButton, sizeFieldIdentifier)
        startSizeFieldButton.connect("clicked", self.findSizeFields_cb, dialog, sizeFieldIdentifier, [self.vocabularyController.treeSymbolController.selectedSymbol], cancelSizeFieldButton, savedEncapsulationLevel)

        panel.attach(startSizeFieldButton, 0, 1, 1, 2, xoptions=Gtk.AttachOptions.FILL, yoptions=0, xpadding=5, ypadding=5)
        panel.attach(cancelSizeFieldButton, 1, 2, 1, 2, xoptions=Gtk.AttachOptions.FILL, yoptions=0, xpadding=5, ypadding=5)

        dialog.vbox.pack_start(panel, True, True, 0)
        dialog.show()
示例#2
0
    def importTrace(self, event, trace):
        importDialog = gtk.Dialog(title=_("Import selected Trace in a project"), flags=0, buttons=None)
        panel = gtk.Table(rows=4, columns=2, homogeneous=False)
        panel.show()

        # Label
        label = NetzobLabel(_("Trace ID"))
        panel.attach(label, 0, 1, 0, 1, xoptions=gtk.FILL, yoptions=0, xpadding=5, ypadding=5)
        label2 = NetzobLabel(trace.getID())
        panel.attach(label2, 1, 2, 0, 1, xoptions=gtk.FILL, yoptions=0, xpadding=5, ypadding=5)

        label3 = NetzobLabel(_("Select project"))
        panel.attach(label3, 0, 1, 1, 2, xoptions=gtk.FILL, yoptions=0, xpadding=5, ypadding=5)
        # Delimiter type
        projectCombo = NetzobComboBoxEntry()
        for project in self.workspace.getProjects():
            projectCombo.append_text(project.getName())

        panel.attach(projectCombo, 1, 2, 1, 2, xoptions=gtk.FILL, yoptions=0, xpadding=5, ypadding=5)

        # Progress bar
        self.progressbarAlignment = NetzobProgressBar()
        panel.attach(self.progressbarAlignment, 0, 2, 2, 3, xoptions=gtk.FILL, yoptions=0, xpadding=5, ypadding=5)

        # Button
        importButton = NetzobButton(_("Import"))
        importButton.connect("clicked", self.importTraceAction, trace, projectCombo, importDialog)
        panel.attach(importButton, 0, 2, 3, 4, xoptions=gtk.FILL, yoptions=0, xpadding=5, ypadding=5)

        importDialog.vbox.pack_start(panel, True, True, 0)
        importDialog.show()
    def findSizeFields_results_cb(self, results, savedEncapsulationLevel):
        dialog = Gtk.Dialog(title="Potential size fields and related payload", flags=0, buttons=None)
        ## ListStore format:
        # int: size field column
        # int: size field size
        # int: start column
        # int: substart column
        # int: end column
        # int: subend column
        # str: message rendered in cell
        treeview = Gtk.TreeView(Gtk.ListStore(int, int, int, int, int, int, str))
        cell = Gtk.CellRendererText()
        selection = treeview.get_selection()
        selection.connect("changed", self.sizeField_selected, savedEncapsulationLevel)
        column = Gtk.TreeViewColumn('Size field and related payload')
        column.pack_start(cell, True)
        column.add_attribute(cell, "text", 6)
        treeview.append_column(column)

       # Chose button
        but = NetzobButton("Apply size field")
        but.connect("clicked", self.applySizeField, dialog, savedEncapsulationLevel)
        dialog.action_area.pack_start(but, True, True, 0)

       # Text view containing potential size fields
        treeview.set_size_request(800, 300)

        if len(results) == 0:
            NetzobErrorMessage("No size field found.")
        else:
            for result in results:
                treeview.get_model().append(result)

            treeview.show()
            scroll = Gtk.ScrolledWindow()
            scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
            scroll.show()
            scroll.add(treeview)
            dialog.vbox.pack_start(scroll, True, True, 0)
            dialog.connect("destroy", self.destroyDialogFindSizeFields, savedEncapsulationLevel)
            dialog.show()