added root and frida detection
This commit is contained in:
File diff suppressed because one or more lines are too long
35
lib/features/security/security_error_screen.dart
Normal file
35
lib/features/security/security_error_screen.dart
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:lottie/lottie.dart';
|
||||||
|
|
||||||
|
class SecurityErrorScreen extends StatelessWidget {
|
||||||
|
final String message;
|
||||||
|
|
||||||
|
const SecurityErrorScreen({Key? key, required this.message}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(20.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Lottie.asset('assets/animations/error.json', height: 200),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
message,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () => SystemChannels.platform.invokeMethod('SystemNavigator.pop'),
|
||||||
|
child: const Text('Okay'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:kmobile/features/security/security_error_screen.dart';
|
||||||
|
import 'package:kmobile/security/security_service.dart';
|
||||||
import 'di/injection.dart';
|
import 'di/injection.dart';
|
||||||
import 'app.dart';
|
import 'app.dart';
|
||||||
|
|
||||||
@@ -12,6 +14,15 @@ void main() async {
|
|||||||
DeviceOrientation.portraitDown,
|
DeviceOrientation.portraitDown,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Check for device compromise
|
||||||
|
final compromisedMessage = await SecurityService.deviceCompromisedMessage;
|
||||||
|
if (compromisedMessage != null) {
|
||||||
|
runApp(MaterialApp(
|
||||||
|
home: SecurityErrorScreen(message: compromisedMessage),
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize dependencies
|
// Initialize dependencies
|
||||||
await setupDependencies();
|
await setupDependencies();
|
||||||
runApp(const KMobile());
|
runApp(const KMobile());
|
||||||
|
31
lib/security/security_service.dart
Normal file
31
lib/security/security_service.dart
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:jailbreak_root_detection/jailbreak_root_detection.dart';
|
||||||
|
|
||||||
|
class SecurityService {
|
||||||
|
static Future<String?> get deviceCompromisedMessage async {
|
||||||
|
final isNotTrust = await JailbreakRootDetection.instance.isNotTrust;
|
||||||
|
if (isNotTrust) {
|
||||||
|
return 'Your device is rooted or jailbroken. For security reasons, you cannot access our services on a compromised device.';
|
||||||
|
}
|
||||||
|
|
||||||
|
final isRealDevice = await JailbreakRootDetection.instance.isRealDevice;
|
||||||
|
if (!isRealDevice) {
|
||||||
|
return 'Emulators are not allowed to access our services. Please use a real device.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
try {
|
||||||
|
final isOnExternalStorage =
|
||||||
|
await JailbreakRootDetection.instance.isOnExternalStorage;
|
||||||
|
if (isOnExternalStorage) {
|
||||||
|
return 'The application cannot be run from external storage.';
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@@ -357,6 +357,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.20.2"
|
version: "0.20.2"
|
||||||
|
jailbreak_root_detection:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: jailbreak_root_detection
|
||||||
|
sha256: c611229940a09785bd686364e92a40b07724926d2496c931527805101eb3da86
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.6"
|
||||||
js:
|
js:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@@ -36,6 +36,7 @@ dependencies:
|
|||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.6
|
cupertino_icons: ^1.0.6
|
||||||
|
jailbreak_root_detection: ^1.1.6
|
||||||
equatable: ^2.0.7
|
equatable: ^2.0.7
|
||||||
dio: ^5.8.0+1
|
dio: ^5.8.0+1
|
||||||
flutter_secure_storage: ^9.2.4
|
flutter_secure_storage: ^9.2.4
|
||||||
|
Reference in New Issue
Block a user