Patching Android ARM64 library initializers for easy Frida i... #1512
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤖 Automated Content Update
This PR was automatically generated by the HackTricks News Bot based on a technical blog post.
📝 Source Information
🎯 Content Summary
What the post delivers
A step‑by‑step, copy‑pasteable method to neutralize Android ARM64 shared library constructors that run via .init_array (commonly abused by RASP for early detections) by: (1) removing INIT_ARRAY/INIT_ARRAYSZ from the DYNAMIC table so they don’t auto‑execute, (2) exposing the hidden constructor as a normal exported function (INIT0), (3) renaming JNI_OnLoad→JNI_OnLoad0 to prevent implicit ART calls, and (4) spinning up a minimal ART/JNI with JNIInvocation to invoke...
🔧 Technical Details
Make implicit constructors explicit: On Android ARM64, .init_array entries are filled by
R_AARCH64_RELATIVErelocations whose addend is the target function. Locate the relocation inside.init_arrayviareadelf --relocs; the addend (e.g.,0xa34or0x954) is the constructor. RemoveINIT_ARRAY/INIT_ARRAYSZfrom the DYNAMIC table so the loader won’t auto-execute it, then add a GLOBAL FUNC symbol (e.g.,INIT0) at that address with LIEF so you can call it on demand.Prevent implicit JNI initialization: Rename
JNI_OnLoad→JNI_OnLoad0in the symbol table. This stops ART from calling it implicitly. After attaching Frida/lldb and patching early checks, invokeJNI_OnLoad0(vm)yourself.Standalone ART harness for repeatable testing: Use