Inject a shared library into a process using ptrace
Inject a shared library into a process using ptrace
AndKittyInjector is a modern ptrace-based Android shared-library injector, built on top of KittyMemoryEx.
Requires C++17 or newer.
Inject from /data on Android.
dladdr & dl_iterate_phdr)Make sure to chmod +x or 755 the pushed binary.
…One of --pid or --package is required. --libs accepts one or more paths and each is injected in order.
…KittyInjector can be used directly instead of through the CLI, e.g. from your own tool:
…inject_elf_config_t also exposes beforeEntryPoint / afterEntryPoint callbacks (invoked around the remote JNI_OnLoad call) if you need to run code between attach and detach.
JNI_OnLoad instead:extern "C" jint JNIEXPORT JNI_OnLoad(JavaVM* vm, void *key)
{
// key 1337 is passed by the injector to confirm this call came from it.
if (key != (void*)1337)
return JNI_VERSION_1_6;
KITTY_LOGI("JNI_OnLoad called by injector.");
JNIEnv *env = nullptr;
if (vm->GetEnv((void**)&env, JNI_VERSION_1_6) == JNI_OK)
{
KITTY_LOGI("JavaEnv: %p.", env);
// ...
}
std::thread(thread_function).detach();
return JNI_VERSION_1_6;
}--launch or --watch to inject as soon as the target app launches, you may also need --bp-ld / --bp-sym or --delay, especially when injecting into an emulated (cross-ISA) library.NDK_HOME to point to your NDK folder.git clone --recursive https://github.com/MJx0/AndKittyInjector.git
cd AndKittyInjector/AndKittyInjector
./build.sh # or build.bat on Windows--recursive is required for KittyMemoryEx.
No open issues yet, or sync has not completed.