def retrieveMemoryConfFromElf(elffile): memConf = None with open(elffile, 'rb') as f: sect = ELFFile(f).get_section_by_name(".memory_configuration") memConf = json.loads(sect.data()) return memConf
#!/bin/python import json from elftools.elf.elffile import ELFFile with open("data/SLUS_206.24", 'rb') as f: rodata = ELFFile(f).get_section_by_name(".rodata") rodata_address = rodata.header["sh_addr"] rodata_data = rodata.data() map_lines = json.load(open("srr2.lines.json")) map_lines_by_address = dict() for line in map_lines: map_lines_by_address[hex(line["address"])] = line vftables = dict() for line in map_lines: if line["type"] == "symbol": if "virtual table" in line["value"]["demangled"]: address = line["address"] size = line["size"] length = int(size / 4) class_name = line["value"]["demangled"].replace( " virtual table", "") vftables[class_name] = { "ea": address, "length": length, "vftptr": None, # Virtual Function Type PoinTeR ? Virtual Function Table PoinTeR