Skip to content

Commit 36d5b2d

Browse files
author
Raccoon
committed
Fix poll error in process.libs() and clean up maps parsing
1 parent 1205b1a commit 36d5b2d

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

pwnlib/tubes/process.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,33 +1322,24 @@ 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 = self.poll() is None and self.maps()
13271326

1328-
if not maps_raw:
1327+
if not maps:
13291328
import pwnlib.elf.elf
13301329

13311330
with context.quiet:
13321331
return pwnlib.elf.elf.ELF(self.executable).maps
13331332

13341333
# Enumerate all of the libraries actually loaded right now.
1335-
maps = {}
1336-
for mapping in maps_raw:
1334+
libs = {}
1335+
for mapping in maps:
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)