diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cb3fae7f..f344466cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -150,6 +150,7 @@ The table below shows which release corresponds to each branch, and what date th - [#2596][2596] Ignore `colored_traceback` error when TERM envvar is unset - [#2579][2579] Fix poll error in `process.libs()` and clean up maps parsing - [#2602][2602] Allow setting debugger path via context.gdb_binary +- [#2606][2606] Fix `process.maps()` [2545]: https://github.com/Gallopsled/pwntools/pull/2545 [2567]: https://github.com/Gallopsled/pwntools/pull/2567 @@ -160,6 +161,7 @@ The table below shows which release corresponds to each branch, and what date th [2596]: https://github.com/Gallopsled/pwntools/pull/2596 [2579]: https://github.com/Gallopsled/pwntools/pull/2579 [2602]: https://github.com/Gallopsled/pwntools/pull/2602 +[2606]: https://github.com/Gallopsled/pwntools/pull/2606 ## 4.14.1 (`stable`) diff --git a/pwnlib/tubes/process.py b/pwnlib/tubes/process.py index 45c0ca0fe..a54da5a07 100644 --- a/pwnlib/tubes/process.py +++ b/pwnlib/tubes/process.py @@ -944,7 +944,10 @@ def maps(self): # addr = address (alias) = start (alias) from pwnlib.util.proc import memory_maps - raw_maps = memory_maps(self.pid) + raw_maps = self.poll() is None and memory_maps(self.pid) + + if not raw_maps: + raise RuntimeError("Could not read maps, process %s has finished" % self.pid) maps = [] # raw_mapping @@ -1322,17 +1325,11 @@ def libs(self): by the process to the address it is loaded at in the process' address space. """ - maps_raw = self.poll() is None and self.maps() - - if not maps_raw: - import pwnlib.elf.elf - - with context.quiet: - return pwnlib.elf.elf.ELF(self.executable).maps + all_maps = self.maps() # Enumerate all of the libraries actually loaded right now. libs = {} - for mapping in maps_raw: + for mapping in all_maps: path = mapping.path if os.sep not in path: continue path = os.path.realpath(path)