Skip to content

Commit ffc46d2

Browse files
R42ccoonRaccoonpeace-maker
authored
Fix poll error in process.libs() and clean up maps parsing (#2579)
Co-authored-by: Raccoon <raccoon@42> Co-authored-by: peace-maker <[email protected]>
1 parent b93c5ac commit ffc46d2

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ The table below shows which release corresponds to each branch, and what date th
150150
- [#2593][2593] Use unicorn on macOS w/ SIP enabled
151151
- [#2587][2587] Support longer function names in Windows `getexport` shellcode
152152
- [#2596][2596] Ignore `colored_traceback` error when TERM envvar is unset
153+
- [#2579][2579] Fix poll error in `process.libs()` and clean up maps parsing
153154

154155
[2545]: https://github.com/Gallopsled/pwntools/pull/2545
155156
[2567]: https://github.com/Gallopsled/pwntools/pull/2567
@@ -158,6 +159,7 @@ The table below shows which release corresponds to each branch, and what date th
158159
[2593]: https://github.com/Gallopsled/pwntools/pull/2593
159160
[2587]: https://github.com/Gallopsled/pwntools/pull/2587
160161
[2596]: https://github.com/Gallopsled/pwntools/pull/2596
162+
[2579]: https://github.com/Gallopsled/pwntools/pull/2579
161163

162164
## 4.14.1 (`stable`)
163165

pwnlib/tubes/process.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,8 +1322,7 @@ def libs(self):
13221322
by the process to the address it is loaded at in the process' address
13231323
space.
13241324
"""
1325-
from pwnlib.util.proc import memory_maps
1326-
maps_raw = self.poll() is not None and memory_maps(self.pid)
1325+
maps_raw = self.poll() is None and self.maps()
13271326

13281327
if not maps_raw:
13291328
import pwnlib.elf.elf
@@ -1332,23 +1331,15 @@ def libs(self):
13321331
return pwnlib.elf.elf.ELF(self.executable).maps
13331332

13341333
# Enumerate all of the libraries actually loaded right now.
1335-
maps = {}
1334+
libs = {}
13361335
for mapping in maps_raw:
13371336
path = mapping.path
13381337
if os.sep not in path: continue
13391338
path = os.path.realpath(path)
1340-
if path not in maps:
1341-
maps[path]=0
1342-
1343-
for lib in maps:
1344-
path = os.path.realpath(lib)
1345-
for mapping in maps_raw:
1346-
if mapping.path == path:
1347-
address = mapping.addr.split('-')[0]
1348-
maps[lib] = int(address, 16)
1349-
break
1339+
if path not in libs:
1340+
libs[path] = mapping.addr
13501341

1351-
return maps
1342+
return libs
13521343

13531344
@property
13541345
def libc(self):

0 commit comments

Comments
 (0)