Skip to content

Commit

Permalink
[FIX] Fix how libc base is searched by adding a .so at the end of the…
Browse files Browse the repository at this point in the history
… filename
  • Loading branch information
ValekoZ committed Apr 10, 2024
1 parent 429a0e5 commit 5baa5fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -10750,7 +10750,7 @@ def find_main_arena_addr() -> int:
# Before anything else, use libc offset from config if available
if gef.config["gef.main_arena_offset"]:
try:
libc_base = get_section_base_address("libc")
libc_base = get_section_base_address("libc.so")
offset: int = gef.config["gef.main_arena_offset"]
if libc_base:
dbg(f"Using main_arena_offset={offset:#x} from config")
Expand Down Expand Up @@ -10797,7 +10797,7 @@ def find_main_arena_addr() -> int:
try:
dbg("Trying to bruteforce main_arena address")
# setup search_range for `main_arena` to `.data` of glibc
search_filter = lambda f: "libc" in f.filename and f.name == ".data"
search_filter = lambda f: "libc.so" in f.filename and f.name == ".data"
dotdata = list(filter(search_filter, get_info_files()))[0]
search_range = range(dotdata.zone_start, dotdata.zone_end, alignment)
# find first possible candidate
Expand Down Expand Up @@ -11391,7 +11391,7 @@ def version(self) -> Optional[Tuple[int, int]]:
@lru_cache()
def find_libc_version() -> Tuple[int, int]:
"""Attempt to determine the libc version. This operation can be long."""
libc_sections = (m for m in gef.memory.maps if "libc" in m.path and m.permission == Permission.READ)
libc_sections = (m for m in gef.memory.maps if "libc.so" in m.path and m.permission == Permission.READ)
for section in libc_sections:
# Try to determine from the filepath
match = re.search(GefLibcManager.PATTERN_LIBC_VERSION_FILENAME, section.path)
Expand Down

0 comments on commit 5baa5fa

Please sign in to comment.