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 LD_LIBRARY_PATH type feature #878

Merged
merged 5 commits into from
May 18, 2018
Merged

Conversation

catenacyber
Copy link
Contributor

@catenacyber catenacyber commented Apr 23, 2018

Use of environment variable MANTICORE_LD_PATH
instead of LD_LIBRARY_PATH which is protected on MacOS

Fixes #93


This change is Reviewable

Use of environment variable MANTICORE_LD_PATH
instead of LD_LIBRARY_PATH which is protected on MacOS

Fixes trailofbits#93
@catenacyber
Copy link
Contributor Author

Better than #861 for handling interpreter error

@disconnect3d
Copy link
Member

Please use open instead of file as the latter has been removed from Python 3 (which we will be compatible with soon).

interpreter = ELFFile(file(interpreter_filename))
elif 'MANTICORE_LD_PATH' in os.environ:
for mpath in os.environ['MANTICORE_LD_PATH'].split(":"):
logger.info("looking for interpreter %s", mpath+'/'+os.path.basename(interpreter_filename))
Copy link
Member

Choose a reason for hiding this comment

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

Use os.path.join to concatenate paths

Copy link
Member

Choose a reason for hiding this comment

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

Also use a variable for the interpreter path.

Commit to be squashed afterwards
@catenacyber
Copy link
Contributor Author

Thanks @disconnect3d
Here come the changes

@yan
Copy link
Contributor

yan commented May 9, 2018

Thanks again @catenacyber. I am thinking of what the best way to incorporate changes from this. I have a few concerns:

  1. We don't use environment variables to pass other options to Manticore; this would be slightly bucking the trend.
  2. In this case, MANTICORE_LD_PATH only controls the ELF interpreter loading path, not ld path in general. We can extend it to cover lib load path as well, that'd just require setting LD_LIBRARY_PATH.

@yan yan unassigned rats-god May 9, 2018
@catenacyber
Copy link
Contributor Author

We don't use environment variables to pass other options to Manticore; this would be slightly bucking the trend.

Ok, so I need to convert MANTICORE_LD_PATH environment variable to argument ld_path.
Or is there another way ? such as config file...

We can extend it to cover lib load path as well, that'd just require setting LD_LIBRARY_PATH

@yan I am not sure what you mean.
On MacOS, LD_LIBRARY_PATH is protected by so-called system integrity protection : you cannot set it.

@yan
Copy link
Contributor

yan commented May 14, 2018

On MacOS, LD_LIBRARY_PATH is protected by so-called system integrity protection : you cannot set it.

What I meant was setting MANTICORE_LD_PATH won't actually affect the dynamic linker, so it's a misnomer. Further, macOS is not currently supported, we only support Linux guests.

What I meant above is, currently MANTICORE_LD_PATH only controls the ELF interpreter path; we should either name it as such (although I still believe a command line argument is potentially more appropriate), or forward along the library path to the emulated binary so that works as expected. Does that make sense?

@catenacyber
Copy link
Contributor Author

Further, macOS is not currently supported, we only support Linux guests.

The point of this pull request is to progress towards macOS support

either name it as such
or forward along the library path to the emulated binary so that works as expected

The latter looks the best option to me.
What do you think ?

@yan
Copy link
Contributor

yan commented May 16, 2018

@catenacyber The latter choice sounds reasonable to me as well. So this would include passing LD_LIBRARY_PATH=/... as an extra env variable on the command line and code in Linux to honor it for loading the interpreter.

@yan yan merged commit f4c4c9a into trailofbits:master May 18, 2018
@catenacyber
Copy link
Contributor Author

catenacyber commented May 21, 2018

thanks @yan you were faster than me

But there is a typo with one variable name interpreter_path_filename

@catenacyber catenacyber deleted the libpath branch May 21, 2018 08:12
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.

6 participants