Everything we learned was related to hooking methods of Dalvik Virtual Machine in Java. The Android NDK (Native Development Kit) is a toolset provided by Google that allows developers to write native code in C/C++ for Android applications.
Some applications require high performance or low-level access to system resources, which may be difficult to achieve using Java alone. In such cases, the NDK can be used to write native code that can be compiled into machine code and run directly on the device's CPU
Using the NDK can be beneficial for applications that require high performance, such as games or media applications, or for applications that need to access low-level system resources. However, it's important to note that using the NDK can also introduce additional complexity and may require more time and effort to develop and maintain compared to using Java alone.
In android it’s really easy to find them. The first sign you find is System.loadLibrary("native-lib"). This load the library in memory. Then you seen function like this:
public native String encryptString(String secretMessage)
Example native code:
#include<jni.h>
#include<string>
extern "C" JNIEXPORT jstring JNICALL
Java_com_apphacking_ndkfrida_MainActivity_encryptString(
JNIEnv* env, jobject, jstring secretMessage){
return env->NewStringUTF("hello".c_str());
}
env → This is an pointer to all important functions like NewStringUTF which developers require. Usually used for type casting.
jobject → This is an pointer to java object instance.
Module.enumerateExports("libnativesecret.so")

let exportedFunctions = Module.enumerateExports("libnativesecret.so")
exportedFunctions.forEach(func => {
if(func.name.indexOf("Java_") != -1){
send(func)
}
});

Module.enumerateImports("libnativesecret.so")
