Bypass Root Detection
Last updated
Last updated
To understand root detection, we must first understand what rootage is. Rooting is the process of obtaining the highest privileges possible on the operating system. In the case of Android, rooting allows you to change or replace applications, files and system settings, and run specialized applications ("apps") that require administrator-level permissions. Root detection is the process of detecting whether a device is rooted. This is usually done when the application is launched. Sometimes root checks are implemented in applications such that the application will not respond or exit when running on a rooted device.
Resources :
Convert the apk file into class files using dex2jar
Analyse the class files and identify which library is being used for the root detection (for example, de.cyberkatze.iroot)
Connect the app with objection : objection -g βcom.package.androidβ explore
Execute in objection : android hooking list class_methods <root detection class>
2. Change return value for the method in charge of Root Detection : android hooking set return_value <root_detect_class.method> false
For de.cyberkatze.iroot, in objection :
android hooking list class_methods de.cyberkatze.iroot.IRoot
Change return value for the method : android hooking set return_value de.cyberkatze.iroot.IRoot.isDeviceRooted false
Decompile the apk file using JADX-GUI or any other alternative.
Identify the code which is in charge of the root detection process
If the library rootbear is used and there is an 'if' condition to verify if the device is rooted or not :
Decompile the apk with apktool : ``apktool d app.apk -o app-decompile```
Find the SMALI code for the 'if' statement (can look like this) : if-eqz v0, :cond_0
Change it by : if-nez v0, :cond_0
Save the file and rebuild the application : apktool b app-decompile -o app-root-patch.apk
Sign the application (see '## Decompile/Compile Source Code
)
Re-install the application on the android device
Allows to bypass root and emulator detection. Can also bypass the RootBeer detection mechanism.
Download Magisk.apk : https://github.com/topjohnwu/Magisk/releases
Launch it in your device : Allow SuperUser access
Enable MagiskHide : Magisk App > Settings > Magisk > Magisk Hide (enable)
Choose the application in which we will hide the root