frida--version# host version — the source of truth
adbshellgetpropro.product.cpu.abi# arm64-v8a | armeabi-v7a | x86_64 | x86
adbshell"cat /proc/$(adbshellpidof-s<pkg>)/maps"|grep-m1linker
# /system/bin/linker64 → 64-bit process /system/bin/linker → 32-bit
Do this one first, and read its output.frida-ps -U is not a proof the server works:
adbshell"su 0 /data/local/tmp/frida-server --version"# AVD form; Magisk: su -c '...'
CANNOT LINK EXECUTABLE … empty/missing DT_HASH/DT_GNU_HASH … (new hash type from the future?)
means the server binary is newer than the image's linker. Measured on sdk_gphone16k_x86_64,
Android 15 / API 35, x86_64. Not a root problem — su 0 id returns 0 — and frida-ps -U
still lists processes while it is happening. Match the build to the image, or use gadget.
Full disclosure: README §top.
frida-trace-U-f<pkg>-i"SSL_*"# native by name
frida-trace-U-n<pkg>-I"libnative.so"# whole module
frida-trace-U-f<pkg>-i"*"-x"malloc"-x"free"
frida-trace-U-f<pkg>-a"libnative.so!0x4a1c"# by offset
frida-trace-U-f<pkg>-j"com.example.crypto.*!*"# JAVA
frida-trace-U-f<pkg>-j"*!*decrypt*"
Handlers appear in __handlers__/ and hot-reload on save.
Java.perform(function(){/* everything Java goes in here */});Java.performNow(function(){/* when already on a VM thread */});Java.available// is there a VM?Java.androidVersion// "14"Java.vm.getEnv()// raw JNIEnv
// single overloadJava.use("com.x.C").m.implementation=function(a){returnthis.m(a);};// specific overload — REQUIRED when more than one existsJava.use("com.x.C").m.overload("java.lang.String","int").implementation=function(s,i){returnthis.m(s,i);};// constructorJava.use("com.x.C").$init.overload("java.lang.String").implementation=function(s){returnthis.$init(s);};// every overloadJava.use("com.x.C").m.overloads.forEach(ov=>{ov.implementation=function(){returnov.apply(this,arguments);};});// static method — same syntax; `this` is the class// revertJava.use("com.x.C").m.implementation=null;
consto=Java.use("com.x.C");o.staticField.value=42;// staticinst.instanceField.value;// instance, inside a hook: this.f.valueo.$className;// runtime class of an instance// name collision between a field and a method:inst._name.value// underscore prefix
consts=Java.use("com.x.C").$new("arg");// constructJava.cast(ptr(handle),Java.use("java.lang.Class"));// reinterpretJava.array("byte",[1,2,3]);// build a Java arrayJava.retain(obj);// keep past the callback
Java.enumerateLoadedClasses({onMatch(n){},onComplete(){}});Java.enumerateClassLoaders({onMatch(l){},onComplete(){}});Java.choose("com.x.C",{onMatch(i){/* return "stop" to end */},onComplete(){}});Java.ClassFactory.get(loader).use("com.x.C");// per-loader wrapperJava.classFactory.loader=loader;// global — SAVE AND RESTORE
constl=Interceptor.attach(addr,{onEnter(args){this.x=args[0];},// `this` persists to onLeaveonLeave(retval){retval.replace(ptr(0));}});l.detach();Interceptor.replace(addr,newNativeCallback(fn,"int",["pointer"]));Interceptor.revert(addr);Interceptor.detachAll();Interceptor.flush();// batch many hooks: one i-cache flush
Stalker.exclude(Process.getModuleByName("libc.so"));// do this FIRSTStalker.follow(tid,{events:{call:true,ret:false,exec:false,block:false,compile:false},onReceive(events){Stalker.parse(events,{annotate:true});},transform(iter){leti=iter.next();do{if(i.mnemonic==="cmp")iter.putCallout(ctx=>console.log(ctx.x0));iter.keep();// MANDATORY for every kept instructioni=iter.next();}while(i!==null);}});Stalker.unfollow(tid);Stalker.garbageCollect();Stalker.trustThreshold=-1;// never re-instrument (fastest)Stalker.trustThreshold=0;// always (self-modifying code)Stalker.queueCapacity=16384;
importfridadevice=frida.get_usb_device(timeout=10)device.enable_child_gating()device.on("child-added",lambdac:...)pid=device.spawn(["com.x"])session=device.attach(pid)script=session.create_script(open("_agent.js").read())script.on("message",lambdam,d:print(m,d))script.load()device.resume(pid)# AFTER load()script.exports_sync.my_fn(1)script.post({"type":"tag","value":1})script.unload();session.detach()
error thrown? ── ClassNotFound → loader
── overload → .overload()
no error, never fires?
respawn with -f → fires? → you were attaching
-m verify → fires? → ART inlining
in JADX? no → R8 inlining
yes → wrong process / dead code / native
LAST: detection (process DIES, not silent)
adbshellsettingsputglobalhttp_proxy:0
adbshellcmdpackagecompile--reset<pkg># BEFORE writing the finding up
adbshellamforce-stop<pkg>
adbshell"su -c 'pkill frida-server'"