MASTG-DEMO-0088: Runtime Detection of Root Detection Mechanisms
Download MASTG-DEMO-0088 APK Open MASTG-DEMO-0088 Folder Build MASTG-DEMO-0088 APK
Sample¶
This demo shows how to detect root detection mechanisms at runtime using Frooky. The sample app from Uses of Root Detection Techniques with Semgrep implements multiple root detection checks.
| ../MASTG-DEMO-0087/MastgTest.kt | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
Steps¶
- Ensure the target app is installed on the device and frida-server is running.
- Run Frooky with the hooks configuration to monitor root detection methods.
| run.sh | |
|---|---|
1 2 | |
The hooks configuration monitors common root detection methods:
| hooks.json | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
Observation¶
The output shows all root detection method invocations captured during app execution.
| output.json | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
Evaluation¶
The test passes because the output confirms the app implements root detection checks that were monitored at runtime:
-
java.io.File.<init>calls forsupath checks:- From
MastgTest.checkForSuBinary()at line 61. - The app checks for 10
subinary locations such as/system/app/Superuser.apk,/sbin/su,/system/bin/su,/system/xbin/su, etc. - Additional constructor calls from libraries like
androidx.profileinstaller.ProfileInstallermay appear in the trace but are not related to root detection.
- From
-
Runtime.execcalls forwhich sucommand:- From
MastgTest.checkForWhichSu()at line 81. - The app executes the
which sucommand to detect if thesubinary is available in the system PATH.
- From
-
PackageManager.getPackageInfocalls for root packages:- From
MastgTest.checkForRootPackagesat line 133. - The app checks for 12 root management packages including
com.topjohnwu.magisk,eu.chainfire.supersu, etc. In the captured output, the relevantgetPackageInfocalls throwNameNotFoundExceptionas expected since none of these packages are installed. - Additional
getPackageInfocalls from system or library components may appear in the trace but are unrelated to root detection.
- From
-
Runtime.execcalls for system property checks:- From
MastgTest.getSystemPropertyat line 181, called bycheckForDangerousProps. - The app executes
getprop ro.debuggableandgetprop ro.securecommands to read system properties.
- From