Last active
October 30, 2020 09:15
-
-
Save yrp604/731df6938994ce5b11758085ce8bd290 to your computer and use it in GitHub Desktop.
binja unimplemented instructions snip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#unlifted instructions | |
# | |
from collections import defaultdict | |
from binaryninja.enums import LowLevelILOperation | |
unlifted = defaultdict(list) | |
print('unlifted instructions in bndb') | |
for ll in bv.llil_instructions: | |
# TODO I need to update this to actually walk all of the LLIL operations in the tree | |
if ll.operation == LowLevelILOperation.LLIL_SET_FLAG: | |
ins = ll.src | |
else: | |
ins = ll | |
if ins.operation != LowLevelILOperation.LLIL_UNIMPL: | |
continue | |
addr = ins.address | |
dis = bv.get_disassembly(addr) | |
if dis is None: | |
print('unable to disassemble @ %#x' % addr) | |
continue | |
mnem = dis.split(' ')[0] | |
unlifted[mnem].append(addr) | |
total = 0 | |
distinct = 0 | |
for mnem in sorted(unlifted, key=lambda x: len(unlifted[x]), reverse=True): | |
pos = ', '.join(['%#x' % x for x in unlifted[mnem][:8]]) | |
count = len(unlifted[mnem]) | |
if count > 8: pos += ', ...' | |
print('%8d%16s [%s]' % (count, mnem, pos)) | |
total += count | |
distinct += 1 | |
print('%d unlifted from %d unique instructions' % (total, distinct)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment