Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config to override libc version. #1027

Merged
merged 8 commits into from
Dec 22, 2023
Merged

Conversation

r12f
Copy link
Contributor

@r12f r12f commented Dec 20, 2023

Description

This change add a config for force the libc version to a specific version.

This is helpful when debugging certain core dumps that doesn't have good memory map information, and could not find libc properly.

This shows up in our recent debugging, where we know the program is using libc 2.31, but it could not be detected properly due to memory map information missing.

The screenshot below shows the libc version missing problem, which results failures when dumping the heap:

  • libc version missing:

    image

  • having trouble dump heap arenas (see top == 0, while arena pointer is right):

    image

This change allows us to force the libc version into a specific version, which solves this problem.

Here is the screenshots that demos the fix:

image

  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • If my change adds new code, adequate tests have been added.
  • I have read and agree to the CONTRIBUTING document.

Copy link
Collaborator

@Grazfather Grazfather left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is good, but I wonder if this could be done better with some command, rather than a config. To me a config is user configuration that basically configures his experience and shouldn't really be used for a specific target. I can see people getting weird behaviour if they accidentally set it, gef save, and then can't work with heap stuff in normal binaries anymore.

@r12f
Copy link
Contributor Author

r12f commented Dec 21, 2023

yea, i thought about that case too, hence i added test to make sure that this config could be cleared by setting ''.

is there any recommended way for doing this? so far it looks like config seems to be the way... or maybe we can make some config not persistent?

@Grazfather
Copy link
Collaborator

The command could set a variable, maybe member of a class or instance, which is readable from exactly where you check the config. That way it would never pessist.

@r12f
Copy link
Contributor Author

r12f commented Dec 21, 2023

would you like it to be part of the config or should we introduce a new command?

@Grazfather
Copy link
Collaborator

third option would be that all heap commands could take a --libc-version opt arg, though that would be annoying to have to type each time. Let's let @hugsy weigh in.

@r12f
Copy link
Contributor Author

r12f commented Dec 21, 2023

sounds perfect! let's see which way we like to go.

@hugsy
Copy link
Owner

hugsy commented Dec 22, 2023

Actually this (enforcing the libc version via config) could be useful especially for ctf exploits, it'd allow to programmatically switch the libc.
And for that matter, the --libc-version option Graz mentioned could also be added in the future, and read into that.

hugsy
hugsy previously requested changes Dec 22, 2023
gef.py Outdated Show resolved Hide resolved
@hugsy hugsy added this to the 2024.01 milestone Dec 22, 2023
@Grazfather Grazfather merged commit 663d4a2 into hugsy:main Dec 22, 2023
4 of 5 checks passed
@r12f r12f deleted the user/r12f/libc_ver branch December 22, 2023 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants