darvincisec / DetectFrida

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

How to implement the detection on my current project? #24

Closed kevinlee-app closed 2 years ago

kevinlee-app commented 2 years ago

Hi,

First of all I would like to thank you for your post about Frida detection. I would like to implement this on my current project to detect Frida and add some logic if it detects Frida. Is there any example or README on how I can implement it?

Thanks.

kevinlee-app commented 2 years ago

I tried to clone and run this repository there is error on the build output

Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process C:\Users\KELEE\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\ninja.exe with arguments {-C C:\Dev\APKTools\DetectFrida-master\app\.cxx\cmake\debug\x86_64 native-lib}
  ninja: Entering directory `C:\Dev\APKTools\DetectFrida-master\app\.cxx\cmake\debug\x86_64'
  [1/2] Building C object CMakeFiles/native-lib.dir/native-lib.c.o
  FAILED: CMakeFiles/native-lib.dir/native-lib.c.o 
  C:\Dev\APKTools\DetectFrida-master\app\src\main\c\..\..\..\..\..\o-llvm-binary\ollvm-tll\build\bin_Darwin\clang --target=x86_64-none-linux-android21 --gcc-toolchain=C:/Users/KELEE/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/KELEE/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot -D_64_BIT -Dnative_lib_EXPORTS -IC:/Dev/APKTools/DetectFrida-master/app/src/main/c/arch/x86_64 -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -mllvm -sub -mllvm -bcf -mllvm -fla -O0 -fno-limit-debug-info  -fPIC -MD -MT CMakeFiles/native-lib.dir/native-lib.c.o -MF CMakeFiles\native-lib.dir\native-lib.c.o.d -o CMakeFiles/native-lib.dir/native-lib.c.o   -c C:/Dev/APKTools/DetectFrida-master/app/src/main/c/native-lib.c
  CreateProcess failed: The system cannot find the file specified.
  ninja: build stopped: subcommand failed.
sedayux commented 2 years ago

I tried to clone and run this repository there is error on the build output

Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process C:\Users\KELEE\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\ninja.exe with arguments {-C C:\Dev\APKTools\DetectFrida-master\app\.cxx\cmake\debug\x86_64 native-lib}
  ninja: Entering directory `C:\Dev\APKTools\DetectFrida-master\app\.cxx\cmake\debug\x86_64'
  [1/2] Building C object CMakeFiles/native-lib.dir/native-lib.c.o
  FAILED: CMakeFiles/native-lib.dir/native-lib.c.o 
  C:\Dev\APKTools\DetectFrida-master\app\src\main\c\..\..\..\..\..\o-llvm-binary\ollvm-tll\build\bin_Darwin\clang --target=x86_64-none-linux-android21 --gcc-toolchain=C:/Users/KELEE/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/KELEE/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot -D_64_BIT -Dnative_lib_EXPORTS -IC:/Dev/APKTools/DetectFrida-master/app/src/main/c/arch/x86_64 -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -mllvm -sub -mllvm -bcf -mllvm -fla -O0 -fno-limit-debug-info  -fPIC -MD -MT CMakeFiles/native-lib.dir/native-lib.c.o -MF CMakeFiles\native-lib.dir\native-lib.c.o.d -o CMakeFiles/native-lib.dir/native-lib.c.o   -c C:/Dev/APKTools/DetectFrida-master/app/src/main/c/native-lib.c
  CreateProcess failed: The system cannot find the file specified.
  ninja: build stopped: subcommand failed.

as far as I know ollvm is great for obfuscating, but still i don't know how to setup, so I remark that on CMakeList.txt

darvincisec commented 2 years ago

@kevinlee-app and @sedayux, OLLVM binary for Window is not provided in my other repo. Try using Mac to build the app.

Reg. how to integrate, each of the detections are discrete functions that you can call it from your native code. I believe the functions are self explanatory.