Example #1
0
    def __str__(self):
        checksum1 = " (!)" if self.checksum != self.calculate_checksum() else ""

        output = \
        microparse.static.fmt_string % ("Header Version", microparse.static.hex8(self.header_version)) + \
        microparse.static.fmt_string % ("Update Revision", microparse.static.hex8(self.update_revision)) + \
        microparse.static.fmt_string % ("Date", microparse.static.int2date(self.date)) + \
        microparse.static.fmt_string % ("Processor Signature", microparse.static.hex8(self.processor_signature)) + \
        str(microparse.signature(self.processor_signature)) + \
        microparse.static.fmt_string % ("Checksum", microparse.static.hex8(self.checksum) + checksum1) + \
        microparse.static.fmt_string % ("Loader Revision", microparse.static.hex8(self.loader_revision)) + \
        microparse.static.fmt_string % ("Processor Flags", microparse.static.hex8(self.processor_flags)) + \
        microparse.static.fmt_string % ("Data Size", microparse.static.hex8(self.data_size)) + \
        microparse.static.fmt_string % ("Total Size", microparse.static.hex8(self.total_size)) + \
        microparse.static.fmt_string % ("Unknown 1", microparse.static.hex8(self.unknown1)) + \
        microparse.static.fmt_string % ("Unknown 2", microparse.static.hex8(self.unknown2)) + \
        microparse.static.fmt_string % ("Unknown 3", microparse.static.hex8(self.unknown3))

        if self.is_data_extended:
            output += \
            microparse.static.fmt_string % ("Data Unknown 1", microparse.static.hex8(self.data_unknown1)) + \
            microparse.static.fmt_string % ("Data Unknown 2", microparse.static.hex8(self.data_unknown2)) + \
            microparse.static.fmt_string % ("Data Unknown 3", microparse.static.hex8(self.data_unknown3)) + \
            microparse.static.fmt_string % ("Data Revision", microparse.static.hex8(self.data_revision)) + \
            microparse.static.fmt_string % ("Data Unknown 4", microparse.static.hex8(self.data_unknown4)) + \
            microparse.static.fmt_string % ("Data Unknown 5", microparse.static.hex8(self.data_unknown5)) + \
            microparse.static.fmt_string % ("Data Date", microparse.static.int2date(self.data_date)) + \
            microparse.static.fmt_string % ("Data Length", microparse.static.hex8(self.data_length)) + \
            microparse.static.fmt_string % ("Data Unknown 6", microparse.static.hex8(self.data_unknown6)) + \
            microparse.static.fmt_string % ("Data Processor Signature", microparse.static.hex8(self.data_processor_signature)) + \
            str(microparse.signature(self.data_processor_signature)) + \
            microparse.static.fmt_string % ("Data Unknown 7", microparse.static.hex8(self.data_unknown7)) + \
            microparse.static.fmt_string % ("Data Unknown 8", microparse.static.hex8(self.data_unknown8)) + \
            microparse.static.fmt_string % ("Data Unknown 9", microparse.static.hex8(self.data_unknown9)) + \
            microparse.static.fmt_string % ("Data Unknown 10", microparse.static.hex8(self.data_unknown10)) + \
            microparse.static.fmt_string % ("Data Unknown 11", microparse.static.hex8(self.data_unknown11)) + \
            microparse.static.fmt_string % ("Data Unknown 12", microparse.static.hex8(self.data_unknown12)) + \
            microparse.static.fmt_string % ("Data Unknown 13", microparse.static.hex8(self.data_unknown13)) + \
            microparse.static.fmt_string % ("Data Unknown 14", microparse.static.hex8(self.data_unknown14)) + \
            microparse.static.fmt_string % ("Data Unknown 15", microparse.static.hex8(self.data_unknown15)) + \
            microparse.static.fmt_string % ("Data Unknown 16", microparse.static.hex8(self.data_unknown16)) + \
            microparse.static.fmt_string % ("Data Unknown 17", microparse.static.hex8(self.data_unknown17)) + \
            microparse.static.fmt_string % ("Data Unknown 18", microparse.static.hex8(self.data_unknown18)) + \
            microparse.static.fmt_string % ("Data Unknown 19", microparse.static.hex8(self.data_unknown19)) + \
            microparse.static.fmt_string % ("Data Unknown 20", microparse.static.hex8(self.data_unknown20))

        if self.is_extended:
            checksum2 = " (!)" if self.extended_checksum != self.calculate_extended_table_checksum() else ""

            output += \
            microparse.static.fmt_string % ("Extended Signature Count", microparse.static.hex8(self.extended_signature_count)) + \
            microparse.static.fmt_string % ("Extended Checksum", microparse.static.hex8(self.extended_checksum) + checksum2) + \
            microparse.static.fmt_string % ("Unknown 4", microparse.static.hex8(self.unknown4)) + \
            microparse.static.fmt_string % ("Unknown 5", microparse.static.hex8(self.unknown5)) + \
            microparse.static.fmt_string % ("Unknown 6", microparse.static.hex8(self.unknown6))

        return output
Example #2
0
    def __str__(self):
        #checksum = " (!)" if self.checksum != self.calculate_checksum() else ""

        return \
        microparse.static.fmt_string % ("Update Revision", microparse.static.hex8(self.update_revision)) + \
        microparse.static.fmt_string % ("Date", microparse.static.ymd2date(self.year, self.month, self.day)) + \
        microparse.static.fmt_string % ("Processor Signature", microparse.static.hex8(self.signature)) + \
        str(microparse.signature(self.signature)) + \
        microparse.static.fmt_string % ("Checksum", microparse.static.hex8(self.checksum)) + \
        microparse.static.fmt_string % ("Loader Revision", microparse.static.hex8(self.loader_revision)) + \
        microparse.static.fmt_string % ("Reserved 1", microparse.static.hex8(self.reserved1)) + \
        microparse.static.fmt_string % ("Payload Size", microparse.static.hex8(self.payload_size)) + \
        microparse.static.fmt_string % ("Total Size", microparse.static.hex8(self.total_size)) + \
        microparse.static.fmt_string % ("Name" , "\"" + self.name.decode("utf-8") + "\"") + \
        microparse.static.fmt_string % ("Reserved 2", microparse.static.hex8(self.reserved2))
Example #3
0
    def __str__(self):
        #checksum = " (!)" if self.checksum != self.calculate_checksum() else ""

        return \
        microparse.static.fmt_string % ("Update Revision", microparse.static.hex8(self.update_revision)) + \
        microparse.static.fmt_string % ("Date", microparse.static.ymd2date(self.year, self.month, self.day)) + \
        microparse.static.fmt_string % ("Processor Signature", microparse.static.hex8(self.signature)) + \
        str(microparse.signature(self.signature)) + \
        microparse.static.fmt_string % ("Checksum", microparse.static.hex8(self.checksum)) + \
        microparse.static.fmt_string % ("Loader Revision", microparse.static.hex8(self.loader_revision)) + \
        microparse.static.fmt_string % ("Reserved 1", microparse.static.hex8(self.reserved1)) + \
        microparse.static.fmt_string % ("Payload Size", microparse.static.hex8(self.payload_size)) + \
        microparse.static.fmt_string % ("Total Size", microparse.static.hex8(self.total_size)) + \
        microparse.static.fmt_string % ("Name" , "\"" + self.name.decode("utf-8") + "\"") + \
        microparse.static.fmt_string % ("Reserved 2", microparse.static.hex8(self.reserved2))
Example #4
0
    def parse_header(self, data):
        if len(data) == static.header(self.is_swap_endian).size:
            try:
                header = static.header(self.is_swap_endian).unpack(data)
            except struct.error:
                raise Exception("Cannot unpack microcode header!")

            self.date = header[0]
            self.patch_id = header[1]
            self.patch_data_id = header[2]
            self.patch_data_len = header[3]
            # attempt to compute total size, will fail for newer encrypted microcode with patch_data_len = 0
            # if self.total_size == 0 and self.patch_data_len != 0:
            #     self.total_size = static.header(self.is_swap_endian).size + self.patch_data_len * microparse.static.data(self.is_swap_endian).size * static.TRIAD_SIZE
            self.init_flag = header[4]
            self.patch_data_checksum = header[5]
            self.nb_dev_id = header[6]
            self.sb_dev_id = header[7]
            self.processor_rev_id = header[8]
            if (self.equiv_cpuid):
                for s in self.equiv_cpuid[self.processor_rev_id]:
                    signature = microparse.signature(s)
                    if (signature.family == 0xe and self.total_size > static.F14_MAX_SIZE) \
                    or (signature.family == 0xf and self.total_size > static.F15_MAX_SIZE) \
                    or ((signature.family != 0xe and signature.family != 0xf) and self.total_size > static.F1X_MAX_SIZE):
                        raise Exception("Microcode exceeds maximum valid size")

            self.nb_rev_id = header[9]
            self.sb_rev_id = header[10]
            self.bios_api_rev = header[11]
            self.unknown1 = header[12]
            self.unknown2 = header[13]
            self.unknown3 = header[14]
            self.match_reg1 = header[15]
            self.match_reg2 = header[16]
            self.match_reg3 = header[17]
            self.match_reg4 = header[18]
            self.match_reg5 = header[19]
            self.match_reg6 = header[20]
            self.match_reg7 = header[21]
            self.match_reg8 = header[22]
        else:
            raise Exception("Input microcode header size mismatch!")
Example #5
0
    def parse_header(self, data):
        if len(data) == static.header(self.is_swap_endian).size:
            try:
                header = static.header(self.is_swap_endian).unpack(data)
            except struct.error:
                raise Exception("Cannot unpack microcode header!")

            self.date = header[0]
            self.patch_id = header[1]
            self.patch_data_id = header[2]
            self.patch_data_len = header[3]
            # attempt to compute total size, will fail for newer encrypted microcode with patch_data_len = 0
            # if self.total_size == 0 and self.patch_data_len != 0:
            #     self.total_size = static.header(self.is_swap_endian).size + self.patch_data_len * microparse.static.data(self.is_swap_endian).size * static.TRIAD_SIZE
            self.init_flag = header[4]
            self.patch_data_checksum = header[5]
            self.nb_dev_id = header[6]
            self.sb_dev_id = header[7]
            self.processor_rev_id = header[8]
            if (self.equiv_cpuid):
                for s in self.equiv_cpuid[self.processor_rev_id]:
                    signature = microparse.signature(s)
                    if (signature.family == 0xe and self.total_size > static.F14_MAX_SIZE) \
                    or (signature.family == 0xf and self.total_size > static.F15_MAX_SIZE) \
                    or ((signature.family != 0xe and signature.family != 0xf) and self.total_size > static.F1X_MAX_SIZE):
                        raise Exception("Microcode exceeds maximum valid size")

            self.nb_rev_id = header[9]
            self.sb_rev_id = header[10]
            self.bios_api_rev = header[11]
            self.unknown1 = header[12]
            self.unknown2 = header[13]
            self.unknown3 = header[14]
            self.match_reg1 = header[15]
            self.match_reg2 = header[16]
            self.match_reg3 = header[17]
            self.match_reg4 = header[18]
            self.match_reg5 = header[19]
            self.match_reg6 = header[20]
            self.match_reg7 = header[21]
            self.match_reg8 = header[22]
        else:
            raise Exception("Input microcode header size mismatch!")
Example #6
0
    def __str__(self):
        fmt_string = ".... %-25s: %s\n"
        checksum = " (!)" if self.patch_data_checksum != self.calculate_checksum(
        ) else ""

        output = \
        microparse.static.fmt_string % ("Date", microparse.static.int2date(self.date)) + \
        microparse.static.fmt_string % ("Patch ID", microparse.static.hex8(self.patch_id)) + \
        microparse.static.fmt_string % ("Patch Data ID", microparse.static.hex8(self.patch_data_id)) + \
        microparse.static.fmt_string % ("Patch Data Length", microparse.static.hex8(self.patch_data_len)) + \
        microparse.static.fmt_string % ("Initialization Flag", microparse.static.hex8(self.init_flag)) + \
        microparse.static.fmt_string % ("Patch Data Checksum", microparse.static.hex8(self.patch_data_checksum) + checksum) + \
        microparse.static.fmt_string % ("Northbridge Device ID", microparse.static.hex8(self.nb_dev_id)) + \
        microparse.static.fmt_string % ("Southbridge Device ID", microparse.static.hex8(self.sb_dev_id)) + \
        microparse.static.fmt_string % ("Processor Revision ID", microparse.static.hex8(self.processor_rev_id))

        if (self.equiv_cpuid):
            for s in self.equiv_cpuid[self.processor_rev_id]:
                output += \
                microparse.signature.fmt_string % ("Processor Signature Entry", microparse.static.hex8(s)) + \
                str(microparse.signature(s))

        output += \
        microparse.static.fmt_string % ("Northbridge Revision ID", microparse.static.hex8(self.nb_rev_id)) + \
        microparse.static.fmt_string % ("Southbridge Revision ID", microparse.static.hex8(self.sb_rev_id)) + \
        microparse.static.fmt_string % ("BIOS API Revision", microparse.static.hex8(self.bios_api_rev)) + \
        microparse.static.fmt_string % ("Unknown 1", microparse.static.hex8(self.unknown1)) + \
        microparse.static.fmt_string % ("Unknown 2", microparse.static.hex8(self.unknown2)) + \
        microparse.static.fmt_string % ("Unknown 3", microparse.static.hex8(self.unknown3)) + \
        microparse.static.fmt_string % ("Match Register 1", microparse.static.hex8(self.match_reg1)) + \
        microparse.static.fmt_string % ("Match Register 2", microparse.static.hex8(self.match_reg2)) + \
        microparse.static.fmt_string % ("Match Register 3", microparse.static.hex8(self.match_reg3)) + \
        microparse.static.fmt_string % ("Match Register 4", microparse.static.hex8(self.match_reg4)) + \
        microparse.static.fmt_string % ("Match Register 5", microparse.static.hex8(self.match_reg5)) + \
        microparse.static.fmt_string % ("Match Register 6", microparse.static.hex8(self.match_reg6)) + \
        microparse.static.fmt_string % ("Match Register 7", microparse.static.hex8(self.match_reg7)) + \
        microparse.static.fmt_string % ("Match Register 8", microparse.static.hex8(self.match_reg8)) + "\n"

        return output
Example #7
0
    def __str__(self):
        fmt_string = ".... %-25s: %s\n"
        checksum = " (!)" if self.patch_data_checksum != self.calculate_checksum() else ""

        output = \
        microparse.static.fmt_string % ("Date", microparse.static.int2date(self.date)) + \
        microparse.static.fmt_string % ("Patch ID", microparse.static.hex8(self.patch_id)) + \
        microparse.static.fmt_string % ("Patch Data ID", microparse.static.hex8(self.patch_data_id)) + \
        microparse.static.fmt_string % ("Patch Data Length", microparse.static.hex8(self.patch_data_len)) + \
        microparse.static.fmt_string % ("Initialization Flag", microparse.static.hex8(self.init_flag)) + \
        microparse.static.fmt_string % ("Patch Data Checksum", microparse.static.hex8(self.patch_data_checksum) + checksum) + \
        microparse.static.fmt_string % ("Northbridge Device ID", microparse.static.hex8(self.nb_dev_id)) + \
        microparse.static.fmt_string % ("Southbridge Device ID", microparse.static.hex8(self.sb_dev_id)) + \
        microparse.static.fmt_string % ("Processor Revision ID", microparse.static.hex8(self.processor_rev_id))

        if (self.equiv_cpuid):
            for s in self.equiv_cpuid[self.processor_rev_id]:
                output += \
                microparse.signature.fmt_string % ("Processor Signature Entry", microparse.static.hex8(s)) + \
                str(microparse.signature(s))

        output += \
        microparse.static.fmt_string % ("Northbridge Revision ID", microparse.static.hex8(self.nb_rev_id)) + \
        microparse.static.fmt_string % ("Southbridge Revision ID", microparse.static.hex8(self.sb_rev_id)) + \
        microparse.static.fmt_string % ("BIOS API Revision", microparse.static.hex8(self.bios_api_rev)) + \
        microparse.static.fmt_string % ("Unknown 1", microparse.static.hex8(self.unknown1)) + \
        microparse.static.fmt_string % ("Unknown 2", microparse.static.hex8(self.unknown2)) + \
        microparse.static.fmt_string % ("Unknown 3", microparse.static.hex8(self.unknown3)) + \
        microparse.static.fmt_string % ("Match Register 1", microparse.static.hex8(self.match_reg1)) + \
        microparse.static.fmt_string % ("Match Register 2", microparse.static.hex8(self.match_reg2)) + \
        microparse.static.fmt_string % ("Match Register 3", microparse.static.hex8(self.match_reg3)) + \
        microparse.static.fmt_string % ("Match Register 4", microparse.static.hex8(self.match_reg4)) + \
        microparse.static.fmt_string % ("Match Register 5", microparse.static.hex8(self.match_reg5)) + \
        microparse.static.fmt_string % ("Match Register 6", microparse.static.hex8(self.match_reg6)) + \
        microparse.static.fmt_string % ("Match Register 7", microparse.static.hex8(self.match_reg7)) + \
        microparse.static.fmt_string % ("Match Register 8", microparse.static.hex8(self.match_reg8)) + "\n"

        return output