Which environment variables the app is using

404 views Asked by At

I have binary executable file compiled from C-source and I know that it uses some of UNIX system environment variables. Unfortunately I have no documentation and decompiling/reverse-engineering is very difficult.

Is there a way to find which env variables the app tries to read in runtime?

I mean, if C's getenv reads some file to get variable values or does a system call, it is possible. So, can I do it?

2

There are 2 answers

0
Armali On

strings(1) might help you to identify the names of the envrionment variables. – Blagovest Buyukliev

0
Armali On

One can use a debugger, set a breakpoint on getenv, and inspect the function argument. This is possible even without debug information (albeit more difficult, since it requires knowledge of the calling convention).