def log_pp_guids(): idc.auto_wait() analyser = Analyser() if not analyser.valid: idc.qexit(-1) analyser.get_boot_services() analyser.get_protocols() analyser.get_prot_names() data = dict() data["module_name"] = idaapi.get_root_filename() data["protocols"] = list() for protocol_record in analyser.Protocols["all"]: if protocol_record["protocol_name"] == "ProprietaryProtocol": guid = get_guid_str(protocol_record["guid"]) service = protocol_record["service"] addr = protocol_record["address"] address = f"{addr:#x}" data["protocols"].append({ "guid": guid, "service": service, "address": address }) logs_dir = os.path.join(tempfile.gettempdir(), "uefi-retool-pp-guids") if not os.path.isdir(logs_dir): os.mkdir(logs_dir) log_fname = f"{binascii.hexlify(ida_nalt.retrieve_input_file_md5()).decode()}.json" log_fpath = os.path.join(logs_dir, log_fname) with open(log_fpath, "w") as f: json.dump(data, f, indent=2) idc.qexit(0)
def log_pp_guids(): idc.auto_wait() analyser = Analyser() if not analyser.valid: idc.qexit(-1) analyser.get_boot_services() analyser.get_protocols() analyser.get_prot_names() data = {} data['module_name'] = idaapi.get_root_filename() data['protocols'] = [] for protocol_record in analyser.Protocols['all']: if (protocol_record['protocol_name'] == 'ProprietaryProtocol'): guid = get_guid_str(protocol_record['guid']) service = protocol_record['service'] address = '{addr:#x}'.format(addr=protocol_record['address']) data['protocols'].append({ 'guid': guid, 'service': service, 'address': address }) logs_dir = os.path.join(tempfile.gettempdir(), 'uefi-retool-pp-guids') if not os.path.isdir(logs_dir): os.mkdir(logs_dir) log_fname = os.path.join( logs_dir, '{}.json'.format( binascii.hexlify(ida_nalt.retrieve_input_file_md5()).decode())) with open(log_fname, 'w') as f: json.dump(data, f, indent=4) idc.qexit(0)
def get_protocols(analyser): protocols = [] analyser.get_protocols() analyser.get_prot_names() data = analyser.Protocols['all'] for element in data: guid = get_guid_str(element['guid']) address = '{:#x}'.format(element['address']) protocols.append({ 'address': address, 'service': element['service'], 'protocol_name': element['protocol_name'], 'protocol_place': element['protocol_place'], 'guid': guid }) return protocols
def get_protocols(analyser): protocols = list() analyser.get_protocols() analyser.get_prot_names() data = analyser.Protocols["all"] for element in data: guid = get_guid_str(element["guid"]) addr = element["address"] address = f"{addr:#x}" protocols.append({ "address": address, "service": element["service"], "protocol_name": element["protocol_name"], "protocol_place": element["protocol_place"], "guid": guid, }) return protocols
def log_pp_guids(): if not os.path.isfile(LOG_FILE) or not os.path.getsize(LOG_FILE): print_log(get_table_line('Guid', 'Module', 'Service', 'Address')) print_log(get_table_line('---', '---', '---', '---')) idc.auto_wait() analyser = Analyser() if not analyser.valid: idc.qexit(-1) analyser.get_boot_services() analyser.get_protocols() analyser.get_prot_names() for protocol_record in analyser.Protocols['all']: if (protocol_record['protocol_name'] == 'ProprietaryProtocol'): guid = get_guid_str(protocol_record['guid']) module = idaapi.get_root_filename() service = protocol_record['service'] address = '{addr:#x}'.format(addr=protocol_record['address']) print_log(get_table_line(guid, module, service, address)) idc.qexit(1)
def log_all(): idc.auto_wait() analyser = Analyser() if not analyser.valid: idc.qexit(-1) analyser.get_boot_services() print_log('## Module: ' + idaapi.get_root_filename()) print_log('### Boot services:') list_boot_services(analyser) analyser.get_protocols() analyser.get_prot_names() data = analyser.Protocols['all'] print_log('### Protocols:') if not len(data): print_log('* empty') for element in data: guid_str = '[guid] ' + get_guid_str(element['guid']) print_log('* [{0}]'.format( '{addr:#x}'.format(addr=element['address']))) print_log('\t - [service] ' + element['service']) print_log('\t - [protocol_name] ' + element['protocol_name']) print_log('\t - [protocol_place] ' + element['protocol_place']) print_log('\t - ' + guid_str) idc.qexit(1)