termux / termux-root-packages

Termux packages that are only usable by root users.
Other
1.04k stars 294 forks source link

frida-python: `import frida` fails after upgrading to 14.2.14 #237

Closed ghost closed 3 years ago

ghost commented 3 years ago

Problem description After upgrading frida-python to 14.2.14, import frida fails with following message:

ImportError: dlopen failed: cannot locate symbol "frida_selinux_apply_policy_patch" referenced by "/data/data/com.termux/files/usr/lib/python3.9/site-packages/_frida.so"...

Scripts in frida-tools package (which depends on frida-python) fails with same error.

Steps to reproduce

~ $ python
Python 3.9.2 (default, Feb 22 2021, 12:26:04)
[Clang 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489 on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import frida

***
Failed to load the Frida native extension: dlopen failed: cannot locate symbol "frida_selinux_apply_policy_patch" referenced by "/data/data/com.termux/files/usr/lib/python3.9/site-packages/_frida.so"...
Please ensure that the extension was compiled for Python 3.x.
***

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/frida/__init__.py", line 24, in <module>
    raise ex
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/frida/__init__.py", line 7, in <module>
    import _frida
ImportError: dlopen failed: cannot locate symbol "frida_selinux_apply_policy_patch" referenced by "/data/data/com.termux/files/usr/lib/python3.9/site-packages/_frida.so"...
>>>
~ $
~ $ frida-ps

***
Failed to load the Frida native extension: dlopen failed: cannot locate symbol "frida_selinux_apply_policy_patch" referenced by "/data/data/com.termux/files/usr/lib/python3.9/site-packages/_frida.so"...
Please ensure that the extension was compiled for Python 3.x.
***

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/frida-ps", line 10, in <module>
    frida_tools.ps.main()
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/frida_tools/ps.py", line 8, in main
    from frida_tools.application import ConsoleApplication
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/frida_tools/application.py", line 23, in <module>
    import frida
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/frida/__init__.py", line 24, in <module>
    raise ex
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/frida/__init__.py", line 7, in <module>
    import _frida
ImportError: dlopen failed: cannot locate symbol "frida_selinux_apply_policy_patch" referenced by "/data/data/com.termux/files/usr/lib/python3.9/site-packages/_frida.so"...
~ $

Expected behavior -

Additional information I believe it's happening because the function name has changed by upstream while the patch in this repository hasn't been updated accordingly.

https://github.com/frida/frida-core/blob/2cb83c81e596cc6a3589bdcdca5fbaf2ba65b672/lib/selinux/patch.c#L59

https://github.com/termux/termux-root-packages/blob/48be2f13705f616af2e2eab0b8c298ec86ec60e7/packages/frida-server/frida-python-src-_frida.c.patch#L8

Grimler91 commented 3 years ago

Thanks for reporting and investigating! Should be fixed in frida 14.2.18, which should be available in ~half an hour as long as the build succeeds

Grimler91 commented 3 years ago

Welp, re-opening. CI build fails with some weird error and local build seem to fail due to arm build requiring ndk 22, so need to spend some time on it.

Grimler91 commented 3 years ago

Fixed in frida 14.2.14-1

arjatr commented 2 years ago

The same thing happens to me with the latest version

arjatr commented 2 years ago

Any solution?

Grimler91 commented 2 years ago

@arjatr please open a new issue and fill in the bug report template. I get an error when I try to import frida, but it is totally different from the one in this issue, so yours might be different

arjatr commented 2 years ago

@arjatr please open a new issue and fill in the bug report template. I get an error when I try to import frida, but it is totally different from the one in this issue, so yours might be different

is the same Screenshot_20211212-005938008

Grimler91 commented 2 years ago

You get the same error as me. The error message is completely different from the one in this issue