Skip to content

Commit

Permalink
split read of segments into 0x100 byte chunks to speed it up
Browse files Browse the repository at this point in the history
  • Loading branch information
chanijindal1 committed May 20, 2024
1 parent 641b472 commit c35aa2c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion angrop/gadget_finder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,13 @@ def _get_locations_by_strings(self, strings):
addrs = []
state = self.project.factory.entry_state()
for segment in self._get_executable_ranges():
read_bytes = state.solver.eval(state.memory.load(segment.min_addr, segment.memsize), cast_to=bytes)
# angr is slow to read huge chunks
read_bytes = []
for i in range(segment.min_addr, segment.min_addr+segment.memsize,
0x100):
read_size = min(0x100, segment.min_addr+segment.memsize-i)
read_bytes.append(state.solver.eval(state.memory.load(i, read_size), cast_to=bytes))
read_bytes = b"".join(read_bytes)
# find all occurrences of the ret_instructions
addrs += [segment.min_addr + m.start() for m in re.finditer(fmt, read_bytes)]
return sorted(addrs)
Expand Down

0 comments on commit c35aa2c

Please sign in to comment.