Skip to content

Commit

Permalink
Fix patching when no default Platform is present
Browse files Browse the repository at this point in the history
  • Loading branch information
plafosse committed Nov 19, 2024
1 parent 9783cd2 commit 4458f63
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Opaque Predicate Patcher (v1.1.5)
# Opaque Predicate Patcher (v1.1.6)
Author: **Vector 35 Inc**

_Automatically patch opaque predicates_
Expand Down
14 changes: 7 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def patch_opaque_inner(bv, status=None):
condition_value = i.condition.possible_values
# If the condition never changes then its safe to patch the branch
if condition_value.type == RegisterValueType.ConstantValue:
if condition_value.value == 0 and bv.is_never_branch_patch_available(i.address):
patch_locations.append((i.address, True))
elif bv.is_always_branch_patch_available(i.address):
patch_locations.append((i.address, False))
if condition_value.value == 0 and bv.is_never_branch_patch_available(i.address, i.il_basic_block.arch):
patch_locations.append((i.address, True, i.il_basic_block.arch))
elif bv.is_always_branch_patch_available(i.address, i.il_basic_block.arch):
patch_locations.append((i.address, False, i.il_basic_block.arch))

return patch_locations

Expand All @@ -55,13 +55,13 @@ def patch_opaque(bv, status=None):
patch_locations = patch_opaque_inner(bv, status)
if len(patch_locations) == 0 or analysis_pass == 10 or (status is not None and status.cancelled):
break
for address, always in patch_locations:
for address, always, arch in patch_locations:
if always:
log_info("Patching instruction {} to never branch.".format(hex(address)))
bv.never_branch(address)
bv.never_branch(address, arch)
else:
log_info("Patching instruction {} to always branch.".format(hex(address)))
bv.always_branch(address)
bv.always_branch(address, arch)
bv.update_analysis_and_wait()


Expand Down
3 changes: 1 addition & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"helper"
],
"api": [
"python2",
"python3"
],
"description": "Automatically patch opaque predicates",
Expand All @@ -25,7 +24,7 @@
"Darwin": ""
},
"dependencies": {},
"version": "1.1.5",
"version": "1.1.6",
"author": "Vector 35 Inc",
"minimumbinaryninjaversion": 0
}

0 comments on commit 4458f63

Please sign in to comment.