コード例 #1
0
 def _setup_layout(self):
     bin_label = QLabel(f"<h1>Binary: {self.data['name']}</h1>")
     bin_label.setToolTip(str(self.data["filepath"]))
     annotations_group = QGroupBox("Annotations")
     annotations_group.setLayout(layout_wrap(QHBoxLayout(), self.list))
     self.setLayout(
         layout_wrap(QVBoxLayout(), bin_label, annotations_group,
                     self.buttonBox))
コード例 #2
0
ファイル: binary_list.py プロジェクト: xihuni/polypyus
 def _setup_layout(self):
     name = QtWidgets.QLabel(self.name, self)
     name.setToolTip(str(self.filepath))
     layout = layout_wrap(
         QtWidgets.QHBoxLayout(),
         name,
         "stretch",
         self.request_export,
         self.delete_button,
     )
     self.setLayout(layout_wrap(QtWidgets.QVBoxLayout(), layout, self.match_label))
コード例 #3
0
    def __init__(self,
                 prompt,
                 file_type,
                 *args,
                 file_path=None,
                 button="Select File",
                 **kwargs):
        """FilePathSelection is a widget that facilitates selecting a file by dialog
        or by text input.

        Args:
             prompt: Title of the dialog
             file_type: Allowed file types
             *args: positional arguments to pass to QWidget
             button: optional button text overwrite
             **kwargs: keyword arguments to pass to QtWidget
        """
        super().__init__(*args, **kwargs)
        self.prompt = prompt
        self.file_type = file_type
        self.path_edit = QtWidgets.QLineEdit()
        self.path_edit.setText(file_path)
        self.select_file = QtWidgets.QPushButton(button)
        self.select_file.setIcon(self.style().standardIcon(
            QtWidgets.QStyle.SP_FileDialogStart))
        self.select_file.clicked.connect(self.show_file_dialog)
        self.select_file.setSizePolicy(fixed_policy)
        self.setLayout(
            layout_wrap(QtWidgets.QHBoxLayout(), self.path_edit,
                        self.select_file))
        self.path_edit.textEdited.connect(self.path_edited)
        self.path = file_path
コード例 #4
0
 def _setup_layout(self):
     type_label = TypeLabel(self.type_, self)
     name = QLabel(self.name, self)
     name.setToolTip(str(self.info))
     layout = layout_wrap(QHBoxLayout(), type_label, name, "stretch",
                          self.delete_button)
     self.setLayout(layout)
コード例 #5
0
 def _setup_layout(self):
     type_label = QLabel(self.type_, self)
     type_label.setAlignment(Qt.AlignCenter)
     type_label.setSizePolicy(fixed_policy)
     type_label.setProperty("class", "type_label")
     name = QLabel(self.name, self)
     name.setToolTip(str(self.info))
     layout = layout_wrap(
         QHBoxLayout(), type_label, name, "stretch", self.delete_button
     )
     self.setLayout(layout)
コード例 #6
0
ファイル: history_list.py プロジェクト: ycmint/polypyus
 def _setup_layout(self):
     layout = QHBoxLayout()
     name = QLabel(self.data["name"])
     name.setToolTip(str(self.data["filepath"]))
     layout.addWidget(name)
     layout.addStretch()
     layout.addWidget(self.edit_button)
     layout.addWidget(self.delete_button)
     layout2 = QHBoxLayout()
     for type_ in self.data["annotation_types"]:
         type_label = TypeLabel(type_, self)
         type_label.setFont(SMALL_FONT)
         layout2.addWidget(type_label)
     layout2.addStretch()
     self.setLayout(layout_wrap(QVBoxLayout(), layout, self.fncs, layout2))
コード例 #7
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     text = QtWidgets.QTextBrowser()
     with open(ASSETS_DIR.joinpath("style.css"), "r") as css:
         text.document().setDefaultStyleSheet(css.read())
     text.setReadOnly(True)
     text.setOpenLinks(False)
     text.setOpenExternalLinks(False)
     text.textCursor().insertHtml(
         "<h1> Polypyus: Firmware-History-Based Diffing </h1><br>")
     text.textCursor().insertImage(str(ASSETS_DIR.joinpath("Polypyus.png")))
     text.textCursor().insertHtml("<br>")
     with open(ASSETS_DIR.joinpath("about.html")) as html:
         text.textCursor().insertHtml(html.read())
     self.setLayout(layout_wrap(QtWidgets.QVBoxLayout(), text))
     text.moveCursor(QTextCursor.Start)
     self.text = text
     self.text.anchorClicked.connect(self.show_link)
コード例 #8
0
ファイル: history_list.py プロジェクト: xihuni/polypyus
 def _setup_layout(self):
     layout = QHBoxLayout()
     name = QLabel(self.data["name"])
     name.setToolTip(str(self.data["filepath"]))
     layout.addWidget(name)
     layout.addStretch()
     layout.addWidget(self.edit_button)
     layout.addWidget(self.delete_button)
     layout2 = QHBoxLayout()
     for type_ in self.data["annotation_types"]:
         type_label = QLabel(type_, self)
         type_label.setAlignment(Qt.AlignCenter)
         type_label.setSizePolicy(fixed_policy)
         type_label.setProperty("class", "type_label")
         type_label.setFont(SMALL_FONT)
         layout2.addWidget(type_label)
     layout2.addStretch()
     self.setLayout(layout_wrap(QVBoxLayout(), layout, self.fncs, layout2))
コード例 #9
0
    def _setup_layout(self):
        binary_label = QtWidgets.QLabel("<h3>Firmware dumps</h3>")
        binary_group = QtWidgets.QGroupBox("Targets")
        binary_group.setLayout(layout_wrap(QVBoxLayout(), self.binary_list))
        history_group = QtWidgets.QGroupBox("Annotated History")
        history_group.setLayout(layout_wrap(QVBoxLayout(), self.history_list))
        firmware_group = QtWidgets.QFrame()
        firmware_group.setLayout(
            layout_wrap(QtWidgets.QVBoxLayout(), binary_label, history_group,
                        binary_group))
        common_group = QtWidgets.QFrame()
        common_label = QtWidgets.QLabel("<h2>Matchers</h2>")

        self.generate_commons.setIcon(self.style().standardIcon(
            QStyle.SP_FileDialogContentsView))
        self.generate_commons.setSizePolicy(fixed_policy)
        common_counter = ListCounter("Matchers", parent=self)
        self.commons.RowCountChanged.connect(common_counter.update_count)
        common_group.setLayout(
            layout_wrap(
                QVBoxLayout(),
                common_label,
                self.generate_commons,
                self.commons,
                common_counter,
            ))

        history_and_common_layout = layout_wrap(QtWidgets.QSplitter(),
                                                firmware_group, common_group)
        width = history_and_common_layout.size().width()
        history_and_common_layout.setSizes(
            [int(width * 0.5), int(width * 0.5)])

        target_group = QtWidgets.QGroupBox("Target selection")
        target_form = QtWidgets.QFormLayout()
        target_form.addRow(self.target_label, self.target_matching)
        target_form.addRow("Match against all targets", self.batch_matching)
        target_group.setLayout(target_form)

        self.target_matching.setSizePolicy(fixed_policy)
        self.batch_matching.setSizePolicy(fixed_policy)
        self.target_matching.setIcon(self.style().standardIcon(
            QStyle.SP_CommandLink))
        match_frame = QtWidgets.QFrame()
        match_counter = ListCounter("Matches", parent=self)
        self.matches.RowCountChanged.connect(match_counter.update_count)
        match_frame.setLayout(
            layout_wrap(
                QtWidgets.QVBoxLayout(),
                QtWidgets.QLabel("<h1>Matching</h1>"),
                target_group,
                self.matches,
                match_counter,
            ))

        main_layout = layout_wrap(QtWidgets.QSplitter(),
                                  history_and_common_layout, match_frame)
        width = main_layout.size().width()
        main_layout.setSizes([int(width * (1 - 0.2)), int(width * (0.2))])
        layout = QVBoxLayout()
        layout.addWidget(main_layout)
        widget_frame = QtWidgets.QFrame()
        widget_frame.setLayout(layout)
        self.setCentralWidget(widget_frame)
コード例 #10
0
 def _setup_layout(self):
     self.setLayout(layout_wrap(QVBoxLayout(), self.add_button, self.list))
コード例 #11
0
    def __init__(self, settings: dict, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setWindowFlags(QtCore.Qt.Dialog)
        self.setWindowTitle("Settings")

        self.experimental_disassembly = QtWidgets.QCheckBox()
        self.matcher_parallelization = QtWidgets.QCheckBox()
        self.find_fnc_starts = QtWidgets.QCheckBox()

        self.fnc_start_size = QtWidgets.QDoubleSpinBox()
        self.fnc_start_size.setMinimum(8)
        self.fnc_start_size.setMaximum(64)
        self.fnc_start_size.setDecimals(0)
        self.fnc_start_size.setSuffix(" Bytes")
        self.fnc_start_size.setSingleStep(2)
        self.fnc_start_size.setValue(8)

        self.partitioning_gap = QtWidgets.QDoubleSpinBox()
        self.partitioning_gap.setMinimum(2)
        self.partitioning_gap.setMaximum(0x10000)
        self.partitioning_gap.setDecimals(0)
        self.partitioning_gap.setSuffix(" Bytes")
        self.partitioning_gap.setSingleStep(2)
        self.partitioning_gap.setValue(0x100)

        self.min_fnc_size = QtWidgets.QDoubleSpinBox()
        self.min_fnc_size.setMinimum(8)
        self.min_fnc_size.setMaximum(1000)
        self.min_fnc_size.setSuffix(" Bytes")
        self.min_fnc_size.setSingleStep(2)
        self.min_fnc_size.setDecimals(0)
        self.min_fnc_size.setValue(24)

        self.max_rel_fuzziness = QtWidgets.QDoubleSpinBox()
        self.max_rel_fuzziness.setMinimum(0)
        self.max_rel_fuzziness.setMaximum(100)
        self.max_rel_fuzziness.setSuffix("%")
        self.max_rel_fuzziness.setDecimals(1)
        self.max_rel_fuzziness.setSingleStep(1)
        self.max_rel_fuzziness.setValue(40)

        importer_group = QtWidgets.QGroupBox("Importer settings")
        importer_group_layout = QtWidgets.QFormLayout()
        importer_group_layout.addRow(
            "Minimum gap between between code partitions", self.partitioning_gap,
        )
        importer_group_layout.addRow(
            "Experimental: Validate symbol sizes through disassembly",
            self.experimental_disassembly,
        )
        importer_group_layout.addRow(
            "Hint", QtWidgets.QLabel("Changing these values will reset the project!"),
        )
        importer_group.setLayout(importer_group_layout)

        common_settings_group = QtWidgets.QGroupBox("Matcher settings")
        common_settings_form = QtWidgets.QFormLayout()
        common_settings_form.addRow("Min. function size", self.min_fnc_size)
        common_settings_form.addRow("Max. relative Fuzziness", self.max_rel_fuzziness)
        common_settings_form.addRow(
            "Mark common function prologues in unmatched regions", self.find_fnc_starts,
        )
        common_settings_form.addRow("Function prologue size", self.fnc_start_size)
        common_settings_form.addRow(
            "Hint", QtWidgets.QLabel("Changing these values will reset the matchers.")
        )
        common_settings_group.setLayout(common_settings_form)

        performance_settings_group = QtWidgets.QGroupBox("Performance settings")
        performance_settings_form = QtWidgets.QFormLayout()
        common_settings_form.addRow(
            "Parallelize match finding", self.matcher_parallelization
        )

        self.buttonBox = self._make_buttonbox()
        self.setLayout(
            layout_wrap(
                QtWidgets.QVBoxLayout(),
                importer_group,
                common_settings_group,
                self.buttonBox,
            )
        )

        self.load_settings(settings)