Skip to content

Commit

Permalink
Merge pull request #94 from angr/fix/reg
Browse files Browse the repository at this point in the history
use translate_register_name to translate offset to register names
  • Loading branch information
Kyle-Kyle authored Apr 6, 2024
2 parents 8009e66 + 0f26ec4 commit 2fd903e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion angrop/chain_builder/reg_mover.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def verify(self, chain, preserve_regs, registers):
return False
if act.type == 'reg' and act.action == 'write':
# get the full name of the register
reg_name = self.project.arch.register_size_names[act.offset, self.project.arch.bytes]
offset = act.offset
offset -= act.offset % self.project.arch.bytes
reg_name = self.project.arch.translate_register_name(offset)
if reg_name in preserve_regs:
l.exception("Somehow angrop thinks \n%s\n can be used for the chain generation.", chain_str)
return False
Expand Down
2 changes: 1 addition & 1 deletion angrop/chain_builder/reg_setter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def verify(self, chain, preserve_regs, registers):
# get the full name of the register
offset = act.offset
offset -= act.offset % self.project.arch.bytes
reg_name = self.project.arch.register_size_names[offset, self.project.arch.bytes]
reg_name = self.project.arch.translate_register_name(offset)
if reg_name in preserve_regs:
l.exception("Somehow angrop thinks \n%s\n can be used for the chain generation - 1.", chain_str)
return False
Expand Down
8 changes: 6 additions & 2 deletions angrop/chain_builder/shifter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def verify_shift(self, chain, length, preserve_regs):
for act in state.history.actions:
if act.type != 'reg' or act.action != 'write':
continue
reg_name = self.project.arch.register_size_names[act.offset, self.project.arch.bytes]
offset = act.offset
offset -= act.offset % self.project.arch.bytes
reg_name = self.project.arch.translate_register_name(offset)
if reg_name in preserve_regs:
chain_str = '\n-----\n'.join([str(self.project.factory.block(g.addr).capstone)for g in chain._gadgets])
l.exception("Somehow angrop thinks \n%s\n can be used for the chain generation.", chain_str)
Expand All @@ -43,7 +45,9 @@ def verify_retsled(self, chain, size, preserve_regs):
for act in state.history.actions:
if act.type != 'reg' or act.action != 'write':
continue
reg_name = self.project.arch.register_size_names[act.offset, self.project.arch.bytes]
offset = act.offset
offset -= act.offset % self.project.arch.bytes
reg_name = self.project.arch.translate_register_name(offset)
if reg_name == self.arch.stack_pointer:
continue
if reg_name in preserve_regs:
Expand Down

0 comments on commit 2fd903e

Please sign in to comment.