@aalzehla/capacitor-jailbreak-root-detection 0.0.1
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/AalzehlaCapacitorJailbreakRootDetection.podspec +17 -0
- package/README.md +79 -0
- package/android/build.gradle +58 -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 +78 -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 = 'AalzehlaCapacitorJailbreakRootDetection'
|
|
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,79 @@
|
|
|
1
|
+
# @evehr/capacitor-jailbreak-root-detection
|
|
2
|
+
|
|
3
|
+
Jailbreak Root detection plugin for capacitor.
|
|
4
|
+
a clone of @evehr/capacitor-jailbreak-root-detection repository.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @evehr/capacitor-jailbreak-root-detection
|
|
10
|
+
npx cap sync
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## API
|
|
14
|
+
|
|
15
|
+
<docgen-index>
|
|
16
|
+
|
|
17
|
+
* [`isJailbrokenOrRooted()`](#isjailbrokenorrooted)
|
|
18
|
+
* [`isSimulator()`](#issimulator)
|
|
19
|
+
* [`isDebuggedMode()`](#isdebuggedmode)
|
|
20
|
+
* [`exitApp()`](#exitapp)
|
|
21
|
+
* [Interfaces](#interfaces)
|
|
22
|
+
|
|
23
|
+
</docgen-index>
|
|
24
|
+
|
|
25
|
+
<docgen-api>
|
|
26
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
27
|
+
|
|
28
|
+
### isJailbrokenOrRooted()
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
isJailbrokenOrRooted() => Promise<JailbreakRootResult>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Returns:** <code>Promise<<a href="#jailbreakrootresult">JailbreakRootResult</a>></code>
|
|
35
|
+
|
|
36
|
+
--------------------
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### isSimulator()
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
isSimulator() => Promise<JailbreakRootResult>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Returns:** <code>Promise<<a href="#jailbreakrootresult">JailbreakRootResult</a>></code>
|
|
46
|
+
|
|
47
|
+
--------------------
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### isDebuggedMode()
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
isDebuggedMode() => Promise<JailbreakRootResult>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Returns:** <code>Promise<<a href="#jailbreakrootresult">JailbreakRootResult</a>></code>
|
|
57
|
+
|
|
58
|
+
--------------------
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### exitApp()
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
exitApp() => void
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
--------------------
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Interfaces
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
#### JailbreakRootResult
|
|
74
|
+
|
|
75
|
+
| Prop | Type |
|
|
76
|
+
| ------------ | -------------------- |
|
|
77
|
+
| **`result`** | <code>boolean</code> |
|
|
78
|
+
|
|
79
|
+
</docgen-api>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:7.2.1'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
|
|
22
|
+
defaultConfig {
|
|
23
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
24
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
|
|
25
|
+
versionCode 1
|
|
26
|
+
versionName "1.0"
|
|
27
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
28
|
+
}
|
|
29
|
+
buildTypes {
|
|
30
|
+
release {
|
|
31
|
+
minifyEnabled false
|
|
32
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
lintOptions {
|
|
36
|
+
abortOnError false
|
|
37
|
+
}
|
|
38
|
+
compileOptions {
|
|
39
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
40
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
repositories {
|
|
45
|
+
google()
|
|
46
|
+
mavenCentral()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
dependencies {
|
|
51
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
52
|
+
implementation project(':capacitor-android')
|
|
53
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
54
|
+
implementation 'com.scottyab:rootbeer-lib:0.0.9'
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CapacitorJailbreakRootDetectionPlugin {\n isJailbrokenOrRooted(): Promise<JailbreakRootResult>;\n isSimulator(): Promise<JailbreakRootResult>;\n isDebuggedMode(): Promise<JailbreakRootResult>;\n exitApp(): void;\n}\n\nexport interface JailbreakRootResult {\n result: boolean;\n}"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const CapacitorJailbreakRootDetection = registerPlugin('CapacitorJailbreakRootDetection', {
|
|
3
|
+
web: () => import('./web').then(m => new m.CapacitorJailbreakRootDetectionWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { CapacitorJailbreakRootDetection };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,+BAA+B,GACnC,cAAc,CACZ,iCAAiC,EACjC;IACE,GAAG,EAAE,GAAG,EAAE,CACR,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,kCAAkC,EAAE,CAAC;CACxE,CACF,CAAC;AAEJ,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,+BAA+B,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapacitorJailbreakRootDetectionPlugin } from './definitions';\n\nconst CapacitorJailbreakRootDetection =\n registerPlugin<CapacitorJailbreakRootDetectionPlugin>(\n 'CapacitorJailbreakRootDetection',\n {\n web: () =>\n import('./web').then(m => new m.CapacitorJailbreakRootDetectionWeb()),\n },\n );\n\nexport * from './definitions';\nexport { CapacitorJailbreakRootDetection };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { CapacitorJailbreakRootDetectionPlugin, JailbreakRootResult } from './definitions';
|
|
3
|
+
export declare class CapacitorJailbreakRootDetectionWeb extends WebPlugin implements CapacitorJailbreakRootDetectionPlugin {
|
|
4
|
+
exitApp(): void;
|
|
5
|
+
isJailbrokenOrRooted(): Promise<JailbreakRootResult>;
|
|
6
|
+
isSimulator(): Promise<JailbreakRootResult>;
|
|
7
|
+
isDebuggedMode(): Promise<JailbreakRootResult>;
|
|
8
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class CapacitorJailbreakRootDetectionWeb extends WebPlugin {
|
|
3
|
+
exitApp() {
|
|
4
|
+
// Do Nothing
|
|
5
|
+
}
|
|
6
|
+
async isJailbrokenOrRooted() {
|
|
7
|
+
return {
|
|
8
|
+
result: false,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
async isSimulator() {
|
|
12
|
+
return {
|
|
13
|
+
result: false,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async isDebuggedMode() {
|
|
17
|
+
return {
|
|
18
|
+
result: false,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,kCACX,SAAQ,SAAS;IAGjB,OAAO;QACL,aAAa;IACf,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,OAAO;YACL,MAAM,EAAE,KAAK;SACd,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,WAAW;QACf,OAAO;YACL,MAAM,EAAE,KAAK;SACd,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,cAAc;QAClB,OAAO;YACL,MAAM,EAAE,KAAK;SACd,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorJailbreakRootDetectionPlugin, JailbreakRootResult } from './definitions';\n\nexport class CapacitorJailbreakRootDetectionWeb\n extends WebPlugin\n implements CapacitorJailbreakRootDetectionPlugin\n{\n exitApp(): void {\n // Do Nothing\n }\n\n async isJailbrokenOrRooted(): Promise<JailbreakRootResult> {\n return {\n result: false,\n };\n }\n async isSimulator(): Promise<JailbreakRootResult> {\n return {\n result: false,\n };\n }\n async isDebuggedMode(): Promise<JailbreakRootResult> {\n return {\n result: false,\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@capacitor/core');
|
|
6
|
+
|
|
7
|
+
const CapacitorJailbreakRootDetection = core.registerPlugin('CapacitorJailbreakRootDetection', {
|
|
8
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorJailbreakRootDetectionWeb()),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
class CapacitorJailbreakRootDetectionWeb extends core.WebPlugin {
|
|
12
|
+
exitApp() {
|
|
13
|
+
// Do Nothing
|
|
14
|
+
}
|
|
15
|
+
async isJailbrokenOrRooted() {
|
|
16
|
+
return {
|
|
17
|
+
result: false,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async isSimulator() {
|
|
21
|
+
return {
|
|
22
|
+
result: false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async isDebuggedMode() {
|
|
26
|
+
return {
|
|
27
|
+
result: false,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
33
|
+
__proto__: null,
|
|
34
|
+
CapacitorJailbreakRootDetectionWeb: CapacitorJailbreakRootDetectionWeb
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
exports.CapacitorJailbreakRootDetection = CapacitorJailbreakRootDetection;
|
|
38
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorJailbreakRootDetection = registerPlugin('CapacitorJailbreakRootDetection', {\n web: () => import('./web').then(m => new m.CapacitorJailbreakRootDetectionWeb()),\n});\nexport * from './definitions';\nexport { CapacitorJailbreakRootDetection };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorJailbreakRootDetectionWeb extends WebPlugin {\n exitApp() {\n // Do Nothing\n }\n async isJailbrokenOrRooted() {\n return {\n result: false,\n };\n }\n async isSimulator() {\n return {\n result: false,\n };\n }\n async isDebuggedMode() {\n return {\n result: false,\n };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,+BAA+B,GAAGA,mBAAc,CAAC,iCAAiC,EAAE;AAC1F,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,kCAAkC,EAAE,CAAC;AACpF,CAAC;;ACFM,MAAM,kCAAkC,SAASC,cAAS,CAAC;AAClE,IAAI,OAAO,GAAG;AACd;AACA,KAAK;AACL,IAAI,MAAM,oBAAoB,GAAG;AACjC,QAAQ,OAAO;AACf,YAAY,MAAM,EAAE,KAAK;AACzB,SAAS,CAAC;AACV,KAAK;AACL,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO;AACf,YAAY,MAAM,EAAE,KAAK;AACzB,SAAS,CAAC;AACV,KAAK;AACL,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,OAAO;AACf,YAAY,MAAM,EAAE,KAAK;AACzB,SAAS,CAAC;AACV,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var aalzehlaCapacitorJailbreakRootDetection = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const CapacitorJailbreakRootDetection = core.registerPlugin('CapacitorJailbreakRootDetection', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorJailbreakRootDetectionWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class CapacitorJailbreakRootDetectionWeb extends core.WebPlugin {
|
|
9
|
+
exitApp() {
|
|
10
|
+
// Do Nothing
|
|
11
|
+
}
|
|
12
|
+
async isJailbrokenOrRooted() {
|
|
13
|
+
return {
|
|
14
|
+
result: false,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async isSimulator() {
|
|
18
|
+
return {
|
|
19
|
+
result: false,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async isDebuggedMode() {
|
|
23
|
+
return {
|
|
24
|
+
result: false,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
30
|
+
__proto__: null,
|
|
31
|
+
CapacitorJailbreakRootDetectionWeb: CapacitorJailbreakRootDetectionWeb
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
exports.CapacitorJailbreakRootDetection = CapacitorJailbreakRootDetection;
|
|
35
|
+
|
|
36
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
37
|
+
|
|
38
|
+
return exports;
|
|
39
|
+
|
|
40
|
+
})({}, capacitorExports);
|
|
41
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorJailbreakRootDetection = registerPlugin('CapacitorJailbreakRootDetection', {\n web: () => import('./web').then(m => new m.CapacitorJailbreakRootDetectionWeb()),\n});\nexport * from './definitions';\nexport { CapacitorJailbreakRootDetection };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorJailbreakRootDetectionWeb extends WebPlugin {\n exitApp() {\n // Do Nothing\n }\n async isJailbrokenOrRooted() {\n return {\n result: false,\n };\n }\n async isSimulator() {\n return {\n result: false,\n };\n }\n async isDebuggedMode() {\n return {\n result: false,\n };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,+BAA+B,GAAGA,mBAAc,CAAC,iCAAiC,EAAE;IAC1F,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,kCAAkC,EAAE,CAAC;IACpF,CAAC;;ICFM,MAAM,kCAAkC,SAASC,cAAS,CAAC;IAClE,IAAI,OAAO,GAAG;IACd;IACA,KAAK;IACL,IAAI,MAAM,oBAAoB,GAAG;IACjC,QAAQ,OAAO;IACf,YAAY,MAAM,EAAE,KAAK;IACzB,SAAS,CAAC;IACV,KAAK;IACL,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO;IACf,YAAY,MAAM,EAAE,KAAK;IACzB,SAAS,CAAC;IACV,KAAK;IACL,IAAI,MAAM,cAAc,GAAG;IAC3B,QAAQ,OAAO;IACf,YAAY,MAAM,EAAE,KAAK;IACzB,SAAS,CAAC;IACV,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class CapacitorJailbreakRootDetection: NSObject {
|
|
4
|
+
@objc public func isJailbrokenOrRooted(_ value: String) -> String {
|
|
5
|
+
print(value)
|
|
6
|
+
return value
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@objc public func isSimulator(_ value: String) -> String {
|
|
10
|
+
print(value)
|
|
11
|
+
return value
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@objc public func isDebuggedMode(_ value: String) -> String {
|
|
15
|
+
print(value)
|
|
16
|
+
return value
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
//! Project version number for Plugin.
|
|
4
|
+
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
5
|
+
|
|
6
|
+
//! Project version string for Plugin.
|
|
7
|
+
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
8
|
+
|
|
9
|
+
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
10
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <Capacitor/Capacitor.h>
|
|
3
|
+
|
|
4
|
+
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
|
+
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
+
CAP_PLUGIN(CapacitorJailbreakRootDetectionPlugin, "CapacitorJailbreakRootDetection",
|
|
7
|
+
CAP_PLUGIN_METHOD(isJailbrokenOrRooted, CAPPluginReturnPromise);
|
|
8
|
+
CAP_PLUGIN_METHOD(isSimulator, CAPPluginReturnPromise);
|
|
9
|
+
CAP_PLUGIN_METHOD(isDebuggedMode, CAPPluginReturnPromise);
|
|
10
|
+
CAP_PLUGIN_METHOD(exitApp, CAPPluginReturnNone);
|
|
11
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import UIKit
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
7
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
8
|
+
*/
|
|
9
|
+
@objc(CapacitorJailbreakRootDetectionPlugin)
|
|
10
|
+
public class CapacitorJailbreakRootDetectionPlugin: CAPPlugin {
|
|
11
|
+
private let implementation = CapacitorJailbreakRootDetection()
|
|
12
|
+
|
|
13
|
+
@objc func isJailbrokenOrRooted(_ call: CAPPluginCall) {
|
|
14
|
+
call.resolve([
|
|
15
|
+
"result": UIDevice.current.isJailBroken
|
|
16
|
+
])
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@objc func isSimulator(_ call: CAPPluginCall) {
|
|
20
|
+
call.resolve([
|
|
21
|
+
"result": UIDevice.current.isSimulator
|
|
22
|
+
])
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@objc func isDebuggedMode(_ call: CAPPluginCall) {
|
|
26
|
+
call.resolve([
|
|
27
|
+
"result": UIDevice.current.isDebuggedMode
|
|
28
|
+
])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@objc func exitApp(_ call: CAPPluginCall) {
|
|
32
|
+
UIControl().sendAction(#selector(NSXPCConnection.suspend), to: UIApplication.shared, for: nil)
|
|
33
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
34
|
+
exit(EXIT_SUCCESS)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
<key>LSApplicationQueriesSchemes</key>
|
|
24
|
+
<array>
|
|
25
|
+
<string>cydia</string>
|
|
26
|
+
</array>
|
|
27
|
+
</dict>
|
|
28
|
+
</plist>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//
|
|
2
|
+
// UIDevice+JailBroken.swift
|
|
3
|
+
// IsJailBroken
|
|
4
|
+
//
|
|
5
|
+
// Created by Vineet Choudhary on 07/02/20.
|
|
6
|
+
// Copyright © 2020 Developer Insider. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
import UIKit
|
|
11
|
+
|
|
12
|
+
extension UIDevice {
|
|
13
|
+
var isSimulator: Bool {
|
|
14
|
+
return TARGET_OS_SIMULATOR != 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var isDebuggedMode: Bool {
|
|
18
|
+
return UIDevice.current.isSimulator
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var isJailBroken: Bool {
|
|
22
|
+
get {
|
|
23
|
+
// if UIDevice.current.isSimulator { return false }
|
|
24
|
+
if JailBrokenHelper.hasCydiaInstalled() { return true }
|
|
25
|
+
if JailBrokenHelper.isContainsSuspiciousApps() { return true }
|
|
26
|
+
if JailBrokenHelper.isSuspiciousSystemPathsExists() { return true }
|
|
27
|
+
return JailBrokenHelper.canEditSystemFiles()
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private struct JailBrokenHelper {
|
|
33
|
+
static func hasCydiaInstalled() -> Bool {
|
|
34
|
+
return UIApplication.shared.canOpenURL(URL(string: "cydia://")!)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static func isContainsSuspiciousApps() -> Bool {
|
|
38
|
+
for path in suspiciousAppsPathToCheck {
|
|
39
|
+
if FileManager.default.fileExists(atPath: path) {
|
|
40
|
+
return true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static func isSuspiciousSystemPathsExists() -> Bool {
|
|
47
|
+
for path in suspiciousSystemPathsToCheck {
|
|
48
|
+
if FileManager.default.fileExists(atPath: path) {
|
|
49
|
+
return true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static func canEditSystemFiles() -> Bool {
|
|
56
|
+
let jailBreakText = "Developer Insider"
|
|
57
|
+
do {
|
|
58
|
+
try jailBreakText.write(toFile: jailBreakText, atomically: true, encoding: .utf8)
|
|
59
|
+
return true
|
|
60
|
+
} catch {
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
Add more paths here to check for jail break
|
|
67
|
+
*/
|
|
68
|
+
static var suspiciousAppsPathToCheck: [String] {
|
|
69
|
+
return ["/Applications/Cydia.app",
|
|
70
|
+
"/Applications/blackra1n.app",
|
|
71
|
+
"/Applications/FakeCarrier.app",
|
|
72
|
+
"/Applications/Icy.app",
|
|
73
|
+
"/Applications/IntelliScreen.app",
|
|
74
|
+
"/Applications/MxTube.app",
|
|
75
|
+
"/Applications/RockApp.app",
|
|
76
|
+
"/Applications/SBSettings.app",
|
|
77
|
+
"/Applications/WinterBoard.app"
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static var suspiciousSystemPathsToCheck: [String] {
|
|
82
|
+
return ["/Library/MobileSubstrate/DynamicLibraries/LiveClock.plist",
|
|
83
|
+
"/Library/MobileSubstrate/DynamicLibraries/Veency.plist",
|
|
84
|
+
"/private/var/lib/apt",
|
|
85
|
+
"/private/var/lib/apt/",
|
|
86
|
+
"/private/var/lib/cydia",
|
|
87
|
+
"/private/var/mobile/Library/SBSettings/Themes",
|
|
88
|
+
"/private/var/stash",
|
|
89
|
+
"/private/var/tmp/cydia.log",
|
|
90
|
+
"/System/Library/LaunchDaemons/com.ikey.bbot.plist",
|
|
91
|
+
"/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist",
|
|
92
|
+
"/usr/bin/sshd",
|
|
93
|
+
"/usr/libexec/sftp-server",
|
|
94
|
+
"/usr/sbin/sshd",
|
|
95
|
+
"/etc/apt",
|
|
96
|
+
"/bin/bash",
|
|
97
|
+
"/Library/MobileSubstrate/MobileSubstrate.dylib"
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aalzehla/capacitor-jailbreak-root-detection",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Jailbreak Root detection plugin for capacitor.",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Plugin/",
|
|
14
|
+
"AalzehlaCapacitorJailbreakRootDetection.podspec"
|
|
15
|
+
],
|
|
16
|
+
"author": "Ateik Alzehla",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/aalzehla/capacitor-jailbreak-root-detection.git.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/aalzehla/capacitor-jailbreak-root-detection.git/issues"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"capacitor",
|
|
27
|
+
"plugin",
|
|
28
|
+
"native"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
32
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
|
|
33
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
34
|
+
"verify:web": "npm run build",
|
|
35
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
36
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
37
|
+
"eslint": "eslint . --ext ts",
|
|
38
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
39
|
+
"swiftlint": "node-swiftlint",
|
|
40
|
+
"docgen": "docgen --api CapacitorJailbreakRootDetectionPlugin --output-readme README.md --output-json dist/docs.json",
|
|
41
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
|
|
42
|
+
"clean": "rimraf ./dist",
|
|
43
|
+
"watch": "tsc --watch",
|
|
44
|
+
"prepublishOnly": "npm run build"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@capacitor/android": "^5.6.0",
|
|
48
|
+
"@capacitor/core": "^5.6.0",
|
|
49
|
+
"@capacitor/docgen": "^0.0.18",
|
|
50
|
+
"@capacitor/ios": "^5.6.0",
|
|
51
|
+
"@ionic/eslint-config": "^0.3.0",
|
|
52
|
+
"@ionic/prettier-config": "^1.0.1",
|
|
53
|
+
"@ionic/swiftlint-config": "^1.1.2",
|
|
54
|
+
"eslint": "^7.11.0",
|
|
55
|
+
"prettier": "~2.3.0",
|
|
56
|
+
"prettier-plugin-java": "~1.0.2",
|
|
57
|
+
"rimraf": "^3.0.2",
|
|
58
|
+
"rollup": "^2.32.0",
|
|
59
|
+
"swiftlint": "^1.0.1",
|
|
60
|
+
"typescript": "~4.1.5"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@capacitor/core": "^5.0.6"
|
|
64
|
+
},
|
|
65
|
+
"prettier": "@ionic/prettier-config",
|
|
66
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
67
|
+
"eslintConfig": {
|
|
68
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
69
|
+
},
|
|
70
|
+
"capacitor": {
|
|
71
|
+
"ios": {
|
|
72
|
+
"src": "ios"
|
|
73
|
+
},
|
|
74
|
+
"android": {
|
|
75
|
+
"src": "android"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|