Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid a couple unnecessary eval_upto which are slow #112

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions angrop/gadget_finder/gadget_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,7 @@ def _analyze_concrete_regs(self, init_state, final_state, gadget):
val = state.registers.load(reg)
if val.symbolic:
continue
concrete_vals = state.solver.eval_upto(val, 2)
if len(concrete_vals) != 1:
continue
gadget.concrete_regs[reg] = concrete_vals[0]
gadget.concrete_regs[reg] = state.solver.eval(val)

def _check_reg_changes(self, final_state, init_state, gadget):
"""
Expand Down Expand Up @@ -637,15 +634,12 @@ def _build_mem_access(self, a, gadget, init_state, final_state):

if a.action == "write":
# for writes we want what the data depends on
test_data = init_state.solver.eval_upto(a.data.ast, 2)
if len(test_data) > 1:
if a.data.ast.symbolic:
mem_access.data_dependencies = rop_utils.get_ast_dependency(a.data.ast)
mem_access.data_controllers = rop_utils.get_ast_controllers(init_state, a.data.ast,
mem_access.data_dependencies)
elif len(test_data) == 1:
mem_access.data_constant = test_data[0]
else:
raise RopException("No data values, something went wrong")
mem_access.data_constant = init_state.solver.eval(a.data.ast)
elif a.action == "read":
# for reads we want to know if any register will have the data after
succ_state = final_state
Expand Down