Ejemplo n.º 1
0
    def add_empty_row_behind(self, row_index: int, num_bits: int):
        message = Message(plain_bits=[0]*num_bits,
                          pause=constants.SETTINGS.value("default_fuzzing_pause", 10**6, int),
                          message_type=self.protocol.default_message_type)

        tmp_protocol = ProtocolAnalyzer(None)
        tmp_protocol.messages = [message]
        undo_action = InsertBitsAndPauses(self.protocol, row_index+1, tmp_protocol)
        self.undo_stack.push(undo_action)
Ejemplo n.º 2
0
    def dropMimeData(self, mimedata, action, row, column, parentIndex):
        if action == Qt.IgnoreAction:
            return True

        data_str = str(mimedata.text())
        indexes = list(data_str.split("/")[:-1])

        group_nodes = []
        file_nodes = []
        for index in indexes:
            try:
                row, column, parent = map(int, index.split(","))
                if parent == -1:
                    parent = self.tree_root_item
                else:
                    parent = self.tree_root_item.child(parent)
                node = parent.child(row)
                if node.is_group:
                    group_nodes.append(node)
                else:
                    file_nodes.append(node)
            except ValueError:
                continue

        # Which Nodes to add?
        nodes_to_add = []  # type: list[ProtocolTreeItem]

        for group_node in group_nodes:
            nodes_to_add.extend(group_node.children)
        nodes_to_add.extend([
            file_node for file_node in file_nodes
            if file_node not in nodes_to_add
        ])

        is_empty = self.row_count == 0

        for node in reversed(nodes_to_add):
            undo_action = InsertBitsAndPauses(self.protocol, self.dropped_row,
                                              node.protocol)
            self.undo_stack.push(undo_action)

        if is_empty and self.row_count > 0:
            self.first_protocol_added.emit(nodes_to_add[0].protocol)

        return True
Ejemplo n.º 3
0
    def generate_de_bruijn(self, row_index: int, start: int, end: int):
        if start < 0 or end < 0:
            return

        f = 1 if self.proto_view == 0 else 4 if self.proto_view == 1 else 8
        start, end = f * start, f * end

        de_bruijn_seq = util.de_bruijn(end-start)

        tmp_protocol = ProtocolAnalyzer(None)
        tmp_protocol.messages = []
        LINE_BREAK_AFTER = 5000 * f
        for i in range(0, len(de_bruijn_seq), LINE_BREAK_AFTER):
            message = Message(plain_bits=de_bruijn_seq[i:i+LINE_BREAK_AFTER],
                              pause=0,
                              message_type=self.protocol.default_message_type)
            tmp_protocol.messages.append(message)

        undo_action = InsertBitsAndPauses(self.protocol, row_index+1, tmp_protocol)
        self.undo_stack.push(undo_action)
Ejemplo n.º 4
0
    def dropMimeData(self, mimedata, action, row, column, parentIndex):
        if action == Qt.IgnoreAction:
            return True

        data_str = str(mimedata.text())
        indexes = list(data_str.split("/")[:-1])

        group_nodes = []
        file_nodes = []
        for index in indexes:
            row, column, parent = map(int, index.split(","))
            if parent == -1:
                parent = self.tree_root_item
            else:
                parent = self.tree_root_item.child(parent)
            node = parent.child(row)
            if node.is_group:
                group_nodes.append(node)
            else:
                file_nodes.append(node)

        # Which Nodes to add?
        nodes_to_add = []
        """:type: list of ProtocolTreeItem """
        for group_node in group_nodes:
            nodes_to_add.extend(group_node.children)
        nodes_to_add.extend([
            file_node for file_node in file_nodes
            if file_node not in nodes_to_add
        ])

        for node in reversed(nodes_to_add):
            undo_action = InsertBitsAndPauses(self.protocol, self.dropped_row,
                                              node.protocol)
            self.undo_stack.push(undo_action)

        return True