|
|
|
|
@ -11,6 +11,13 @@ import pwndbg.commands
|
|
|
|
|
from pwndbg.commands import CommandCategory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def _nextjmp(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
"""
|
|
|
|
|
Execution controller for the `nextjmp` command.
|
|
|
|
|
"""
|
|
|
|
|
await pwndbg.aglib.next.break_next_branch(ec)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pwndbg.commands.ArgparsedCommand(
|
|
|
|
|
"Breaks at the next jump instruction.", aliases=["nextjump"], category=CommandCategory.NEXT
|
|
|
|
|
)
|
|
|
|
|
@ -18,10 +25,7 @@ from pwndbg.commands import CommandCategory
|
|
|
|
|
def nextjmp() -> None:
|
|
|
|
|
"""Breaks at the next jump instruction"""
|
|
|
|
|
|
|
|
|
|
async def ctrl(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
await pwndbg.aglib.next.break_next_branch(ec)
|
|
|
|
|
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(ctrl)
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(_nextjmp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description="Breaks at the next call instruction.")
|
|
|
|
|
@ -46,6 +50,14 @@ def nextcall(symbol_regex=None) -> None:
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(ctrl)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def _nextret(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
"""
|
|
|
|
|
Execution controller for the `nextret` command.
|
|
|
|
|
"""
|
|
|
|
|
if await pwndbg.aglib.next.break_next_ret(ec):
|
|
|
|
|
pwndbg.commands.context.context()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pwndbg.commands.ArgparsedCommand(
|
|
|
|
|
"Breaks at next return-like instruction.", category=CommandCategory.NEXT
|
|
|
|
|
)
|
|
|
|
|
@ -53,11 +65,22 @@ def nextcall(symbol_regex=None) -> None:
|
|
|
|
|
def nextret() -> None:
|
|
|
|
|
"""Breaks at next return-like instruction"""
|
|
|
|
|
|
|
|
|
|
async def ctrl(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
if await pwndbg.aglib.next.break_next_ret(ec):
|
|
|
|
|
pwndbg.commands.context.context()
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(_nextret)
|
|
|
|
|
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(ctrl)
|
|
|
|
|
|
|
|
|
|
async def _stepret(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
"""
|
|
|
|
|
Execution controller for the `stepret` command.
|
|
|
|
|
"""
|
|
|
|
|
while (
|
|
|
|
|
pwndbg.aglib.proc.alive
|
|
|
|
|
and not (await pwndbg.aglib.next.break_next_ret(ec))
|
|
|
|
|
and (await pwndbg.aglib.next.break_next_branch(ec))
|
|
|
|
|
):
|
|
|
|
|
# Here we are e.g. on a CALL instruction (temporarily breakpointed by `break_next_branch`)
|
|
|
|
|
# We need to step so that we take this branch instead of ignoring it
|
|
|
|
|
await ec.single_step()
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pwndbg.commands.ArgparsedCommand(
|
|
|
|
|
@ -67,18 +90,14 @@ def nextret() -> None:
|
|
|
|
|
def stepret() -> None:
|
|
|
|
|
"""Breaks at next return-like instruction by 'stepping' to it"""
|
|
|
|
|
|
|
|
|
|
async def ctrl(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
while (
|
|
|
|
|
pwndbg.aglib.proc.alive
|
|
|
|
|
and not (await pwndbg.aglib.next.break_next_ret(ec))
|
|
|
|
|
and (await pwndbg.aglib.next.break_next_branch(ec))
|
|
|
|
|
):
|
|
|
|
|
# Here we are e.g. on a CALL instruction (temporarily breakpointed by `break_next_branch`)
|
|
|
|
|
# We need to step so that we take this branch instead of ignoring it
|
|
|
|
|
await ec.single_step()
|
|
|
|
|
continue
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(_stepret)
|
|
|
|
|
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(ctrl)
|
|
|
|
|
|
|
|
|
|
async def _nextproginstr(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
"""
|
|
|
|
|
Execution controller for the `nextproginstr` command.
|
|
|
|
|
"""
|
|
|
|
|
await pwndbg.aglib.next.break_on_program_code(ec)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pwndbg.commands.ArgparsedCommand(
|
|
|
|
|
@ -87,10 +106,7 @@ def stepret() -> None:
|
|
|
|
|
)
|
|
|
|
|
@pwndbg.commands.OnlyWhenRunning
|
|
|
|
|
def nextproginstr() -> None:
|
|
|
|
|
async def ctrl(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
await pwndbg.aglib.next.break_on_program_code(ec)
|
|
|
|
|
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(ctrl)
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(_nextproginstr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description="Breaks on the instruction after this one.")
|
|
|
|
|
@ -102,10 +118,25 @@ parser.add_argument("addr", type=int, default=None, nargs="?", help="The address
|
|
|
|
|
def stepover(addr=None) -> None:
|
|
|
|
|
"""Sets a breakpoint on the instruction after this one"""
|
|
|
|
|
|
|
|
|
|
async def ctrl(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
async def _stepover(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
"""
|
|
|
|
|
Execution controller for the `stepover` command.
|
|
|
|
|
"""
|
|
|
|
|
await pwndbg.aglib.next.break_on_next(ec, addr)
|
|
|
|
|
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(ctrl)
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(_stepover)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def _nextsyscall(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
"""
|
|
|
|
|
Execution controller for the `nextsyscall` command
|
|
|
|
|
"""
|
|
|
|
|
while (
|
|
|
|
|
pwndbg.aglib.proc.alive
|
|
|
|
|
and not (await pwndbg.aglib.next.break_next_interrupt(ec))
|
|
|
|
|
and (await pwndbg.aglib.next.break_next_branch(ec))
|
|
|
|
|
):
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pwndbg.commands.ArgparsedCommand(
|
|
|
|
|
@ -118,16 +149,23 @@ def nextsyscall() -> None:
|
|
|
|
|
"""
|
|
|
|
|
Breaks at the next syscall not taking branches.
|
|
|
|
|
"""
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(_nextsyscall)
|
|
|
|
|
|
|
|
|
|
async def ctrl(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
while (
|
|
|
|
|
pwndbg.aglib.proc.alive
|
|
|
|
|
and not (await pwndbg.aglib.next.break_next_interrupt(ec))
|
|
|
|
|
and (await pwndbg.aglib.next.break_next_branch(ec))
|
|
|
|
|
):
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(ctrl)
|
|
|
|
|
async def _stepsyscall(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
"""
|
|
|
|
|
Execution controller for the `stepsyscall` command.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
while (
|
|
|
|
|
pwndbg.aglib.proc.alive
|
|
|
|
|
and not (await pwndbg.aglib.next.break_next_interrupt(ec))
|
|
|
|
|
and (await pwndbg.aglib.next.break_next_branch(ec))
|
|
|
|
|
):
|
|
|
|
|
# Here we are e.g. on a CALL instruction (temporarily breakpointed by `break_next_branch`)
|
|
|
|
|
# We need to step so that we take this branch instead of ignoring it
|
|
|
|
|
await ec.single_step()
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pwndbg.commands.ArgparsedCommand(
|
|
|
|
|
@ -141,18 +179,7 @@ def stepsyscall() -> None:
|
|
|
|
|
Breaks at the next syscall by taking branches.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
async def ctrl(ec: pwndbg.dbg_mod.ExecutionController):
|
|
|
|
|
while (
|
|
|
|
|
pwndbg.aglib.proc.alive
|
|
|
|
|
and not (await pwndbg.aglib.next.break_next_interrupt(ec))
|
|
|
|
|
and (await pwndbg.aglib.next.break_next_branch(ec))
|
|
|
|
|
):
|
|
|
|
|
# Here we are e.g. on a CALL instruction (temporarily breakpointed by `break_next_branch`)
|
|
|
|
|
# We need to step so that we take this branch instead of ignoring it
|
|
|
|
|
await ec.single_step()
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(ctrl)
|
|
|
|
|
pwndbg.dbg.selected_inferior().dispatch_execution_controller(_stepsyscall)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description="Breaks on the next matching instruction.")
|
|
|
|
|
|