-
-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This pull request addresses a limitation in GDB where the "nexti" and "next" commands fail to step over call instructions properly
- Loading branch information
1 parent
6a2ecce
commit 13af366
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Command `stepover` | ||
|
||
The stepover command simplifies the process of stepping over instructions by continuing to a | ||
temporary breakpoint at the next instruction. | ||
|
||
This feature is particularly useful for stepping over call/rep instructions. | ||
|
||
Ex: Step over call instruction | ||
|
||
```text | ||
stepover | ||
``` | ||
|
||
```bash | ||
gef➤ stepover | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
`stepover` command test module | ||
""" | ||
|
||
import pytest | ||
|
||
from tests.base import RemoteGefUnitTestGeneric | ||
from tests.utils import ARCH, ERROR_INACTIVE_SESSION_MESSAGE, p32, p64, u16, u32 | ||
|
||
|
||
class Stepover(RemoteGefUnitTestGeneric): | ||
"""`stepover` command test module""" | ||
|
||
cmd = "stepover" | ||
|
||
def test_cmd_stepover_inactive(self): | ||
gdb = self._gdb | ||
res = gdb.execute(f"{self.cmd}", to_string=True) | ||
self.assertEqual(ERROR_INACTIVE_SESSION_MESSAGE, res) | ||
|
||
@pytest.mark.skipif(ARCH not in ("i686", "x86_64"), reason=f"Skipped for {ARCH}") | ||
def test_cmd_stepover(self): | ||
gdb = self._gdb | ||
gef = self._gef | ||
|
||
payload = b"\xe8\x05\x00\x00\x00\x90\x90\x6a\x00\xc3\xb8\x69\x69\x69\x69\xc3" | ||
''' | ||
call movtag <- 'stepover' execution from this point | ||
nop <- 'stepover' should stops here and eax value should be 0x69696969 | ||
nop | ||
push 0 | ||
ret <- if something fails we want a specific crash | ||
movtag: | ||
mov eax, 0x69696969 | ||
ret | ||
''' | ||
|
||
gdb.execute("start") | ||
gef.memory.write(gef.arch.pc, payload) | ||
res = gdb.execute(self.cmd, to_string=True) | ||
assert res | ||
mem = u16(gef.memory.read(gef.arch.pc, 2)) # read 2 bytes | ||
self.assertEqual(0x9090, mem) # 2 nops | ||
self.assertEqual(0x69696969, gef.arch.register("$eax")) |