def ief_find_export(binview, func): """ run `ief <path> -e <symbol>` """ directory = get_directory_name_input( "Directory to search", dirname(binview.file.filename)) # Assumes `~/.cargo/bin` already exists in PATH result = run(["ief", directory.decode('utf-8'), "-e", func.name], capture_output=True) directory = directory.decode('utf-8') markdown = f"# Results - binaries in '[{directory}]({directory})'" \ f" with exported symbol '_{func.name}_'`\n\n" for line in result.stdout.split(b"\n")[1: -1]: npath = normpath(line.decode('utf-8')) markdown += f"* [{npath}]({npath})\n" show_markdown_report(f"I[E]F - {func.name}", markdown, result.stdout.decode('utf-8'))
def ief_find_library(binview): """ run `ief <path> -l <partial library name>` """ name = TextLineField("Library name (can be partial)") directory = DirectoryNameField( "Directory to search", dirname(binview.file.filename)) get_form_input([name, None, directory], "Find binaries that import library") if not directory.result: directory.result = dirname(binview.file.filename) if name.result is None: return # Assumes `~/.cargo/bin` already exists in PATH result = run(["ief", directory.result, "-l", name.result], capture_output=True) directory = directory.result markdown = f"# Results - binaries in '[{directory}]({directory})'" \ f"with imported library name containing '_{name.result}_'\n\n" for line in result.stdout.split(b"\n")[1:-1]: npath = normpath(line.decode('utf-8')) markdown += f"* [{npath}]({npath})\n" show_markdown_report(f"IEF - {name.result}", markdown, result.stdout.decode('utf-8'))
def display_bininfo(bv): interaction.show_markdown_report("Binary Info Report", get_bininfo(bv))