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

loading android system libs #103

Closed
antisec opened this issue Jan 2, 2018 · 8 comments
Closed

loading android system libs #103

antisec opened this issue Jan 2, 2018 · 8 comments

Comments

@antisec
Copy link

antisec commented Jan 2, 2018

seams this is elftools related.
starting with android7.0 with libs in /lib/system/ from a nexus device.

>>> p = angr.Project("libmedia.so")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/angr/project.py", line 156, in __init__
    self.loader = cle.Loader(self.filename, **load_options)
  File "/usr/local/lib/python2.7/dist-packages/cle/loader.py", line 124, in __init__
    self.initial_load_objects = self._internal_load(main_binary, *force_load_libs)
  File "/usr/local/lib/python2.7/dist-packages/cle/loader.py", line 471, in _internal_load
    if self.find_object(main_spec, extra_objects=objects) is not None:
  File "/usr/local/lib/python2.7/dist-packages/cle/loader.py", line 284, in find_object
    for ident in self._possible_idents(spec):
  File "/usr/local/lib/python2.7/dist-packages/cle/loader.py", line 805, in _possible_idents
    soname = backend_cls.extract_soname(spec)
  File "/usr/local/lib/python2.7/dist-packages/cle/backends/elf/metaelf.py", line 272, in extract_soname
    soname = [ x.soname for x in list(dyn.iter_tags()) if x.entry.d_tag == 'DT_SONAME']
  File "/usr/local/lib/python2.7/dist-packages/elftools/elf/dynamic.py", line 135, in iter_tags
    yield DynamicTag(tag, self._get_stringtable())
  File "/usr/local/lib/python2.7/dist-packages/elftools/elf/dynamic.py", line 51, in __init__
    stringtable.get_string(self.entry.d_val))
  File "/usr/local/lib/python2.7/dist-packages/elftools/elf/sections.py", line 70, in get_string
    return s.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfa in position 1: ordinal not in range(128)
>>>
@schieb
Copy link
Contributor

schieb commented Jan 2, 2018

Could you please upload the binary?

@rhelmot
Copy link
Member

rhelmot commented Jan 4, 2018

It's not hard to reproduce - pyelftools just absolutely cannot handle non-ascii characters. I've reported it to them here eliben/pyelftools#173

@antisec
Copy link
Author

antisec commented Jan 4, 2018

i uploaded it here :libmedia.so its standart system/lib from android 7.0 nexus 5x

@rhelmot
Copy link
Member

rhelmot commented Jan 5, 2018

so this is indeed a pyelftools bug, though it's more complicated than I initially thought. See the latest linked issue.

@rhelmot
Copy link
Member

rhelmot commented Feb 24, 2018

I finally figured out how to solve this on the pyelftools level, but now we're waiting for them to make a new release.

You can't actually use the current github pyelftools with cle because of some internal changes they made that break some hacks we use, so that's preventing me from closing this issue right now, but I'll get to that soon.

@ltfish
Copy link
Member

ltfish commented Feb 25, 2018

The related PR: eliben/pyelftools#182

@rhelmot
Copy link
Member

rhelmot commented Feb 25, 2018

Actually that was not the fix to this problem, it would have just masked the issue. This was the one that actually fixed it: eliben/pyelftools#183

@rhelmot
Copy link
Member

rhelmot commented Mar 4, 2018

You can now use the upstream, fixed pyelftools with angr! It's not released on pypi so you'll have to install it from their github, but it now works: a22c5a6

@rhelmot rhelmot closed this as completed Mar 4, 2018
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

No branches or pull requests

4 participants