frida / frida

Clone this repo to build Frida
https://frida.re
Other
16.14k stars 1.67k forks source link

ERROR: frida_resolve_remote_library_function: assertion failed: (module != NULL) #12

Closed shitsecurity closed 9 years ago

shitsecurity commented 9 years ago

debian sid

root@b751a7d3b40c:~# nc -l -p 8080 &
[1] 56
root@b751a7d3b40c:~# frida-trace -i 'recv*' nc
Attaching...
**
ERROR:../../../../frida-core/src/linux/linjector-glue.c:928:frida_resolve_remote_library_function: assertion failed: (module != NULL)
Aborted
root@b751a7d3b40c:~# 
oleavr commented 9 years ago

Looks like the injector isn't able to find a certain loaded library. Perhaps you could add some temporary printf-logging to check which? Also, a dump of /proc/<pid>/maps would be great.

Thanks!

shitsecurity commented 9 years ago

The install on debian was via pip. I'm having trouble compiling some components of frida. Build log below. Any hints?

root@336e6d9de83a:/opt/frida.debug# ANDROID_NDK_ROOT=/opt/frida.debug/android-ndk-r10d/ make
make[1]: Entering directory '/opt/frida.debug'
. build/frida-env-android-arm.rc && make -C build/tmp-android-arm/frida-gum install
make[2]: Entering directory '/opt/frida.debug/build/tmp-android-arm/frida-gum'
Making install in gum
make[3]: Entering directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/gum'
  CXXLD    libfrida-gum.la
  CCLD     libfrida-gum-1.0.la
make[4]: Entering directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/gum'
 /bin/mkdir -p '/opt/frida.debug/build/frida-android-arm/lib'
 /bin/bash ../libtool   --mode=install /usr/bin/install -p   libfrida-gum-1.0.la '/opt/frida.debug/build/frida-android-arm/lib'
libtool: install: /usr/bin/install -p .libs/libfrida-gum-1.0.lai /opt/frida.debug/build/frida-android-arm/lib/libfrida-gum-1.0.la
libtool: install: /usr/bin/install -p .libs/libfrida-gum-1.0.a /opt/frida.debug/build/frida-android-arm/lib/libfrida-gum-1.0.a
libtool: install: chmod 644 /opt/frida.debug/build/frida-android-arm/lib/libfrida-gum-1.0.a
libtool: install: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib /opt/frida.debug/build/frida-android-arm/lib/libfrida-gum-1.0.a
 /bin/mkdir -p '/opt/frida.debug/build/frida-android-arm/include/frida-1.0/gum/arch-arm'
 /usr/bin/install -p -m 644 ../../../../frida-gum/gum/arch-arm/gumarmbacktracer.h '/opt/frida.debug/build/frida-android-arm/include/frida-1.0/gum/arch-arm'
 /bin/mkdir -p '/opt/frida.debug/build/frida-android-arm/include/frida-1.0/gum/arch-arm64'
 /usr/bin/install -p -m 644 ../../../../frida-gum/gum/arch-arm64/gumarm64.h ../../../../frida-gum/gum/arch-arm64/gumarm64writer.h ../../../../frida-gum/gum/arch-arm64/gumarm64relocator.h '/opt/frida.debug/build/frida-android-arm/include/frida-1.0/gum/arch-arm64'
 /bin/mkdir -p '/opt/frida.debug/build/frida-android-arm/include/frida-1.0/gum/arch-arm'
 /usr/bin/install -p -m 644 ../../../../frida-gum/gum/arch-arm/gumarm.h ../../../../frida-gum/gum/arch-arm/gumarmwriter.h ../../../../frida-gum/gum/arch-arm/gumarmrelocator.h ../../../../frida-gum/gum/arch-arm/gumthumbwriter.h ../../../../frida-gum/gum/arch-arm/gumthumbrelocator.h '/opt/frida.debug/build/frida-android-arm/include/frida-1.0/gum/arch-arm'
 /bin/mkdir -p '/opt/frida.debug/build/frida-android-arm/include/frida-1.0/gum'
 /usr/bin/install -p -m 644 ../../../../frida-gum/gum/gum.h ../../../../frida-gum/gum/gumarray.h ../../../../frida-gum/gum/gumbacktracer.h ../../../../frida-gum/gum/gumcodeallocator.h ../../../../frida-gum/gum/gumdefs.h ../../../../frida-gum/gum/gumevent.h ../../../../frida-gum/gum/gumeventsink.h ../../../../frida-gum/gum/gumfunction.h ../../../../frida-gum/gum/gumhash.h ../../../../frida-gum/gum/guminterceptor.h ../../../../frida-gum/gum/guminvocationcontext.h ../../../../frida-gum/gum/guminvocationlistener.h ../../../../frida-gum/gum/gumlist.h ../../../../frida-gum/gum/gummemory.h ../../../../frida-gum/gum/gummemoryaccessmonitor.h ../../../../frida-gum/gum/gummemorymap.h ../../../../frida-gum/gum/gumprocess.h ../../../../frida-gum/gum/gumreturnaddress.h ../../../../frida-gum/gum/gumspinlock.h ../../../../frida-gum/gum/gumstalker.h ../../../../frida-gum/gum/gumsymbolutil.h ../../../../frida-gum/gum/gumsysinternals.h ../../../../frida-gum/gum/backend-linux/gumlinux.h ../../../../frida-gum/gum/gumscript.h '/opt/frida.debug/build/frida-android-arm/include/frida-1.0/gum'
 /bin/mkdir -p '/opt/frida.debug/build/frida-android-arm/include/frida-1.0/gum/arch-x86'
 /usr/bin/install -p -m 644 ../../../../frida-gum/gum/arch-x86/gumx86writer.h ../../../../frida-gum/gum/arch-x86/gumx86relocator.h ../../../../frida-gum/gum/arch-x86/gumx86reader.h '/opt/frida.debug/build/frida-android-arm/include/frida-1.0/gum/arch-x86'
make[4]: Leaving directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/gum'
make[3]: Leaving directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/gum'
Making install in tests
make[3]: Entering directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/tests'
Making install in core
make[4]: Entering directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/tests/core'
make[5]: Entering directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/tests/core'
make[5]: Nothing to be done for 'install-exec-am'.
make[5]: Nothing to be done for 'install-data-am'.
make[5]: Leaving directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/tests/core'
make[4]: Leaving directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/tests/core'
make[4]: Entering directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/tests'
  CCLD     gum-tests
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /opt/frida.debug/android-ndk-r10d//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a(Unwind-EHABI.o): multiple definition of '_Unwind_VRS_Pop'
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/thumb/libgcc.a(unwind-arm.o): previous definition here
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /opt/frida.debug/android-ndk-r10d//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a(Unwind-EHABI.o): multiple definition of '__aeabi_unwind_cpp_pr0'
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/thumb/libgcc.a(unwind-arm.o): previous definition here
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /opt/frida.debug/android-ndk-r10d//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a(Unwind-EHABI.o): multiple definition of '_Unwind_VRS_Get'
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/thumb/libgcc.a(unwind-arm.o): previous definition here
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /opt/frida.debug/android-ndk-r10d//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a(Unwind-EHABI.o): multiple definition of '_Unwind_VRS_Set'
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/thumb/libgcc.a(unwind-arm.o): previous definition here
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /opt/frida.debug/android-ndk-r10d//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a(Unwind-EHABI.o): multiple definition of '_Unwind_RaiseException'
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/thumb/libgcc.a(libunwind.o): previous definition here
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /opt/frida.debug/android-ndk-r10d//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a(Unwind-EHABI.o): multiple definition of '_Unwind_Complete'
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/thumb/libgcc.a(unwind-arm.o): previous definition here
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /opt/frida.debug/android-ndk-r10d//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a(Unwind-EHABI.o): multiple definition of '_Unwind_Resume'
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/thumb/libgcc.a(libunwind.o): previous definition here
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /opt/frida.debug/android-ndk-r10d//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a(Unwind-EHABI.o): multiple definition of '_Unwind_GetLanguageSpecificData'
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/thumb/libgcc.a(pr-support.o): previous definition here
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /opt/frida.debug/android-ndk-r10d//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a(Unwind-EHABI.o): multiple definition of '_Unwind_GetRegionStart'
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/thumb/libgcc.a(pr-support.o): previous definition here
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /opt/frida.debug/android-ndk-r10d//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_static.a(Unwind-EHABI.o): multiple definition of '_Unwind_DeleteException'
/opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /opt/frida.debug/android-ndk-r10d//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8/armv7-a/thumb/libgcc.a(unwind-arm.o): previous definition here
../../../../../glib/gio/xdgmime/xdgmimemagic.c:253: error: undefined reference to '__srget'
../../../../../glib/gio/xdgmime/xdgmimemagic.c:301: error: undefined reference to '__srget'
../../../../../glib/gio/xdgmime/xdgmimemagic.c:326: error: undefined reference to '__srget'
../../../../../glib/gio/xdgmime/xdgmimemagic.c:265: error: undefined reference to '__srget'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:698: recipe for target 'gum-tests' failed
make[4]: *** [gum-tests] Error 1
make[4]: Leaving directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/tests'
Makefile:754: recipe for target 'install-recursive' failed
make[3]: *** [install-recursive] Error 1
make[3]: Leaving directory '/opt/frida.debug/build/tmp-android-arm/frida-gum/tests'
Makefile:495: recipe for target 'install-recursive' failed
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory '/opt/frida.debug/build/tmp-android-arm/frida-gum'
Makefile.linux.mk:63: recipe for target 'build/frida-android-arm/lib/pkgconfig/frida-gum-1.0.pc' failed
make[1]: *** [build/frida-android-arm/lib/pkgconfig/frida-gum-1.0.pc] Error 2
make[1]: Leaving directory '/opt/frida.debug'
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 2
root@336e6d9de83a:/opt/frida.debug#
oleavr commented 9 years ago

Frida's prebuilt dependencies (its SDK) were built against NDK r9, and r10 is unfortunately not ABI compatible with it. Could you try with r9 and let me know how it goes?

shitsecurity commented 9 years ago

The ndk r9d dependency (https://dl.google.com/android/ndk/android-ndk-r9d-linux-x86_64.tar.bz2) would be useful to have in an INSTALL doc. The vanilla r9 fails to build due to clang not being included in the archive.

Now i'm hitting a different error:

root@ae28c4b496be:/opt/frida.debug# nc -l -p 8080 &
[1] 3510
root@ae28c4b496be:/opt/frida.debug# ./build/frida-linux-x86_64/bin/frida-trace -i 'recv*' nc

***
Failed to load the Frida native extension: dynamic module does not define init function (init_frida)
Please ensure that the extension was compiled for Python 2.7.
***

Traceback (most recent call last):
  File "./build/frida-linux-x86_64/bin/frida-trace", line 10, in <module>
    frida.tracer.main()
  File "/opt/frida.debug/build/frida-linux-x86_64/lib/python3.4/site-packages/frida/tracer.py", line 497, in main
    app.run()
  File "/opt/frida.debug/build/frida-linux-x86_64/lib/python3.4/site-packages/frida/application.py", line 57, in run
    mgr = frida.get_device_manager()
  File "/opt/frida.debug/build/frida-linux-x86_64/lib/python3.4/site-packages/frida/__init__.py", line 43, in get_device_manager
    raise ex
ImportError: dynamic module does not define init function (init_frida)
root@ae28c4b496be:/opt/frida.debug#

From what i gather, the 3.4 python bindings are somehow being confused with the 2.7 ones, which are also present, but reside in a neighboring dir? Any fix for this?

Edit: Uninstalled the frida version that came with pip via pip uninstall.

oleavr commented 9 years ago

Ahh, I'm sorry, I meant to say r9d. I'll add a note about this to the build system.

The issue with the Python version mixup is because the *.in scripts have this hashbang:

#!/usr/bin/env python

Perhaps it should be:

#!/usr/bin/env python@PYTHON_VERSION@

Let's try that.

oleavr commented 9 years ago

Just pushed the aforementioned changes. Would be great if you could confirm that the correct python interpreter is now being used.

Cheers!

oleavr commented 9 years ago

Oops, didn't quite get it right the first time. Sorry. Should work now.

shitsecurity commented 9 years ago

No go. Same problem.

make clean
git pull
ANDROID_NDK_ROOT=/opt/frida.debug/android-ndk-r9d/ make
root@eef029454a21:/opt/frida.debug# nc -l -p 8080 &
[1] 8532
root@eef029454a21:/opt/frida.debug# ./build/frida-linux-x86_64/bin/frida-trace -i 'recv*' nc

***
Failed to load the Frida native extension: dynamic module does not define init function (init_frida)
Please ensure that the extension was compiled for Python 2.7.
***

Traceback (most recent call last):
  File "./build/frida-linux-x86_64/bin/frida-trace", line 10, in <module>
    frida.tracer.main()
  File "/opt/frida.debug/build/frida-linux-x86_64/lib/python3.4/site-packages/frida/tracer.py", line 497, in main
    app.run()
  File "/opt/frida.debug/build/frida-linux-x86_64/lib/python3.4/site-packages/frida/application.py", line 57, in run
    mgr = frida.get_device_manager()
  File "/opt/frida.debug/build/frida-linux-x86_64/lib/python3.4/site-packages/frida/__init__.py", line 43, in get_device_manager
    raise ex
ImportError: dynamic module does not define init function (init_frida)
root@eef029454a21:/opt/frida.debug#
oleavr commented 9 years ago

After git pull, did you also do git submodule update? If you did, what's the first line of the frida-trace script you're running?

shitsecurity commented 9 years ago

Oh snap! Forgot about the submodules. My bad.

root@f179c5cdf954:/opt/frida.debug# ./build/frida-linux-x86_64/bin/frida-trace -h
Traceback (most recent call last):
  File "./build/frida-linux-x86_64/bin/frida-trace", line 10, in <module>
    frida.tracer.main()
  File "/opt/frida.debug/build/frida-linux-x86_64/lib/python3.4/site-packages/frida/tracer.py", line 432, in main
    from frida.application import ConsoleApplication
  File "/opt/frida.debug/build/frida-linux-x86_64/lib/python3.4/site-packages/frida/application.py", line 9, in <module>
    import colorama
ImportError: No module named 'colorama'
root@f179c5cdf954:/opt/frida.debug# vim ./build/frida-linux-x86_64/bin/frida-trace

Fixed by changing 3.4 to 2.7 in frida-trace (shebang + sys.path).

shitsecurity commented 9 years ago

Debug code:

  module = dlopen (local_library_path, RTLD_GLOBAL | RTLD_NOW);
  if( module == NULL ){
    printf( "%s\n", local_library_path );
  }
  g_assert (module != NULL);

Null library:

root@df135f6c6681:/opt/frida.debug# ./build/frida-linux-x86_64/bin/frida-trace -i 'recv*' nc
Attaching...                                                                
/mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/libc-2.19.so
**
ERROR:../../../../frida-core/src/linux/linjector-glue.c:931:frida_resolve_remote_library_function: assertion failed: (module != NULL)
Aborted
root@df135f6c6681:/opt/frida.debug# 

/proc/$pid/maps:

00400000-00406000 r-xp 00000000 08:08 8391177                            /mnt/xdat/var/lib/docker/aufs/diff/ec85d4ebd7d191aaa045ef7ad63912d4335630b9badc2abd8f0e954797f9f548/bin/nc.traditional
00605000-00606000 r--p 00005000 08:08 8391177                            /mnt/xdat/var/lib/docker/aufs/diff/ec85d4ebd7d191aaa045ef7ad63912d4335630b9badc2abd8f0e954797f9f548/bin/nc.traditional
00606000-00607000 rw-p 00006000 08:08 8391177                            /mnt/xdat/var/lib/docker/aufs/diff/ec85d4ebd7d191aaa045ef7ad63912d4335630b9badc2abd8f0e954797f9f548/bin/nc.traditional
0088d000-008ae000 rw-p 00000000 00:00 0                                  [heap]
7fbc999a5000-7fbc999b0000 r-xp 00000000 08:08 8655134                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/libnss_files-2.19.so
7fbc999b0000-7fbc99baf000 ---p 0000b000 08:08 8655134                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/libnss_files-2.19.so
7fbc99baf000-7fbc99bb0000 r--p 0000a000 08:08 8655134                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/libnss_files-2.19.so
7fbc99bb0000-7fbc99bb1000 rw-p 0000b000 08:08 8655134                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/libnss_files-2.19.so
7fbc99bb1000-7fbc99d50000 r-xp 00000000 08:08 8655136                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/libc-2.19.so
7fbc99d50000-7fbc99f50000 ---p 0019f000 08:08 8655136                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/libc-2.19.so
7fbc99f50000-7fbc99f54000 r--p 0019f000 08:08 8655136                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/libc-2.19.so
7fbc99f54000-7fbc99f56000 rw-p 001a3000 08:08 8655136                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/libc-2.19.so
7fbc99f56000-7fbc99f5a000 rw-p 00000000 00:00 0 
7fbc99f5a000-7fbc99f7a000 r-xp 00000000 08:08 8655151                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/ld-2.19.so
7fbc9a16e000-7fbc9a171000 rw-p 00000000 00:00 0 
7fbc9a178000-7fbc9a17a000 rw-p 00000000 00:00 0 
7fbc9a17a000-7fbc9a17b000 r--p 00020000 08:08 8655151                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/ld-2.19.so
7fbc9a17b000-7fbc9a17c000 rw-p 00021000 08:08 8655151                    /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/ld-2.19.so
7fbc9a17c000-7fbc9a17d000 rw-p 00000000 00:00 0 
7fff9273d000-7fff9275e000 rw-p 00000000 00:00 0                          [stack]
7fff927ff000-7fff92800000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

Thanks for the installation hand-holding!

oleavr commented 9 years ago

No worries! By the way, to get frida-trace running with 3.4, you'll have to install the colorama package from PyPI. (Your 2.7 installation already has this as you previously installed the frida package from there, and it depends on it.)

Regarding the dlopen() issue, it looks like you're running Frida and the target process inside a Docker container, right? Could you check if the following path is valid inside the Docker container: /mnt/xdat/var/lib/docker/aufs/diff/7ac40b0ba88f5f8629c8121162aa5aa7068436afde29e4887f25becfd317c6a7/lib/x86_64-linux-gnu/libc-2.19.so And if it isn't, is this path valid: /lib/x86_64-linux-gnu/libc-2.19.so I have a suspicion that /proc/$pid/maps reports the path as seen by the host/outside also when queried inside the container. If so, the easiest would probably be to dlopen the basename of that path:

diff --git a/src/linux/linjector-glue.c b/src/linux/linjector-glue.c
index fefa237..523ec18 100644
--- a/src/linux/linjector-glue.c
+++ b/src/linux/linjector-glue.c
@@ -912,7 +912,7 @@ frida_resolve_remote_linker_function (int remote_pid, gpointer func)
 static GumAddress
 frida_resolve_remote_library_function (int remote_pid, const gchar * library_name, const gchar * function_name)
 {
-  gchar * local_library_path, * remote_library_path;
+  gchar * local_library_path, * remote_library_path, * canonical_library_name;
   GumAddress local_base, remote_base, remote_address;
   gpointer module, local_address;

@@ -924,7 +924,9 @@ frida_resolve_remote_library_function (int remote_pid, const gchar * library_nam

   g_assert_cmpstr (local_library_path, ==, remote_library_path);

-  module = dlopen (local_library_path, RTLD_GLOBAL | RTLD_NOW);
+  canonical_library_name = g_path_get_basename (local_library_path);
+
+  module = dlopen (canonical_library_name, RTLD_GLOBAL | RTLD_NOW);
   g_assert (module != NULL);

   local_address = dlsym (module, function_name);
@@ -936,6 +938,7 @@ frida_resolve_remote_library_function (int remote_pid, const gchar * library_nam

   g_free (local_library_path);
   g_free (remote_library_path);
+  g_free (canonical_library_name);

   return remote_address;
 }

Just apply that patch to frida-core, and let me know if it works for you. (Untested, but should only be a matter of correcting a typo or two if it doesn't compile.)

Thanks for hanging in there! :)

shitsecurity commented 9 years ago

Fix confirmed! Marking issue closed. Thanks for your help. I really appreciate it. Best of luck.

oleavr commented 9 years ago

Fix pushed. Thank you so much for your help!