@akilrafeek/capacitor-jailbreak-root-detection 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MeedikaCapacitorJailbreakRootDetection.podspec +17 -0
- package/README.md +78 -0
- package/android/build.gradle +59 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/evehr/plugins/capacitor/jailbreakrootdetection/CapacitorJailbreakRootDetection.java +17 -0
- package/android/src/main/java/com/evehr/plugins/capacitor/jailbreakrootdetection/CapacitorJailbreakRootDetectionPlugin.java +66 -0
- package/android/src/main/java/com/evehr/plugins/capacitor/jailbreakrootdetection/Rooted/CheckApiVersion.java +5 -0
- package/android/src/main/java/com/evehr/plugins/capacitor/jailbreakrootdetection/Rooted/EmulatorDetector.java +162 -0
- package/android/src/main/java/com/evehr/plugins/capacitor/jailbreakrootdetection/Rooted/GreaterThan23.java +44 -0
- package/android/src/main/java/com/evehr/plugins/capacitor/jailbreakrootdetection/Rooted/LessThan23.java +50 -0
- package/android/src/main/java/com/evehr/plugins/capacitor/jailbreakrootdetection/Rooted/RootedCheck.java +89 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +78 -0
- package/dist/esm/definitions.d.ts +9 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +8 -0
- package/dist/esm/web.js +22 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +38 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +41 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/CapacitorJailbreakRootDetection.swift +18 -0
- package/ios/Plugin/CapacitorJailbreakRootDetectionPlugin.h +10 -0
- package/ios/Plugin/CapacitorJailbreakRootDetectionPlugin.m +11 -0
- package/ios/Plugin/CapacitorJailbreakRootDetectionPlugin.swift +37 -0
- package/ios/Plugin/Info.plist +28 -0
- package/ios/Plugin/UIDeviceJailBroken.swift +100 -0
- package/package.json +344 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'MeedikaCapacitorJailbreakRootDetection'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @meedika/capacitor-jailbreak-root-detection
|
|
2
|
+
|
|
3
|
+
This is a Capacitor 6 Jailbreak Root detection plugin.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @meedika/capacitor-jailbreak-root-detection
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
<docgen-index>
|
|
15
|
+
|
|
16
|
+
* [`isJailbrokenOrRooted()`](#isjailbrokenorrooted)
|
|
17
|
+
* [`isSimulator()`](#issimulator)
|
|
18
|
+
* [`isDebuggedMode()`](#isdebuggedmode)
|
|
19
|
+
* [`exitApp()`](#exitapp)
|
|
20
|
+
* [Interfaces](#interfaces)
|
|
21
|
+
|
|
22
|
+
</docgen-index>
|
|
23
|
+
|
|
24
|
+
<docgen-api>
|
|
25
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
26
|
+
|
|
27
|
+
### isJailbrokenOrRooted()
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
isJailbrokenOrRooted() => Promise<JailbreakRootResult>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Returns:** <code>Promise<<a href="#jailbreakrootresult">JailbreakRootResult</a>></code>
|
|
34
|
+
|
|
35
|
+
--------------------
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### isSimulator()
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
isSimulator() => Promise<JailbreakRootResult>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Returns:** <code>Promise<<a href="#jailbreakrootresult">JailbreakRootResult</a>></code>
|
|
45
|
+
|
|
46
|
+
--------------------
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### isDebuggedMode()
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
isDebuggedMode() => Promise<JailbreakRootResult>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Returns:** <code>Promise<<a href="#jailbreakrootresult">JailbreakRootResult</a>></code>
|
|
56
|
+
|
|
57
|
+
--------------------
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### exitApp()
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
exitApp() => void
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
--------------------
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
### Interfaces
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
#### JailbreakRootResult
|
|
73
|
+
|
|
74
|
+
| Prop | Type |
|
|
75
|
+
| ------------ | -------------------- |
|
|
76
|
+
| **`result`** | <code>boolean</code> |
|
|
77
|
+
|
|
78
|
+
</docgen-api>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.2.1'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "com.evehr.plugins.capacitor.jailbreakrootdetection"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
implementation 'com.scottyab:rootbeer-lib:0.1.1'
|
|
56
|
+
testImplementation "junit:junit:$junitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
58
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
59
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.evehr.plugins.capacitor.jailbreakrootdetection;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
5
|
+
public class CapacitorJailbreakRootDetection {
|
|
6
|
+
public boolean isJailbrokenOrRooted(boolean value) {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public boolean isSimulator(boolean value) {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public boolean isDebuggedMode(boolean value) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package com.evehr.plugins.capacitor.jailbreakrootdetection;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
import com.getcapacitor.Plugin;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
import com.getcapacitor.PluginMethod;
|
|
7
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
+
|
|
9
|
+
import android.content.Context;
|
|
10
|
+
|
|
11
|
+
import com.evehr.plugins.capacitor.jailbreakrootdetection.Rooted.RootedCheck;
|
|
12
|
+
import com.evehr.plugins.capacitor.jailbreakrootdetection.Rooted.EmulatorDetector;
|
|
13
|
+
|
|
14
|
+
@CapacitorPlugin(name = "CapacitorJailbreakRootDetection")
|
|
15
|
+
public class CapacitorJailbreakRootDetectionPlugin extends Plugin {
|
|
16
|
+
private CapacitorJailbreakRootDetection implementation = new CapacitorJailbreakRootDetection();
|
|
17
|
+
private RootedCheck rootedCheck;
|
|
18
|
+
private EmulatorDetector emulatorDetector;
|
|
19
|
+
|
|
20
|
+
@Override
|
|
21
|
+
public void load() {
|
|
22
|
+
rootedCheck = new RootedCheck(getContext());
|
|
23
|
+
emulatorDetector = new EmulatorDetector(getContext());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@PluginMethod
|
|
27
|
+
public void isJailbrokenOrRooted(PluginCall call) {
|
|
28
|
+
boolean result = rootedCheck.isJailBroken();
|
|
29
|
+
|
|
30
|
+
JSObject ret = new JSObject();
|
|
31
|
+
ret.put("result", implementation.isJailbrokenOrRooted(result));
|
|
32
|
+
call.resolve(ret);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@PluginMethod
|
|
37
|
+
public void isSimulator(PluginCall call) {
|
|
38
|
+
boolean result = emulatorDetector.isEmulator();
|
|
39
|
+
|
|
40
|
+
JSObject ret = new JSObject();
|
|
41
|
+
ret.put("result", implementation.isSimulator(result));
|
|
42
|
+
call.resolve(ret);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@PluginMethod
|
|
47
|
+
public void isDebuggedMode(PluginCall call) {
|
|
48
|
+
boolean result = emulatorDetector.isDebuggedMode();
|
|
49
|
+
|
|
50
|
+
JSObject ret = new JSObject();
|
|
51
|
+
ret.put("result", implementation.isDebuggedMode(result));
|
|
52
|
+
call.resolve(ret);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@PluginMethod
|
|
56
|
+
public void exitApp(PluginCall call) {
|
|
57
|
+
unsetAppListeners();
|
|
58
|
+
call.resolve();
|
|
59
|
+
getBridge().getActivity().finish();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private void unsetAppListeners() {
|
|
63
|
+
bridge.getApp().setStatusChangeListener(null);
|
|
64
|
+
bridge.getApp().setAppRestoredListener(null);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
package com.evehr.plugins.capacitor.jailbreakrootdetection.Rooted;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.pm.ApplicationInfo;
|
|
5
|
+
import android.content.pm.PackageManager;
|
|
6
|
+
import android.os.Build;
|
|
7
|
+
import android.provider.Settings;
|
|
8
|
+
import android.telephony.TelephonyManager;
|
|
9
|
+
import java.io.BufferedReader;
|
|
10
|
+
import java.io.File;
|
|
11
|
+
import java.io.FileInputStream;
|
|
12
|
+
import java.io.InputStreamReader;
|
|
13
|
+
|
|
14
|
+
public class EmulatorDetector {
|
|
15
|
+
|
|
16
|
+
private final Context context;
|
|
17
|
+
|
|
18
|
+
public EmulatorDetector(Context ctx) {
|
|
19
|
+
context = ctx;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public boolean isEmulator() {
|
|
23
|
+
return (
|
|
24
|
+
checkBuildProperties() ||
|
|
25
|
+
checkEmulatorFiles() ||
|
|
26
|
+
checkTelephonyManager() ||
|
|
27
|
+
checkPipes() ||
|
|
28
|
+
checkQEmuDriverFile() ||
|
|
29
|
+
checkQEmuProps()
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public boolean isDebuggedMode() {
|
|
34
|
+
boolean result = false;
|
|
35
|
+
try {
|
|
36
|
+
if ((context.getPackageManager().getPackageInfo(context.getPackageName(), 0).
|
|
37
|
+
applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0)
|
|
38
|
+
result = true;
|
|
39
|
+
else
|
|
40
|
+
result = false;
|
|
41
|
+
} catch (PackageManager.NameNotFoundException e) {
|
|
42
|
+
result = false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private boolean checkBuildProperties() {
|
|
49
|
+
String[] knownEmulatorBuildProperties = {
|
|
50
|
+
"ro.hardware",
|
|
51
|
+
"goldfish",
|
|
52
|
+
"ro.hardware",
|
|
53
|
+
"ranchu",
|
|
54
|
+
"ro.kernel.qemu",
|
|
55
|
+
"1",
|
|
56
|
+
"ro.product.model",
|
|
57
|
+
"sdk",
|
|
58
|
+
"ro.product.model",
|
|
59
|
+
"google_sdk",
|
|
60
|
+
"ro.product.model",
|
|
61
|
+
"sdk_x86",
|
|
62
|
+
"ro.product.model",
|
|
63
|
+
"vbox86p"
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
for (int i = 0; i < knownEmulatorBuildProperties.length; i += 2) {
|
|
67
|
+
String property = knownEmulatorBuildProperties[i];
|
|
68
|
+
String value = knownEmulatorBuildProperties[i + 1];
|
|
69
|
+
if (value.equals(getSystemProperty(property))) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private boolean checkEmulatorFiles() {
|
|
77
|
+
String[] knownEmulatorFiles = {
|
|
78
|
+
"/dev/socket/qemud",
|
|
79
|
+
"/dev/qemu_pipe",
|
|
80
|
+
"/system/lib/libc_malloc_debug_qemu.so",
|
|
81
|
+
"/sys/qemu_trace",
|
|
82
|
+
"/system/bin/qemu-props"
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
for (String path : knownEmulatorFiles) {
|
|
86
|
+
if (new File(path).exists()) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private boolean checkTelephonyManager() {
|
|
94
|
+
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
95
|
+
String networkOperatorName = tm.getNetworkOperatorName();
|
|
96
|
+
return "Android".equalsIgnoreCase(networkOperatorName);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private boolean checkPipes() {
|
|
100
|
+
String[] knownEmulatorPipes = { "/dev/socket/qemud", "/dev/qemu_pipe" };
|
|
101
|
+
|
|
102
|
+
for (String path : knownEmulatorPipes) {
|
|
103
|
+
if (new File(path).exists()) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private boolean checkQEmuDriverFile() {
|
|
111
|
+
File driverFile = new File("/proc/tty/driver");
|
|
112
|
+
if (driverFile.exists() && driverFile.canRead()) {
|
|
113
|
+
byte[] data = new byte[(int) driverFile.length()];
|
|
114
|
+
try {
|
|
115
|
+
String driverData = new BufferedReader(new InputStreamReader(new FileInputStream(driverFile))).readLine();
|
|
116
|
+
return driverData.contains("goldfish") || driverData.contains("qemu");
|
|
117
|
+
} catch (Exception e) {
|
|
118
|
+
e.printStackTrace();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private boolean checkQEmuProps() {
|
|
125
|
+
int minQemuProps = 6;
|
|
126
|
+
String[] knownQemuProps = {
|
|
127
|
+
"ro.product.device",
|
|
128
|
+
"qemu",
|
|
129
|
+
"ro.product.brand",
|
|
130
|
+
"generic",
|
|
131
|
+
"ro.product.manufacturer",
|
|
132
|
+
"unknown",
|
|
133
|
+
"ro.product.model",
|
|
134
|
+
"sdk",
|
|
135
|
+
"ro.hardware",
|
|
136
|
+
"goldfish",
|
|
137
|
+
"ro.hardware",
|
|
138
|
+
"ranchu"
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
int matchCount = 0;
|
|
142
|
+
for (int i = 0; i < knownQemuProps.length; i += 2) {
|
|
143
|
+
String property = knownQemuProps[i];
|
|
144
|
+
String value = knownQemuProps[i + 1];
|
|
145
|
+
if (value.equals(getSystemProperty(property))) {
|
|
146
|
+
matchCount++;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return matchCount >= minQemuProps;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private String getSystemProperty(String propertyName) {
|
|
153
|
+
String propertyValue = "";
|
|
154
|
+
try {
|
|
155
|
+
Class<?> systemPropertyClazz = Class.forName("android.os.SystemProperties");
|
|
156
|
+
propertyValue = (String) systemPropertyClazz.getMethod("get", String.class).invoke(systemPropertyClazz, propertyName);
|
|
157
|
+
} catch (Exception e) {
|
|
158
|
+
e.printStackTrace();
|
|
159
|
+
}
|
|
160
|
+
return propertyValue;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
package com.evehr.plugins.capacitor.jailbreakrootdetection.Rooted;
|
|
2
|
+
|
|
3
|
+
import java.io.BufferedReader;
|
|
4
|
+
import java.io.File;
|
|
5
|
+
import java.io.InputStreamReader;
|
|
6
|
+
|
|
7
|
+
public class GreaterThan23 implements CheckApiVersion {
|
|
8
|
+
|
|
9
|
+
@Override
|
|
10
|
+
public boolean checkRooted() {
|
|
11
|
+
return checkRootMethod1() || checkRootMethod2();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private boolean checkRootMethod1() {
|
|
15
|
+
String[] paths = {
|
|
16
|
+
"/system/app/Superuser.apk",
|
|
17
|
+
"/sbin/su",
|
|
18
|
+
"/system/bin/su",
|
|
19
|
+
"/system/xbin/su",
|
|
20
|
+
"/data/local/xbin/su",
|
|
21
|
+
"/data/local/bin/su",
|
|
22
|
+
"/system/sd/xbin/su",
|
|
23
|
+
"/system/bin/failsafe/su",
|
|
24
|
+
"/data/local/su"};
|
|
25
|
+
for (String path : paths) {
|
|
26
|
+
if (new File(path).exists()) return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private boolean checkRootMethod2() {
|
|
32
|
+
Process process = null;
|
|
33
|
+
try {
|
|
34
|
+
process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
|
|
35
|
+
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
36
|
+
if (in.readLine() != null) return true;
|
|
37
|
+
return false;
|
|
38
|
+
} catch (Throwable t) {
|
|
39
|
+
return false;
|
|
40
|
+
} finally {
|
|
41
|
+
if (process != null) process.destroy();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package com.evehr.plugins.capacitor.jailbreakrootdetection.Rooted;
|
|
2
|
+
|
|
3
|
+
import java.io.File;
|
|
4
|
+
|
|
5
|
+
public class LessThan23 implements CheckApiVersion {
|
|
6
|
+
@Override
|
|
7
|
+
public boolean checkRooted() {
|
|
8
|
+
return canExecuteCommand("/system/xbin/which su") || isSuperuserPresent();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// executes a command on the system
|
|
12
|
+
private static boolean canExecuteCommand(String command) {
|
|
13
|
+
boolean executeResult;
|
|
14
|
+
try {
|
|
15
|
+
Process process = Runtime.getRuntime().exec(command);
|
|
16
|
+
if(process.waitFor() == 0) {
|
|
17
|
+
executeResult = true;
|
|
18
|
+
} else {
|
|
19
|
+
executeResult = false;
|
|
20
|
+
}
|
|
21
|
+
} catch (Exception e) {
|
|
22
|
+
executeResult = false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return executeResult;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private static boolean isSuperuserPresent() {
|
|
29
|
+
// Check if /system/app/Superuser.apk is present
|
|
30
|
+
String[] paths = {
|
|
31
|
+
"/system/app/Superuser.apk",
|
|
32
|
+
"/sbin/su",
|
|
33
|
+
"/system/bin/su",
|
|
34
|
+
"/system/xbin/su",
|
|
35
|
+
"/data/local/xbin/su",
|
|
36
|
+
"/data/local/bin/su",
|
|
37
|
+
"/system/sd/xbin/su",
|
|
38
|
+
"/system/bin/failsafe/su",
|
|
39
|
+
"/data/local/su"
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
for (String path : paths) {
|
|
43
|
+
if (new File(path).exists()) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
package com.evehr.plugins.capacitor.jailbreakrootdetection.Rooted;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import com.scottyab.rootbeer.RootBeer;
|
|
5
|
+
import java.util.HashMap;
|
|
6
|
+
import java.util.Map;
|
|
7
|
+
|
|
8
|
+
public class RootedCheck {
|
|
9
|
+
private static boolean checkWithJailMonkeyMethod() {
|
|
10
|
+
CheckApiVersion check;
|
|
11
|
+
|
|
12
|
+
if (android.os.Build.VERSION.SDK_INT >= 23) {
|
|
13
|
+
check = new GreaterThan23();
|
|
14
|
+
} else {
|
|
15
|
+
check = new LessThan23();
|
|
16
|
+
}
|
|
17
|
+
return check.checkRooted();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private final boolean jailMonkeyResult;
|
|
21
|
+
private final RootBeerResults rootBeerResults;
|
|
22
|
+
|
|
23
|
+
public RootedCheck(Context context) {
|
|
24
|
+
jailMonkeyResult = checkWithJailMonkeyMethod();
|
|
25
|
+
rootBeerResults = new RootBeerResults(context);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public boolean isJailBroken() {
|
|
29
|
+
return jailMonkeyResult || rootBeerResults.isJailBroken();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public Map<String, Object> getResultByDetectionMethod() {
|
|
33
|
+
final Map<String, Object> map = new HashMap<>();
|
|
34
|
+
|
|
35
|
+
map.put("jailMonkey", jailMonkeyResult);
|
|
36
|
+
map.put("rootBeer", rootBeerResults.toNativeMap());
|
|
37
|
+
|
|
38
|
+
return map;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private static class RootBeerResults {
|
|
42
|
+
private final boolean detectRootManagementApps;
|
|
43
|
+
private final boolean detectPotentiallyDangerousApps;
|
|
44
|
+
private final boolean checkForSuBinary;
|
|
45
|
+
private final boolean checkForDangerousProps;
|
|
46
|
+
private final boolean checkForRWPaths;
|
|
47
|
+
private final boolean detectTestKeys;
|
|
48
|
+
private final boolean checkSuExists;
|
|
49
|
+
private final boolean checkForRootNative;
|
|
50
|
+
private final boolean checkForMagiskBinary;
|
|
51
|
+
|
|
52
|
+
RootBeerResults(Context context) {
|
|
53
|
+
final RootBeer rootBeer = new RootBeer(context);
|
|
54
|
+
rootBeer.setLogging(false);
|
|
55
|
+
|
|
56
|
+
detectRootManagementApps = rootBeer.detectRootManagementApps();
|
|
57
|
+
detectPotentiallyDangerousApps = rootBeer.detectPotentiallyDangerousApps();
|
|
58
|
+
checkForSuBinary = rootBeer.checkForSuBinary();
|
|
59
|
+
checkForDangerousProps = rootBeer.checkForDangerousProps();
|
|
60
|
+
checkForRWPaths = rootBeer.checkForRWPaths();
|
|
61
|
+
detectTestKeys = rootBeer.detectTestKeys();
|
|
62
|
+
checkSuExists = rootBeer.checkSuExists();
|
|
63
|
+
checkForRootNative = rootBeer.checkForRootNative();
|
|
64
|
+
checkForMagiskBinary = rootBeer.checkForMagiskBinary();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public boolean isJailBroken() {
|
|
68
|
+
return detectRootManagementApps || detectPotentiallyDangerousApps || checkForSuBinary
|
|
69
|
+
|| checkForDangerousProps || checkForRWPaths
|
|
70
|
+
|| detectTestKeys || checkSuExists || checkForRootNative || checkForMagiskBinary;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public Map<String, Object> toNativeMap() {
|
|
74
|
+
final Map<String, Object> map = new HashMap<>();
|
|
75
|
+
|
|
76
|
+
map.put("detectRootManagementApps", detectRootManagementApps);
|
|
77
|
+
map.put("detectPotentiallyDangerousApps", detectPotentiallyDangerousApps);
|
|
78
|
+
map.put("checkForSuBinary", checkForSuBinary);
|
|
79
|
+
map.put("checkForDangerousProps", checkForDangerousProps);
|
|
80
|
+
map.put("checkForRWPaths", checkForRWPaths);
|
|
81
|
+
map.put("detectTestKeys", detectTestKeys);
|
|
82
|
+
map.put("checkSuExists", checkSuExists);
|
|
83
|
+
map.put("checkForRootNative", checkForRootNative);
|
|
84
|
+
map.put("checkForMagiskBinary", checkForMagiskBinary);
|
|
85
|
+
|
|
86
|
+
return map;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "CapacitorJailbreakRootDetectionPlugin",
|
|
4
|
+
"slug": "capacitorjailbreakrootdetectionplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "isJailbrokenOrRooted",
|
|
10
|
+
"signature": "() => Promise<JailbreakRootResult>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<JailbreakRootResult>",
|
|
13
|
+
"tags": [],
|
|
14
|
+
"docs": "",
|
|
15
|
+
"complexTypes": [
|
|
16
|
+
"JailbreakRootResult"
|
|
17
|
+
],
|
|
18
|
+
"slug": "isjailbrokenorrooted"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "isSimulator",
|
|
22
|
+
"signature": "() => Promise<JailbreakRootResult>",
|
|
23
|
+
"parameters": [],
|
|
24
|
+
"returns": "Promise<JailbreakRootResult>",
|
|
25
|
+
"tags": [],
|
|
26
|
+
"docs": "",
|
|
27
|
+
"complexTypes": [
|
|
28
|
+
"JailbreakRootResult"
|
|
29
|
+
],
|
|
30
|
+
"slug": "issimulator"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "isDebuggedMode",
|
|
34
|
+
"signature": "() => Promise<JailbreakRootResult>",
|
|
35
|
+
"parameters": [],
|
|
36
|
+
"returns": "Promise<JailbreakRootResult>",
|
|
37
|
+
"tags": [],
|
|
38
|
+
"docs": "",
|
|
39
|
+
"complexTypes": [
|
|
40
|
+
"JailbreakRootResult"
|
|
41
|
+
],
|
|
42
|
+
"slug": "isdebuggedmode"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "exitApp",
|
|
46
|
+
"signature": "() => void",
|
|
47
|
+
"parameters": [],
|
|
48
|
+
"returns": "void",
|
|
49
|
+
"tags": [],
|
|
50
|
+
"docs": "",
|
|
51
|
+
"complexTypes": [],
|
|
52
|
+
"slug": "exitapp"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"properties": []
|
|
56
|
+
},
|
|
57
|
+
"interfaces": [
|
|
58
|
+
{
|
|
59
|
+
"name": "JailbreakRootResult",
|
|
60
|
+
"slug": "jailbreakrootresult",
|
|
61
|
+
"docs": "",
|
|
62
|
+
"tags": [],
|
|
63
|
+
"methods": [],
|
|
64
|
+
"properties": [
|
|
65
|
+
{
|
|
66
|
+
"name": "result",
|
|
67
|
+
"tags": [],
|
|
68
|
+
"docs": "",
|
|
69
|
+
"complexTypes": [],
|
|
70
|
+
"type": "boolean"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
"enums": [],
|
|
76
|
+
"typeAliases": [],
|
|
77
|
+
"pluginConfigs": []
|
|
78
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CapacitorJailbreakRootDetectionPlugin {
|
|
2
|
+
isJailbrokenOrRooted(): Promise<JailbreakRootResult>;
|
|
3
|
+
isSimulator(): Promise<JailbreakRootResult>;
|
|
4
|
+
isDebuggedMode(): Promise<JailbreakRootResult>;
|
|
5
|
+
exitApp(): void;
|
|
6
|
+
}
|
|
7
|
+
export interface JailbreakRootResult {
|
|
8
|
+
result: boolean;
|
|
9
|
+
}
|