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

gdb.debug(env) affects gdbserver #1307

Closed
mzr opened this issue May 8, 2019 · 2 comments
Closed

gdb.debug(env) affects gdbserver #1307

mzr opened this issue May 8, 2019 · 2 comments

Comments

@mzr
Copy link
Contributor

mzr commented May 8, 2019

Setting LD_PRELOAD as in gdb.debug(... ,env={'LD_PRELOAD' : './some.so'}) makes gdbserver itself use that some.so library. Currently I see no mechanism in pwntools allowing specifying env only for the debugged process.

It's been kind of fixed in #1083, yet gdbserver can give different outputs than those starting with "ERROR:".

--wrapper option could solve that problem.
gdbserver --wrapper env 'LD_PRELOAD=./libefence.so' -- :1234 ./test-program
gdbserver manual

@zachriggle
Copy link
Member

zachriggle commented May 8, 2019 via email

@zachriggle
Copy link
Member

On follow-up, I'm not sure the best way to handle this. The current way we do this is to set the environment on gdbserver which is inherited by the child binary (which you pointed out). This causes issues on LD_PRELOAD, specifically.

We might want to special-case tricky environment variables like this and PATH. It looks like we can do the following:

gdbserver --wrapper env LD_PRELOAD=libtest.so -- 

I can't contribute to Pwntools anymore (employer), but if you submit a PR I can merge it.

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