w3connext / jailbreak_root_detection

https://pub.dev/packages/jailbreak_root_detection
MIT License
10 stars 9 forks source link

How to detect Frida from Flutter side? #4

Open vodemn opened 7 months ago

vodemn commented 7 months ago

How do I know, that Frida was detected? Also what does this plugin when it detects Frida? Does it crash the app?

kauemurakami commented 7 months ago

In my implementation it appeared

final checkForIssues = await JailbreakRootDetection.instance.checkForIssues;
print(checkForIssues);
I/AntiFridaChecker(17827): Frida running: false
I/AntiFridaChecker(17827): Frida running: false
I/AntiFridaChecker(17827): Frida running: false
I/flutter (17827): [JailbreakIssue.jailbreak, JailbreakIssue.notRealDevice] 

When you see the type of checkForIssues you will see that it is of the type Future<List<JailbreakIssue>>```` , when I entered the code ofJailbreakIssue```, I could see an if/ else that goes through all the problems that may arise. Here the list

static JailbreakIssue fromString(String value) {
    if (value == "jailbreak") {
      return JailbreakIssue.jailbreak;
    }
    if (value == "notRealDevice") {
      return JailbreakIssue.notRealDevice;
    }
    if (value == "proxied") {
      return JailbreakIssue.proxied;
    }
    if (value == "debugged") {
      return JailbreakIssue.debugged;
    }
    if (value == "reverseEngineered") {
      return JailbreakIssue.reverseEngineered;
    }
    if (value == "fridaFound") {
      return JailbreakIssue.fridaFound;
    }
    if (value == "cydiaFound") {
      return JailbreakIssue.cydiaFound;
    }
    if (value == "tampered") {
      return JailbreakIssue.tampered;
    }
    if (value == "onExternalStorage") {
      return JailbreakIssue.onExternalStorage;
    }

    return JailbreakIssue.unknown;
  }

With this you can retrieve the list of JailbreakIssue with ```await JailbreakRootDetection.instance.checkForIssues;```` and compare the enums. If the list contains [JailbreakIssue.fridaFound], you can take action on it. edit: i solve problem

edit 2 example

import 'package:jailbreak_root_detection/jailbreak_root_detection.dart';

detectFrida() async {
  final checkForIssues = await JailbreakRootDetection.instance.checkForIssues;
  print(checkForIssues); // output: [JailbreakIssue.jailbreak, JailbreakIssue.notRealDevice]
  final List<JailbreakIssue> jailbreakIssuesToCheck = [
    JailbreakIssue.debugged,
    JailbreakIssue.cydiaFound,
    JailbreakIssue.fridaFound,
    JailbreakIssue.proxied,
    JailbreakIssue.notRealDevice,
    JailbreakIssue.reverseEngineered,
    JailbreakIssue.jailbreak,
    JailbreakIssue.tampered
  ];
  final bool contains =
      jailbreakIssuesToCheck.any((issue) => checkForIssues.contains(issue));
     print('teste jailbreak ${contains.toString()}'); // test jailbreak true
}

I added the enums that interest me and compared them with the ones I retrieve. If I find one, I will return true later. To test, find the issues that apply to you and comment and you will see that the output will be false.

kauemurakami commented 7 months ago

But crash my app in prod :/ works only debug

arlakay commented 5 months ago

Hi, this is not work for me. can't detect frida 16.1.0 on flutter app, still able to inject script.js from frida. how to use this plugin properly?