# batch example # # Intended to be run from the CLI, not as a snippet # Remove these top lines to run headlessly (requires a commercial license) #!/usr/bin/env python3 import binaryninja import glob import filetype import os from tabulate import tabulate from collections import defaultdict binaryninja.disable_default_log() for file in glob.glob("./**/*", recursive=True): if os.path.isfile(file): guess = filetype.guess(file) if guess and guess.extension == "elf": print(f"Filename: {file}") try: with binaryninja.load(file, update_analysis=False) as bv: # Imports don't require analysis, otherwise remove update_analysis param syms = [] for sym in bv.get_symbols_of_type(binaryninja.SymbolType.ImportAddressSymbol): syms.append([sym.name, hex(sym.address)]) print(tabulate(syms, headers=["Import Name", "Offset"])) except: print("Invalid architecture.") print("\n")