Special compiler sets are used for binaries compiled to run on Android systems. We will use the package we named Android NDK here. It contains compilers for different architectures and different android versions. We will compile POC code using these compilers and run it using adb in vulnerable environment. Let’s download POC code with the help of the link below.
The NDK package we downloaded with the help of Android Studio is located under the “~/Android/Sdk/ndk/ndk_version” directory.
We use NDK toolchains to compile POC code or any native C/C++ code for Android platform. NDK offers us different compiler options in this regard. You can find these compiler options under “~/Android/Sdk/ndk/ndk_version/toolchains/llvm/prebuilt/linux-x86_64/bin“.
Since Android 10 is API 29 and emulator has x86_64 architecture, the compiler we will use here will be “x86_64-linux-android29-clang“.
Let’s compile the POC code
Now, it’s time to try the POC code on the custom vulnerable kernel.
Running the POC
Let’s run the following commands in the following order.