Using Binary Ninja's API for creating dynamic analysed binary dataset #1995
-
Hey guys, i'm doing research (thesis) into dynamically analysing binaries to detect vulnerabilites using a neural net. However i've been having trouble finding a decompiler and analyser that i can script so that i can create the dataset / make a proof of concept. Thanks in advance !!! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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}')
print('Number of Assembly Basic Blocks: :')
print(f'{len(bv.entry_function.basic_blocks)}')
print('Number of HLIL Basic Blocks: :')
print(f'{len(bv.entry_function.hlil.basic_blocks)}')
except IOError:
print(f'{file} does not appear to be a valid file for analysis') Note that you can use a modified form of that script in the Personal license as well, just have to run it inside the UI. The good news is if you're a full-time student, our student discount applies to commercial licenses as well. Here's the sample output from
|
Beta Was this translation helpful? Give feedback.
Yes, BN is perfect for that. Here's a quick sample of using the API via a headless script to demonstrate the basics: