Skip to content

Commit

Permalink
expose cache API
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Kyle committed Feb 12, 2024
1 parent 5fe3775 commit 79da821
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions angrop/rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,20 @@ def find_gadgets_single_threaded(self, show_progress=True):
self._screen_gadgets()
return self.rop_gadgets

def _get_cache_tuple(self):
return (self._all_gadgets, self._duplicates)

def _load_cache_tuple(self, tup):
self._all_gadgets = tup[0]
self._duplicates = tup[1]

def save_gadgets(self, path):
"""
Saves gadgets in a file.
:param path: A path for a file where the gadgets are stored
"""
with open(path, "wb") as f:
pickle.dump((self._all_gadgets, self._duplicates), f)
pickle.dump(self._get_cache_tuple(), f)

def load_gadgets(self, path):
"""
Expand All @@ -132,8 +139,7 @@ def load_gadgets(self, path):
"""
with open(path, "rb") as f:
cache_tuple = pickle.load(f)
self._all_gadgets = cache_tuple[0]
self._duplicates = cache_tuple[1]
self._load_cache_tuple(cache_tuple)
self._screen_gadgets()

def set_badbytes(self, badbytes):
Expand Down

0 comments on commit 79da821

Please sign in to comment.