|
196 | 196 | }
|
197 | 197 |
|
198 | 198 | function bypassJavaFileCheck() {
|
| 199 | + function isRootIndicatorFile(file) { |
| 200 | + const path = file.getAbsolutePath(); |
| 201 | + const filename = file.getName(); |
| 202 | + return ROOT_INDICATORS.paths.has(path) || |
| 203 | + path.includes("magisk") || |
| 204 | + filename === "su"; |
| 205 | + } |
| 206 | + |
199 | 207 | const UnixFileSystem = Java.use("java.io.UnixFileSystem");
|
200 | 208 | UnixFileSystem.checkAccess.implementation = function(file, access) {
|
201 |
| - const filename = file.getAbsolutePath(); |
202 |
| - if (ROOT_INDICATORS.paths.has(filename) || filename.includes("magisk") || filename.includes("su")) { |
| 209 | + if (isRootIndicatorFile(file)) { |
203 | 210 | if (DEBUG_MODE) {
|
204 |
| - console.debug(`Blocked possible root detection: filesystem access check for ${filename}`); |
| 211 | + console.debug(`Blocked possible root detection: filesystem access check for ${file.getAbsolutePath()}`); |
205 | 212 | } else logFirstRootDetection();
|
206 | 213 | return false;
|
207 | 214 | }
|
|
210 | 217 |
|
211 | 218 | const File = Java.use("java.io.File");
|
212 | 219 | File.exists.implementation = function() {
|
213 |
| - const filename = this.getAbsolutePath(); |
214 |
| - if (ROOT_INDICATORS.paths.has(filename) || filename.includes("magisk") || filename.includes("su")) { |
| 220 | + if (isRootIndicatorFile(this)) { |
215 | 221 | if (DEBUG_MODE) {
|
216 |
| - console.debug(`Blocked possible root detection: file exists check for ${filename}`); |
| 222 | + console.debug(`Blocked possible root detection: file exists check for ${this.getAbsolutePath()}`); |
217 | 223 | } else logFirstRootDetection();
|
218 | 224 | return false;
|
219 | 225 | }
|
220 | 226 | return this.exists();
|
221 | 227 | };
|
222 | 228 |
|
223 | 229 | File.length.implementation = function() {
|
224 |
| - const filename = this.getAbsolutePath(); |
225 |
| - if (ROOT_INDICATORS.paths.has(filename) || filename.includes("magisk") || filename.includes("su")) { |
| 230 | + if (isRootIndicatorFile(this)) { |
226 | 231 | if (DEBUG_MODE) {
|
227 |
| - console.debug(`Blocked possible root detection: file length check for ${filename}`); |
| 232 | + console.debug(`Blocked possible root detection: file length check for ${this.getAbsolutePath()}`); |
228 | 233 | } else logFirstRootDetection();
|
229 | 234 | return 0;
|
230 | 235 | }
|
|
233 | 238 |
|
234 | 239 | const FileInputStream = Java.use("java.io.FileInputStream");
|
235 | 240 | FileInputStream.$init.overload('java.io.File').implementation = function(file) {
|
236 |
| - const path = file.getAbsolutePath(); |
237 |
| - const filename = file.getName(); |
238 |
| - if (ROOT_INDICATORS.paths.has(path) || path.includes("magisk") || filename.includes("su")) { |
| 241 | + if (isRootIndicatorFile(file)) { |
239 | 242 | if (DEBUG_MODE) {
|
240 |
| - console.debug(`Blocked possible root detection: file stream for ${path}`); |
| 243 | + console.debug(`Blocked possible root detection: file stream for ${file.getAbsolutePath()}`); |
241 | 244 | } else logFirstRootDetection();
|
242 |
| - throw Java.use("java.io.FileNotFoundException").$new(path); |
| 245 | + throw Java.use("java.io.FileNotFoundException").$new(file.getAbsolutePath()); |
243 | 246 | }
|
244 | 247 | return this.$init(file);
|
245 | 248 | };
|
|
0 commit comments