Skip to content

Commit

Permalink
issue #137: added documentation to heap set-arena and heap chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Feb 24, 2018
1 parent f1f47f8 commit 4b05ef9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
39 changes: 35 additions & 4 deletions docs/commands/heap.md
Expand Up @@ -11,17 +11,35 @@ gef➤ heap <sub_commands>
```


### `heap chunks` command ###

Displays all the chunks from the `heap` section.

```
gef➤ heap chunks
```

In some cases, the allocation will start immediately from start of the page. If
so, specify the base address of the first chunk as follow:

```
gef➤ heap chunks <LOCATION>
```

![heap-chunks](https://i.imgur.com/2Ew2fA6.png)


### `heap chunk` command ###

This command gives visual information of a Glibc malloc-ed chunked. Simply
provide the address to the user memory pointer of the chunk to show the
information related to the current chunk:
information related to a specific chunk:

```
gef➤ heap chunk <LOCATION>
```

![heap-chunks](https://i.imgur.com/SAWNptW.png)
![heap-chunk](https://i.imgur.com/SAWNptW.png)



Expand All @@ -32,8 +50,22 @@ Multi-threaded programs have different arenas, and the only knowledge of the
to help you list all the arenas allocated in your program **at the moment you
call the command**.

![heap-arena](https://i.imgur.com/ajbLiCF.png)
![heap-arenas](https://i.imgur.com/ajbLiCF.png)



### `heap set-arena` command ###

In cases where the debug symbol are not present (e.g. statically stripped
binary), it is possible to instruct GEF to find the `main_arena` at a different
location with the command:

```
gef➤ heap set-arena <LOCATION>
```

If the arena address is correct, all `heap` commands will be functional, and use
the specified address for `main_arena`.


### `heap bins` command ###
Expand Down Expand Up @@ -84,4 +116,3 @@ All the other subcommands for the `heap bins` work the same way as `fast`. If
no argument is provided, `gef` will fall back to `main_arena`. Otherwise, it
will use the address pointed as the base of the `malloc_state` structure and
print out information accordingly.

8 changes: 4 additions & 4 deletions gef.py
Expand Up @@ -5471,17 +5471,17 @@ class GlibcHeapCommand(GenericCommand):
"""Base command to get information about the Glibc heap structure."""

_cmdline_ = "heap"
_syntax_ = "{:s} (chunk|bins|arenas)".format(_cmdline_)
_syntax_ = "{:s} (chunk|chunk|bins|arenas)".format(_cmdline_)

def __init__(self):
super(GlibcHeapCommand, self).__init__(prefix=True)
return

@only_if_gdb_running
def do_invoke(self, argv):
if len(argv)==0:
self.usage()
return
self.usage()
return


@register_command
class GlibcHeapSetArenaCommand(GenericCommand):
Expand Down

0 comments on commit 4b05ef9

Please sign in to comment.