frida / frida-core

Frida core library intended for static linking into bindings
https://frida.re
Other
609 stars 193 forks source link

frida_injector_inject_library_file_sync usage problem #531

Closed etjson closed 3 months ago

etjson commented 4 months ago

I want to use the frida_injector_inject_library_file_sync usage problem to inject a so file into the target application and execute the JNI_OnLoad method. My implementation idea is this

First use frida_injector_inject_library_file_sync to load a so file with an entry method

FridaInjector *injector;
GError *error;
frida_init();
frida_selinux_patch_policy();
const char *context = "u:object_r:frida_file:s0";
setxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1, 0);
injector = frida_injector_new();
frida_injector_inject_library_file_sync(injector, 12345, "/data/adb/patch.so", "test", "", NULL, &error);
frida_injector_close_sync(injector, NULL, NULL);
frida_deinit();

Then get the current env in the test method

void test(const char *data) {
    JNIEnv *env = getCurrentEnv();
    jclass clazz = env->FindClass("java/lang/System");
    jmethodID methodID = env->GetStaticMethodID(clazz, "load", "(Ljava/lang/String;)V");
    env->CallStaticVoidMethod(clazz, methodID, env->NewStringUTF("/sdcard/Android/data/com.test/test.so"));
}

But the test.so file is not loaded. How to solve this problem?

@oleavr