Skip to content

Instantly share code, notes, and snippets.

@cetfor
Created February 8, 2020 20:15
Show Gist options
  • Save cetfor/f7b21a92e5be960019aa85cdb65ca22e to your computer and use it in GitHub Desktop.
Save cetfor/f7b21a92e5be960019aa85cdb65ca22e to your computer and use it in GitHub Desktop.
# Get MLIL SSA form
import binaryninja
target = "cwe369A_x64"
target_operations = [
binaryninja.MediumLevelILOperation.MLIL_DIVS,
binaryninja.MediumLevelILOperation.MLIL_DIVS_DP,
binaryninja.MediumLevelILOperation.MLIL_DIVU,
binaryninja.MediumLevelILOperation.MLIL_DIVU_DP,
binaryninja.MediumLevelILOperation.MLIL_FDIV,
]
print("Analyzing file: {}".format(target))
bv = binaryninja.BinaryViewType.get_view_of_file(target)
bv.add_analysis_option('linearsweep')
for func in bv.functions:
if func.name != "main": continue
print("Function: {}".format(func.name))
for block in func.medium_level_il.ssa_form:
for instr in block:
for operand in instr.postfix_operands:
if operand in target_operations:
print("Div: {}".format(instr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment