Skip to content

No libc.sym.__libc_start_main_ret while libcdb reports it #2563

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

Open
tesuji opened this issue Mar 18, 2025 · 4 comments
Open

No libc.sym.__libc_start_main_ret while libcdb reports it #2563

tesuji opened this issue Mar 18, 2025 · 4 comments

Comments

@tesuji
Copy link
Contributor

tesuji commented Mar 18, 2025

> libcdb file /lib/x86_64-linux-gnu/libc.so.6
[*] libc.so.6
    Version:     2.41
    BuildID:     beada22c75281a7e3ed0847c8ba3b2a28bddfe6c
    MD5:         56507c022fb7bd983d49e9e704db4aa1
    SHA1:        b6f98582f06859632f750cbcfd1b95d884ca8b19
    SHA256:      826b5033b9ad60b026cc7fce0d6eacb48de13aaa950f5f5d3a6711aba9ef224a
    Symbols:
        __libc_start_main_ret = 0x29ca8
                         dup2 = 0xff840
                       printf = 0x59880
                         puts = 0x80520
                         read = 0x103e90
                   str_bin_sh = 0x1a7ea4
                       system = 0x530d0
                        write = 0x104920

However, using ELF(libc_path).sym.__libc_start_main_ret raises a not-found exception.
It would be nice if we could automatically set this for ELF(libc).

@tesuji
Copy link
Contributor Author

tesuji commented Mar 18, 2025

LMAO. I found this in the doc: https://docs.pwntools.com/en/stable/elf/elf.html#pwnlib.elf.elf.ELF.libc_start_main_return
However, I still feel that automatically setting this on ELF(libc).sym is really nice to have.

@peace-maker
Copy link
Member

I didn't add it to the ELF.symbols by default since disassembling some code potentially twice takes time and I didn't want to slow down the average case of not using that symbol.

Some heuristic if the ELF is a libc could be cheap, so maybe lazily adding that symbol to the symbols dotdict somehow could work? To only look up the actual value if the code requests it.

@tesuji
Copy link
Contributor Author

tesuji commented Apr 6, 2025

What about raising an exception when accessing that virtual index to guide user towards ELF.libc_start_main_return ?

Image

@peace-maker
Copy link
Member

That's a good start to make this more discoverable. Would you be willing to submit a PR for this against stable please?

We can add lazy calculating the property later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants