示例#1
0
    def update_checksums_for_row(self, row: int):
        message = self.protocol.messages[row]
        for lbl in message.message_type.checksum_labels:  # type: ChecksumLabel
            if lbl.fuzz_created:
                continue

            self.__set_italic_font_for_label_range(row, lbl, italic=True)
            self.edited_checksum_labels_by_row[row].discard(lbl)

            calculated_checksum = lbl.calculate_checksum_for_message(message, use_decoded_bits=False)
            label_range = message.get_label_range(lbl=lbl, view=0, decode=False)
            start, end = label_range[0], label_range[1]
            message.plain_bits[start:end] = calculated_checksum + array.array("B", [0] * (
            (end - start) - len(calculated_checksum)))

            label_range = message.get_label_range(lbl=lbl, view=self.proto_view, decode=False)
            start, end = label_range[0], label_range[1]
            if self.proto_view == 0:
                data = calculated_checksum
            elif self.proto_view == 1:
                data = util.aggregate_bits(calculated_checksum, size=4)
            elif self.proto_view == 2:
                data = util.aggregate_bits(calculated_checksum, size=8)
            else:
                data = array.array("B", [])

            self.display_data[row][start:end] = data + array.array("B", [0] * ((end - start) - len(data)))
示例#2
0
    def update_checksums_for_row(self, row: int):
        msg = self.protocol.messages[row]
        for lbl in msg.message_type.checksum_labels:  # type: ChecksumLabel
            if lbl.fuzz_created:
                continue

            self.__set_italic_font_for_label_range(row, lbl, italic=True)
            self.edited_checksum_labels_by_row[row].discard(lbl)

            calculated_checksum = lbl.calculate_checksum_for_message(
                msg, use_decoded_bits=False)
            label_range = msg.get_label_range(lbl=lbl, view=0, decode=False)
            start, end = label_range[0], label_range[1]
            msg[start:end] = calculated_checksum + array.array(
                "B", [0] * ((end - start) - len(calculated_checksum)))

            label_range = msg.get_label_range(lbl=lbl,
                                              view=self.proto_view,
                                              decode=False)
            start, end = label_range[0], label_range[1]
            if self.proto_view == 0:
                data = calculated_checksum
            elif self.proto_view == 1:
                data = util.aggregate_bits(calculated_checksum, size=4)
            elif self.proto_view == 2:
                data = util.aggregate_bits(calculated_checksum, size=8)
            else:
                data = array.array("B", [])

            self.display_data[row][start:end] = data + array.array(
                "B", [0] * ((end - start) - len(data)))
示例#3
0
 def to_binary(self, filename: str, use_decoded: bool):
     with open(filename, "wb") as f:
         for msg in self.messages:
             bits = msg.decoded_bits if use_decoded else msg.plain_bits
             aggregated = urh_util.aggregate_bits(bits, size=8)
             f.write(bytes(aggregated))
示例#4
0
 def to_binary(self, filename: str, use_decoded: bool):
     with open(filename, "wb") as f:
         for msg in self.messages:
             bits = msg.decoded_bits if use_decoded else msg.plain_bits
             aggregated = urh_util.aggregate_bits(bits, size=8)
             f.write(bytes(aggregated))