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

Allow setting max stacksize #97

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion angrop/chain_builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def func_call(self, address, args, **kwargs):
:param args: a list/tuple of arguments to the function
:param preserve_regs: set of registers to preserve, e.g. ('eax', 'ebx')
:param needs_return: whether to continue the ROP after invoking the function
:return: a RopChain which inovkes the function with the arguments
:return: a RopChain which invokes the function with the arguments
"""
return self._func_caller.func_call(address, args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion angrop/chain_builder/func_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def func_call(self, address, args, **kwargs):
:param args: a list/tuple of arguments to the function
:param preserve_regs: list of registers which shouldn't be set
:param needs_return: whether to continue the ROP after invoking the function
:return: a RopChain which inovkes the function with the arguments
:return: a RopChain which invokes the function with the arguments
"""
# is it a symbol?
if isinstance(address, str):
Expand Down
5 changes: 3 additions & 2 deletions angrop/gadget_finder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ class GadgetFinder:
a class to find ROP gadgets
"""
def __init__(self, project, fast_mode=None, only_check_near_rets=True, max_block_size=None,
max_sym_mem_access=None, is_thumb=False, kernel_mode=False):
max_sym_mem_access=None, is_thumb=False, kernel_mode=False, stack_gsize=80):
# configurations
self.project = project
self.fast_mode = fast_mode
self.arch = get_arch(self.project, kernel_mode=kernel_mode)
self.only_check_near_rets = only_check_near_rets
self.kernel_mode = kernel_mode
self.stack_gsize = stack_gsize

if only_check_near_rets and not isinstance(self.arch, (X86, AMD64)):
l.warning("only_check_near_rets only makes sense for i386/amd64, setting it to False")
Expand Down Expand Up @@ -110,7 +111,7 @@ def _initialize_gadget_analyzer(self):
num_to_check, self.arch.max_block_size)

self._gadget_analyzer = gadget_analyzer.GadgetAnalyzer(self.project, self.fast_mode, arch=self.arch,
kernel_mode=self.kernel_mode)
kernel_mode=self.kernel_mode, stack_gsize=self.stack_gsize)

def analyze_gadget(self, addr):
return self.gadget_analyzer.analyze_gadget(addr)
Expand Down
6 changes: 4 additions & 2 deletions angrop/rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ROP(Analysis):
"""

def __init__(self, only_check_near_rets=True, max_block_size=None, max_sym_mem_access=None,
fast_mode=None, rebase=None, is_thumb=False, kernel_mode=False):
fast_mode=None, rebase=None, is_thumb=False, kernel_mode=False, stack_gsize=80):
"""
Initializes the rop gadget finder
:param only_check_near_rets: If true we skip blocks that are not near rets
Expand All @@ -33,6 +33,8 @@ def __init__(self, only_check_near_rets=True, max_block_size=None, max_sym_mem_a
if set to None makes a decision based on the size of the binary
:param is_thumb: execute ROP chain in thumb mode. Only makes difference on ARM architecture.
angrop does not switch mode within a rop chain
:param kernel_mode: find kernel mode gadgets
:param stack_gsize: change the maximum allowable stack change for gadgets
:return:
"""

Expand All @@ -52,7 +54,7 @@ def __init__(self, only_check_near_rets=True, max_block_size=None, max_sym_mem_a
# gadget finder configurations
self.gadget_finder = GadgetFinder(self.project, fast_mode=fast_mode, only_check_near_rets=only_check_near_rets,
max_block_size=max_block_size, max_sym_mem_access=max_sym_mem_access,
is_thumb=is_thumb, kernel_mode=kernel_mode)
is_thumb=is_thumb, kernel_mode=kernel_mode, stack_gsize=stack_gsize)
self.arch = self.gadget_finder.arch

# chain builder
Expand Down
Loading