Skip to content

Using Binary Ninja's API for creating dynamic analysed binary dataset #1995

Discussion options

You must be logged in to vote

Yes, BN is perfect for that. Here's a quick sample of using the API via a headless script to demonstrate the basics:

#!/usr/bin/env python3
import binaryninja
import glob
import argparse

parser = argparse.ArgumentParser(description='Dump CFG and AST for function start')
parser.add_argument("files", metavar="path", type=str,
    help="Path to files to be analyzed, can use wildcards")
args = parser.parse_args()
files = glob.iglob(args.files)

for file in files:
    try:    
        with binaryninja.open_view(file, 'r') as bv:
            print(f'AST for {file} and the entry_function:') 
            ast = '\n'.join(map(str, bv.entry_function.hlil.root.lines))
            print(f'{ast}')
   …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@BluePython339
Comment options

@psifertex
Comment options

Answer selected by psifertex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants