Files
gef/docs/commands/stub.md
T
crazy hugsy 90cced847b [Maintenance] Remove unmaintained commands, tests, and documentation, and moved to Ruff (#1222)
## Description

This PR  
 - removes unmaintained `shellcode` commands, tests, and documentation
- (finally) switches to Ruff instead of Pylint (still handled by
`pre-commit`)
 - fixes a few ruff/ty-found issues
2026-05-02 12:15:26 -07:00

1.3 KiB

Command stub

The stub command allows you stub out functions, optionally specifying the return value.

gef➤  stub [-h] [--retval RETVAL] [address]

address indicates the address of the function to bypass. If not specified, GEF will consider the instruction at the program counter to be the start of the function.

If --retval RETVAL is provided, GEF will set the return value to the provided value. Otherwise, it will set the return value to 0.

For example, it is trivial to bypass fork() calls. Since the return value is set to 0, it will in fact drop us into the "child" process. It must be noted that this is a different behaviour from the classic set follow-fork-mode child since here we do not spawn a new process, we only trick the parent process into thinking it has become the child.

Example

Patching fork() calls:

  • Without stub:

fork execution

  • With stub:

stubbed fork