Gallopsled / pwntools

CTF framework and exploit development library
http://pwntools.com
Other
11.74k stars 1.67k forks source link

Get address of stack, heap, binary in memory of process #2369

Open k4lizen opened 4 months ago

k4lizen commented 4 months ago

The same way there is a way to get the address of shared libraries: process.libs(), which is currently implemented by inspecting /proc/<pid>/maps as linked in the docs, it should be possible to find the base address of the binary, stack and heap, even when ASLR is on.

This would be quite handy in some cases (like easily calculating offsets locally, which can then be used on remote processes).

k4lizen commented 4 months ago

Along with this, a process.maps() (which would returned a parsed /proc/<pid>/maps) could be implemented, and .libc/libs/stack/heap/whatever would just use that. Also returning the size along with the address would be useful.

k4lizen commented 4 months ago

I would be willing to work on this PR if the feature is approved.

peace-maker commented 4 months ago

Sure, this sounds useful! Next to the hardcoded properties, having a shortcut to receive the base address of any mapping without having to filter the .libs() result manually would be great too.