def __init__(self, cs): super(SMBIOS, self).__init__(cs) self.uefi = uefi.UEFI(cs) self.smbios_2_guid_found = False self.smbios_2_pa = None self.smbios_2_ep = None self.smbios_2_data = None self.smbios_3_guid_found = False self.smbios_3_pa = None self.smbios_3_ep = None self.smbios_3_data = None
def run(self): if len(self.argv) < 3: print DecodeCommand.__doc__ return _uefi = uefi.UEFI( self.cs ) if self.argv[2] == "types": print "\n<fw_type> should be in [ %s ]\n" % ( " | ".join( ["%s" % t for t in uefi.uefi_platform.fw_types] ) ) return rom_file = self.argv[2] fwtype = self.argv[3] if len(self.argv) == 4 else None self.logger.log( "[CHIPSEC] Decoding SPI ROM image from a file '%s'" % rom_file ) t = time.time() f = read_file( rom_file ) (fd_off, fd) = spi_descriptor.get_spi_flash_descriptor( f ) if (-1 == fd_off) or (fd is None): self.logger.error( "Could not find SPI Flash descriptor in the binary '%s'" % rom_file ) return False self.logger.log( "[CHIPSEC] Found SPI Flash descriptor at offset 0x%x in the binary '%s'" % (fd_off, rom_file) ) rom = f[fd_off:] # Decoding Flash Descriptor #self.logger.LOG_COMPLETE_FILE_NAME = os.path.join( pth, 'flash_descriptor.log' ) #parse_spi_flash_descriptor( self.cs, fd ) # Decoding SPI Flash Regions # flregs[r] = (r,SPI_REGION_NAMES[r],flreg,base,limit,notused) flregs = spi_descriptor.get_spi_regions( fd ) if flregs is None: self.logger.error( "SPI Flash descriptor region is not valid" ) return False _orig_logname = self.logger.LOG_FILE_NAME pth = os.path.join( self.cs.helper.getcwd(), rom_file + ".dir" ) if not os.path.exists( pth ): os.makedirs( pth ) for r in flregs: idx = r[0] name = r[1] base = r[3] limit = r[4] notused = r[5] if not notused: region_data = rom[base:limit+1] fname = os.path.join( pth, '%d_%04X-%04X_%s.bin' % (idx, base, limit, name) ) write_file( fname, region_data ) if spi.FLASH_DESCRIPTOR == idx: # Decoding Flash Descriptor self.logger.set_log_file( os.path.join( pth, fname + '.log' ) ) spi_descriptor.parse_spi_flash_descriptor( self.cs, region_data ) elif spi.BIOS == idx: # Decoding EFI Firmware Volumes self.logger.set_log_file( os.path.join( pth, fname + '.log' ) ) spi_uefi.decode_uefi_region(_uefi, pth, fname, fwtype) self.logger.set_log_file( _orig_logname ) self.logger.log( "[CHIPSEC] (decode) time elapsed %.3f" % (time.time()-t) )
import os import sys import time import chipsec_util from chipsec.logger import * import chipsec.file import chipsec.hal.spi as spi import chipsec.hal.spi_descriptor as spi_descriptor import chipsec.hal.spi_uefi as spi_uefi import chipsec.hal.uefi as uefi _uefi = uefi.UEFI(chipsec_util._cs.helper) usage = "chipsec_util decode <rom> [fw_type]\n" + \ " <fw_type> should be in [ %s ]\n" % (" | ".join( ["%s" % t for t in uefi.fw_types])) + \ "Examples:\n" + \ " chipsec_util decode spi.bin vss\n\n" def decode(argv): if 3 > len(argv): print usage return rom_file = argv[2]
def __init__(self, cs): super(ACPI, self).__init__(cs) self.uefi = uefi.UEFI(self.cs) self.tableList = defaultdict(list) self.get_ACPI_table_list()
import os import sys import time import chipsec_util from chipsec.logger import * import chipsec.file import chipsec.hal.spi as spi import chipsec.hal.spi_descriptor as spi_descriptor import chipsec.hal.spi_uefi as spi_uefi import chipsec.hal.uefi as uefi _uefi = uefi.UEFI(chipsec_util._cs) def decode(argv): """ >>> chipsec_util decode <rom> [fw_type] For a list of fw types run: >>> chipsec_util decode types Examples: >>> chipsec_util decode spi.bin vss """