darvincisec / DetectFrida

Detect Frida for Android
MIT License
665 stars 138 forks source link

While integrating code to other project getting this Path issue. #32

Closed erpriyeshpanchal closed 1 year ago

erpriyeshpanchal commented 1 year ago
    Build command failed.

Error while executing process C:\Users\Priyesh\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\ninja.exe with arguments {-C D:\Novopay\novopay-platform-digi-distribution-app\app.cxx\Debug\6g1o2x5t\armeabi-v7a native-lib} ninja: Entering directory `D:\Novopay\novopay-platform-digi-distribution-app\app.cxx\Debug\6g1o2x5t\armeabi-v7a' [1/2] Building C object CMakeFiles/native-lib.dir/native-lib.c.o [2/2] Linking C shared library D:\Novopay\novopay-platform-digi-distribution-app\app\build\intermediates\cxx\Debug\6g1o2x5t\obj\armeabi-v7a\libnative-lib.so FAILED: D:/Novopay/novopay-platform-digi-distribution-app/app/build/intermediates/cxx/Debug/6g1o2x5t/obj/armeabi-v7a/libnative-lib.so cmd.exe /C "cd . && C:\Users\Priyesh\AppData\Local\Android\Sdk\ndk\20.1.5948944\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=armv7-none-linux-androideabi21 --gcc-toolchain=C:/Users/Priyesh/AppData/Local/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/Priyesh/AppData/Local/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -march=armv7-a -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -shared -Wl,-soname,libnative-lib.so -o D:\Novopay\novopay-platform-digi-distribution-app\app\build\intermediates\cxx\Debug\6g1o2x5t\obj\armeabi-v7a\libnative-lib.so CMakeFiles/native-lib.dir/native-lib.c.o -llog -latomic -lm && cmd.exe /C "cd /D D:\Novopay\novopay-platform-digi-distribution-app\app.cxx\Debug\6g1o2x5t\armeabi-v7a && C:\Users\Priyesh\AppData\Local\Android\Sdk\ndk\20.1.5948944\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-strip -R .comment -g -S -d --strip-unneeded D:/Novopay/novopay-platform-digi-distribution-app/app/src/main/c/../../../build/intermediates/cmake/Debug/obj/armeabi-v7a/libnative-lib.so"" C:\Users\Priyesh\AppData\Local\Android\Sdk\ndk\20.1.5948944\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-strip: 'D:/Novopay/novopay-platform-digi-distribution-app/app/src/main/c/../../../build/intermediates/cmake/Debug/obj/armeabi-v7a/libnative-lib.so': No such file ninja: build stopped: subcommand failed.

@patuoynageek @darvincisec can you give suggestions how to resolve this issue. I am trying to add this C module in another project. TIA

Originally posted by @erpriyeshpanchal in https://github.com/darvincisec/DetectFrida/issues/20#issuecomment-1369656200

erpriyeshpanchal commented 1 year ago

In my case fixed this issue by changing the path in add_custom_command in CMakeList.txt

FROM :

add_custom_command( TARGET native-lib
        POST_BUILD
        COMMAND "${ANDROID_TOOLCHAIN_PREFIX}strip" -R .comment -g -S -d --strip-unneeded ${CMAKE_HOME_DIRECTORY}/../../../build/intermediates/cmake/${CMAKE_BUILD_TYPE}/obj/${ANDROID_ABI}/libnative-lib.so
        COMMENT "Stripped native library")

TO :

add_custom_command( TARGET native-lib
        POST_BUILD
        COMMAND "${ANDROID_TOOLCHAIN_PREFIX}strip" -R .comment -g -S -d --strip-unneeded ${CMAKE_HOME_DIRECTORY}/../../../build/intermediates/cxx/${CMAKE_BUILD_TYPE}/6g1o2x5t/obj/${ANDROID_ABI}/libnative-lib.so
        COMMENT "Stripped native library")
darvincisec commented 1 year ago

Explicit strip command is not really required. I introduced it for removing specific sections in the binary, which is an optional step. As part of building the apk, there is a gradle task that will strip all the native libraries.

erpriyeshpanchal commented 1 year ago

@darvincisec so suppose if i remove the above line of codes it will not affect anything? also do i have to write anything in build.gradle or somewhere else for strip all the native libraries if i remove that add_custom_commandcode ?

darvincisec commented 1 year ago

No need to do anything if you remove add_custom_command code

erpriyeshpanchal commented 1 year ago

Okay, Thank you so much @darvincisec, i am seeking one more help from you where all i have to add code to crash the app or finish the app when frida is detected ?

erpriyeshpanchal commented 1 year ago

wherever __android_log_print is called should i add code for crashing the app ?

darvincisec commented 1 year ago

Search for logs containing text "Act now". You can introduce crash code in the place of the logs.