entry_point=0, **kwargs) self.os = "bf" self.engine_preset = bf_engine_preset @staticmethod def is_compatible(stream): bf_re = re.compile(b'[+\-<>.,\[\]\n]+') stream.seek(0) stuff = stream.read(0x1000) if bf_re.match(stuff): return True return False """ def _load(self, offset, size=None): """""" Load a segment into memory. """""" self.binary_stream.seek(offset) if size is None: string = self.binary_stream.read() else: string = self.binary_stream.read(size) self.memory.add_backer(0, string) self._max_addr = len(string) """ register_backend("bf", BF)
"AutoBlob could not figure out what your binary is. Consider using Blob manually." ) return False l.info("AutoBlob results:") l.info("Architecture: %s" % repr(arch)) l.info("Base address: %s" % (hex(base) if isinstance(base, int) else repr(base))) l.info("Entry point: %s" % (hex(entry) if isinstance(entry, int) else repr(entry))) return True def autodetect_secondary(self): """ Dig up as much info about the just-loaded binary as possible. If we didn't find the IVT before, can we find it now? If we didn't pin down the exact arch revision, can we do that? Also, some fingerprinting on the entry function itself may yield more info. :return: """ pass if __name__ == '__main__': logging.basicConfig() l.setLevel(logging.DEBUG) with open(sys.argv[1], 'rb') as stream: AutoBlob.is_compatible(stream) else: register_backend("autoblob", AutoBlob)
hdr_global_checksum = struct.unpack('>H', gb_header[0x4E:0x50])[0] calculated_global_checksum = (sum(gb_rom_data[:0x14E]) + sum(gb_rom_data[0x150:])) & 0xFFFF if calculated_global_checksum != hdr_global_checksum: log.warn('Global checksum does not match: %04x != %04x', calculated_global_checksum, hdr_global_checksum) #if not self.ignore_checksum: return False log.debug('Gameboy header valid') return True """ # TODO: Needed? def _load(self, offset, size=None): """ """ Load a segment into memory. """ """ self.binary_stream.seek(offset) if size is None: string = self.binary_stream.read() else: string = self.binary_stream.read(size) self.memory.add_backer(0, string) self._max_addr = len(string) """ register_backend("gameboy", GameboyROM)
class BPF(Blob): is_default = False def __init__(self, path, offset=0, *args, **kwargs): """ Loader backend for BF programs :param path: The file path :param offset: Skip this many bytes from the beginning of the file. """ super(BPF, self).__init__(path, *args, arch=arch_from_id("bpf"), offset=offset, entry_point=0, **kwargs) self.os = "bpf" @staticmethod def is_compatible(stream): """ A BPF file is simply a binary blob. So it is compatible with anything. :param stream: :return: """ return True register_backend("bpf", BPF)
__all__ = ['Image'] from cle.backends import register_backend from .backend import Kernel from .image import Image register_backend('kernel', Kernel)