A comprehensive Flutter security plugin that provides advanced security features for your Flutter applications, including root detection, emulator detection, and various security checks.
-
π‘οΈ Advanced Root Detection
- Multiple detection layers
- Frida anti-tampering protection
- Magisk detection
- SuperSU detection
- Common root app detection
-
π± Emulator Detection
- Comprehensive emulator environment checks
- Build properties analysis
- Hardware characteristics verification
-
π Security Checks
- Development mode detection
- Mock location detection
- External storage checks
- Runtime integrity verification
- System tampering detection
Add this to your package's pubspec.yaml
file:
dependencies:
security_plus: ^3.0.1
1.Add the following permissions to your AndroidManifest.xml file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
</manifest>
2.Add permission_handler for runtime permission management:
dependencies:
permission_handler: ^10.4.3
Add the following to your Info.plist file:
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open to verify device security.</string>
import 'package:security_plus/security_plus.dart';
import 'package:permission_handler/permission_handler.dart';
Future<void> checkDeviceSecurity() async {
// Request location permission first
if (Platform.isAndroid) {
final status = await Permission.location.request();
if (!status.isGranted) {
// Handle permission denied
return;
}
}
// Perform security checks
try {
final isRooted = await SecurityPlus.isRooted;
final isEmulator = await SecurityPlus.isEmulator;
final isDevelopmentMode = await SecurityPlus.isDevelopmentModeEnable;
final isMockLocation = await SecurityPlus.isMockLocationEnabled;
final isExternalStorage = await SecurityPlus.isOnExternalStorage;
// Handle security check results
if (isRooted || isEmulator || isMockLocation) {
// Handle security risks
}
} catch (e) {
// Handle errors
}
}
try {
bool isRooted = await SecurityPlus.isRooted;
if (isRooted) {
// Handle rooted device
}
} catch (e) {
// Handle errors
}
try {
bool isEmulator = await SecurityPlus.isEmulator;
if (isEmulator) {
// Handle emulator detection
}
} catch (e) {
// Handle errors
}
try {
bool isDevelopmentMode = await SecurityPlus.isDevelopmentModeEnable;
if (isDevelopmentMode) {
// Handle development mode
}
} catch (e) {
// Handle errors
}
try {
bool isMockLocation = await SecurityPlus.isMockLocationEnabled;
if (isMockLocation) {
// Handle mock location
}
} catch (e) {
// Handle errors
}
try {
bool isOnExternalStorage = await SecurityPlus.isOnExternalStorage;
if (isOnExternalStorage) {
// Handle external storage detection
}
} catch (e) {
// Handle errors
}
The plugin employs multiple layers of root detection:
- RootBeer Integration: Uses the advanced RootBeer library for base root detection
- Frida Detection: Actively searches for Frida-related processes and libraries
- File System Checks: Scans for common root-related files and directories
- Package Analysis: Detects known root management applications
- Runtime Integrity: Checks for system modifications and hooks
- Process monitoring for known tampering tools
- Library injection detection
- System property verification
- Runtime integrity checks
Check out the example directory for a complete sample application demonstrating all features.
Android | iOS |
---|---|
β | π§ |
Contributions are welcome! If you find a bug or want a feature, please open an issue.
This project is licensed under the MIT License - see the LICENSE file for details.
Created and maintained by Abdelrahman Bonna.
- RootBeer - For root detection capabilities
- The Flutter team and community for their amazing work
This plugin provides security features but should not be considered as the sole security measure for your application. Always implement multiple layers of security and keep your security measures up to date.