def _get_sizes(self, analyser): """ get maximum field sizes """ sizes = {"Address": 0, "Name": 0, "Service": 0, "Place": 0, "GUID": 0} for prot in analyser.Protocols["All"] + analyser.Protocols["Data"]: if len("{addr:#010x}".format( addr=prot["address"])) > sizes["Address"]: sizes["Address"] = len( "{addr:#010x}".format(addr=prot["address"])) if len(prot["protocol_name"]) > sizes["Name"]: sizes["Name"] = len(prot["protocol_name"]) if len(prot["service"]) > sizes["Service"]: sizes["Service"] = len(prot["service"]) if len(prot["protocol_place"]) > sizes["Place"]: sizes["Place"] = len(prot["protocol_place"]) if len(utils.get_guid_str(prot["guid"])) > sizes["GUID"]: sizes["GUID"] = len(utils.get_guid_str(prot["guid"])) return sizes
def _get_lines(self, analyser): """ to fill line in the table """ lines = [] for prot in analyser.Protocols["All"] + analyser.Protocols["Data"]: item = [ "{addr:#010x}".format(addr=prot["address"]), prot["protocol_name"], prot["service"], prot["protocol_place"], utils.get_guid_str(prot["guid"]) ] if not lines.count(item): lines.append(item) return lines
def log_all(): idc.auto_wait() analyser = Analyser() if not analyser.valid: idc.qexit(0) 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 (len(data) == 0): print_log("* empty") for element in data: guid_str = "[guid] " + utils.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(0)
def list_protocols(self): """ display protocols information to the IDAPython output window """ self.get_boot_services() self.get_protocols() self.get_prot_names() data = self.Protocols["All"] + self.Protocols["Data"] print("Protocols:") if len(data) == 0: print(" * list is empty") else: table_data = [] table_data.append([ "GUID", "Protocol name", "Address", "Service", "Protocol place" ]) for element in data: guid = utils.get_guid_str(element["guid"]) table_data.append([ guid, element["protocol_name"], "{addr:#010x}".format(addr=element["address"]), element["service"], element["protocol_place"] ]) print(Table.display(table_data))