Skip to content

Commit

Permalink
add new API pane for glibc and syscalls (#111)
Browse files Browse the repository at this point in the history
This fixes all the issues with the context panes and it now works as it
did before the plugins were created.

In the GEF part, it was just a minor refactor and a new external API. 

In the gef-extras part, it was only necessary to call this new function!

I think the proposed solution is simple and it works.

gef code:
- hugsy/gef#1093
  • Loading branch information
therealdreg authored Apr 27, 2024
1 parent 0b481fd commit 9d7ff6f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
21 changes: 13 additions & 8 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ Start with cloning this repo:
git clone https://github.com/hugsy/gef-extras
```

Add syscall_args and libc_function_args to context layout:

```text
gef➤ pi gef.config['context.layout'] += ' syscall_args'
gef➤ pi gef.config['context.layout'] += ' libc_function_args'
```

Add the path to the external scripts to GEF's config:

```text
Expand All @@ -90,11 +97,13 @@ gef➤ gef config context.libc_args True
gef➤ gef config context.libc_args_path /path/to/gef-extras/glibc-function-args
```

Check out the [complete documentation](commands/glibc_function_args.md) on libc argument support.

And don't forget to save your settings.

Now run and enjoy all the fun!
```text
gef➤ gef save
```

Check out the [complete documentation](commands/glibc_function_args.md) on libc argument support.

Note that it is possible to specify multiple directories, separating the paths with
a semi-colon:
Expand All @@ -103,8 +112,4 @@ a semi-colon:
gef➤ gef config gef.extra_plugins_dir /path/to/dir1;/path/to/dir2
```

And don't forget to save your settings.

```text
gef➤ gef save
```
Now run and enjoy all the fun!
5 changes: 5 additions & 0 deletions scripts/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,11 @@ def register_external_context_pane(pane_name: str, display_pane_function: Callab
def pane_title() -> str: ...


def register_external_context_layout_mapping(current_pane_name: str, display_pane_function: Callable[[], None], pane_title_function: Callable[[], Optional[str]], condition: Optional[Callable[[], bool]]) -> None:
def display_pane() -> None: ...
def pane_title() -> str: ...


def register(cls: Union[Type["GenericCommand"], Type["GenericFunction"]]) -> Union[Type["GenericCommand"], Type["GenericFunction"]]: ...


Expand Down
4 changes: 2 additions & 2 deletions scripts/libc_function_args/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ def extract_called_function_name() -> str:

return function_name

if GLIBC_FUNCTION_ARGS_CONTEXT_PANE_INDEX not in gef.config["context.layout"]:
if GLIBC_FUNCTION_ARGS_CONTEXT_PANE_INDEX in gef.config["context.layout"]:
#
# Register the context pane
#
register_external_context_pane(
register_external_context_layout_mapping(
GLIBC_FUNCTION_ARGS_CONTEXT_PANE_INDEX,
GlibcFunctionArguments.pane_content,
pane_title_function=GlibcFunctionArguments.pane_title,
Expand Down
4 changes: 2 additions & 2 deletions scripts/syscall_args/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ def __syscall_args_pane_content() -> None:
def __syscall_args_pane_title() -> str:
return CONTEXT_PANE_DESCRIPTION

if CONTEXT_PANE_INDEX not in gef.config["context.layout"]:
if CONTEXT_PANE_INDEX in gef.config["context.layout"]:
#
# Register a callback to `syscall-args` to automatically detect when a syscall is hit
#
register_external_context_pane(
register_external_context_layout_mapping(
CONTEXT_PANE_INDEX, __syscall_args_pane_content, pane_title_function=__syscall_args_pane_title, condition=__syscall_args_pane_condition)

0 comments on commit 9d7ff6f

Please sign in to comment.