Setting or accessing library load addresses #48
-
Is there a way to either explicitly set or access the address libraries are loaded at? I'm using I'm using the Python interface. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There's a manual way to get the library load addresses (provided that they have been loaded with
It is possible to get the mappings programmatically using the C++ API, but unfortunately we haven't yet written the Python bindings for it. As regards setting the load addresses for libraries, as of today there isn't a simple way. The solution I see would be to overwrite the @novafacing If you're interested in having Python bindings for accessing the memory mappings I can convert this discussion into an issue and add it in the TODO list :) |
Beta Was this translation helpful? Give feedback.
-
For anyone who discovers this after me but before ToB folks get around to adding the python interface: from maat import MaatEngine
from typing import Dict, List, Tuple
from collections import defaultdict
from bisect import insort
<...snip...>
def get_mappings(self, engine: MaatEngine) -> Dict[str, List[Tuple[int]]]:
"""
Get the mappings of the binary.
:param engine: Maat engine
"""
mappings = defaultdict(list)
rawmaps = list(map(lambda l: l.strip(), str(engine.mem).splitlines()))
maps = map(
lambda l: l.split(),
filter(
lambda l: l and l.startswith("0x"),
rawmaps[: rawmaps.index("Page permissions:")],
),
)
for mp in maps:
insort(mappings[mp[2]], (int(mp[0], 16), int(mp[1], 16)))
return dict(mappings) This will grab the current mappings as a dict of map name to list of mapped regions. |
Beta Was this translation helpful? Give feedback.
There's a manual way to get the library load addresses (provided that they have been loaded with
mmap
), by simply printing theMaatEngine
memory. Taken from your example in #49 (during load time so not all libraries have been loaded yet):