Client-side root detection is a cost function, not a boundary. The only control with evidence from
outside the attacker's territory is server-verified attestation (§3.15).
/system or / mounted rw
tmpfs on /sbin, /system/bin, /system/xbin, /debug_ramdisk
overlay|overlayfs on /system*
/dev/block/loop* mounted under /system
/data/adb present at all
// Java: deny only root-flavoured paths (blanket false breaks the app)Java.perform(function(){varF=Java.use("java.io.File"),B=/su$|busybox|magisk|superuser|\/sbin\/|\/data\/adb/i;F.exists.implementation=function(){varp=this.getAbsolutePath();returnB.test(p)?false:this.exists();};});// Java: hide root manager packages — hook the CONCRETE classJava.perform(function(){varPM=Java.use("android.app.ApplicationPackageManager"),E=Java.use("android.content.pm.PackageManager$NameNotFoundException");PM.getPackageInfo.overloads.forEach(function(o){o.implementation=function(n){if(/magisk|supersu|superuser|rootcloak|xposed/i.test(n))throwE.$new(""+n);returno.apply(this,arguments);};});});// Java: spoof propertiesJava.perform(function(){varS={"ro.build.tags":"release-keys","ro.debuggable":"0","ro.secure":"1","ro.boot.verifiedbootstate":"green","ro.boot.flash.locked":"1"};varSP=Java.use("android.os.SystemProperties");SP.get.overload("java.lang.String").implementation=function(k){return(kinS)?S[k]:this.get(k);};Java.use("android.os.Build").TAGS.value="release-keys";});// Native: deny access() with a correct errnovarENOENT=2,en=newNativeFunction(Module.getExportByName("libc.so","__errno"),'pointer',[]);vara=Module.findExportByName("libc.so","access");if(a)Interceptor.attach(a,{onEnter:function(g){this.p=g[0].readUtf8String();},onLeave:function(r){if(/su$|magisk|busybox/i.test(this.p||"")){en().writeS32(ENOENT);r.replace(ptr(-1));}}});// Native: safe path substitution — allocate, never overwrite in placevarclean=Memory.allocUtf8String("/data/local/tmp/mounts.clean");varo=Module.findExportByName("libc.so","openat");if(o)Interceptor.attach(o,{onEnter:function(g){varp=g[1].readUtf8String();if(p==="/proc/self/mounts"||p==="/proc/mounts")g[1]=clean;}});// Remove the consequence instead of the checkJava.perform(function(){Java.use("android.app.Activity").finish.implementation=function(){};Java.use("java.lang.System").exit.implementation=function(c){console.log("[block] exit("+c+")");};Java.use("android.os.Process").killProcess.implementation=function(p){};});// Library not mapped yet — install hooks from dlopenvard=Module.findExportByName(null,"android_dlopen_ext");if(d)Interceptor.attach(d,{onEnter:function(a){this.p=a[0].readUtf8String();},onLeave:function(){if(this.p&&this.p.indexOf("libintegrity.so")!==-1)installNativeHooks();}});// Find the aggregation point: one hook beats twentyJava.perform(function(){Java.enumerateLoadedClasses({onMatch:function(n){if(/root|integrity|security|tamper/i.test(n))console.log(n);},onComplete:function(){}});});
// Java surface["isRooted","isRootedWithBusyBoxCheck","isRootedWithoutBusyBoxCheck","detectRootManagementApps","detectPotentiallyDangerousApps","detectRootCloakingApps","checkForSuBinary","checkForBusyBoxBinary","checkForDangerousProps","checkForRWPaths","detectTestKeys","checkSuExists","checkForRootNative","checkForMagiskBinary"]// Native anchor — survives R8, resolved by name at runtimeJava_com_scottyab_rootbeer_RootBeerNative_checkForRoot
// frida — same patch at runtime, no re-signingvart=Module.findBaseAddress("libintegrity.so").add(0x12a40);Memory.patchCode(t,8,function(p){varw=newArm64Writer(p,{pc:t});w.putMovRegU64('x0',0);w.putRet();w.flush();});