def run(self, module_argv): self.logger.start_test( "Check for black-listed EFI binaries in UEFI firmware") self.usage() image_file = DEF_FWIMAGE_FILE if len(module_argv) == 0: # Read firmware image directly from SPI flash memory self.spi = SPI(self.cs) (base, limit, freg) = self.spi.get_SPI_region(BIOS) image_size = limit + 1 - base self.logger.log( "[*] dumping FW image from ROM to {}: 0x{:08X} bytes at [0x{:08X}:0x{:08X}]" .format(image_file, base, limit, image_size)) self.logger.log( "[*] this may take a few minutes (instead, use 'chipsec_util spi dump')..." ) self.spi.read_spi_to_file(base, image_size, image_file) elif len(module_argv) > 0: # Use provided firmware image image_file = module_argv[0] self.logger.log( "[*] reading FW image from file: {}".format(image_file)) self.image = read_file(image_file) # Load JSON config with black-listed EFI modules if len(module_argv) > 1: self.cfg_name = module_argv[1] cfg_pth = os.path.join(get_main_dir(), "chipsec/modules/tools/uefi", self.cfg_name) with open(cfg_pth, 'r') as blacklist_json: self.efi_blacklist = json.load(blacklist_json) return self.check_blacklist()
def run(self, module_argv): self.logger.start_test( "Check for suspicious EFI binaries in UEFI firmware") self.usage() if len(module_argv) > 0: self.vt = VirusTotalPublicApi(module_argv[0]) if len(module_argv) > 1: self.vt_threshold = int(module_argv[1]) image_file = DEF_FWIMAGE_FILE if len(module_argv) > 2: # Use provided firmware image image_file = module_argv[2] self.logger.log( "[*] reading FW image from file: {}".format(image_file)) else: # Read firmware image directly from SPI flash memory self.spi = SPI(self.cs) (base, limit, freg) = self.spi.get_SPI_region(BIOS) image_size = limit + 1 - base self.logger.log( "[*] dumping FW image from ROM to {}: 0x{:08X} bytes at [0x{:08X}:0x{:08X}]" .format(image_file, base, limit, image_size)) self.logger.log( "[*] this may take a few minutes (instead, use 'chipsec_util spi dump')..." ) self.spi.read_spi_to_file(base, image_size, image_file) self.image = read_file(image_file) return self.check_reputation()
def run(self, module_argv): self.logger.start_test( "simple list generation/checking for (U)EFI firmware") self.res = ModuleResult.SKIPPED op = module_argv[0] if len(module_argv) > 0 else 'generate' if op in ['generate', 'check']: if len(module_argv) <= 2: self.usage() return self.res elif len(module_argv) > 2: json_file = module_argv[1] image_file = module_argv[2] self.logger.log( "[*] reading firmware from '{}'...".format(image_file)) else: image_file = DEF_FWIMAGE_FILE json_file = DEF_EFILIST_FILE self.spi = SPI(self.cs) (base, limit, freg) = self.spi.get_SPI_region(BIOS) image_size = limit + 1 - base self.logger.log( "[*] dumping firmware image from ROM to '{}': 0x{:08X} bytes at [0x{:08X}:0x{:08X}]" .format(image_file, image_size, base, limit)) self.spi.read_spi_to_file(base, image_size, image_file) self.image_file = image_file self.image = read_file(image_file) json_pth = os.path.abspath(json_file) if op == 'generate': if os.path.exists(json_pth): self.logger.error( "JSON file '{}' already exists. Exiting...".format( json_file)) self.res = ModuleResult.ERROR else: self.res = self.generate_efilist(json_pth) elif op == 'check': if not os.path.exists(json_pth): self.logger.error( "JSON file '{}' doesn't exists. Exiting...".format( json_file)) self.res = ModuleResult.ERROR else: self.res = self.check_list(json_pth) elif op == 'help': self.usage() else: self.logger.error( "unrecognized command-line argument to the module") self.usage() return self.res
def run(self): try: self._spi = SPI(self.cs) except SpiRuntimeError as msg: self.logger.error(msg) return self._msg = "it may take a few minutes (use DEBUG or VERBOSE logger options to see progress)" t = time.time() self.func() self.logger.log( "[CHIPSEC] (spi) time elapsed {:.3f}".format(time.time() - t))
def run(self, module_argv): self.logger.start_test( "Check for blocked EFI binaries in UEFI firmware") self.usage() image_file = DEF_FWIMAGE_FILE if len(module_argv) == 0: # Read firmware image directly from SPI flash memory self.spi = SPI(self.cs) (base, limit, freg) = self.spi.get_SPI_region(BIOS) image_size = limit + 1 - base self.logger.log( "[*] Dumping FW image from ROM to {}: 0x{:08X} bytes at [0x{:08X}:0x{:08X}]" .format(image_file, base, limit, image_size)) self.logger.log( "[*] This may take a few minutes (instead, use 'chipsec_util spi dump')..." ) self.spi.read_spi_to_file(base, image_size, image_file) elif len(module_argv) > 0: # Use provided firmware image image_file = module_argv[0] self.logger.log( "[*] Reading FW image from file: {}".format(image_file)) self.image = read_file(image_file) if not self.image: if len(module_argv) == 0: self.logger.log_important( 'Unable to read SPI and generate FW image. Access may be blocked.' ) self.logger.error('No FW image file to read. Exiting!') self.res = ModuleResult.ERROR return self.res # Load JSON config with blocked EFI modules if len(module_argv) > 1: self.cfg_name = module_argv[1] cfg_pth = os.path.join(get_main_dir(), "chipsec/modules/tools/uefi", self.cfg_name) with open(cfg_pth, 'r') as blockedlist_json: self.efi_blockedlist = json.load(blockedlist_json) self.res = self.check_blockedlist() return self.res
def __init__(self): BaseModule.__init__(self) self.spi = SPI( self.cs )