@aalzehla/capacitor-jailbreak-root-detection 0.0.9 → 1.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/README.md +14 -0
- package/android/src/main/java/com/evehr/plugins/capacitor/jailbreakrootdetection/CapacitorJailbreakRootDetection.java +4 -0
- package/android/src/main/java/com/evehr/plugins/capacitor/jailbreakrootdetection/CapacitorJailbreakRootDetectionPlugin.java +9 -0
- package/dist/docs.json +12 -0
- package/dist/esm/definitions.d.ts +1 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +1 -0
- package/dist/esm/web.js +5 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +5 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +5 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorJailbreakRootDetection.swift +4 -0
- package/ios/Plugin/CapacitorJailbreakRootDetectionPlugin.m +1 -0
- package/ios/Plugin/CapacitorJailbreakRootDetectionPlugin.swift +6 -0
- package/ios/Plugin/UIDeviceJailBroken.swift +75 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @evehr/capacitor-jailbreak-root-detection
|
|
2
2
|
|
|
3
3
|
Jailbreak Root detection plugin for capacitor. Supports Capacior 5 and 6.
|
|
4
|
+
This plugin also supports Frida Detection.
|
|
5
|
+
|
|
4
6
|
a clone of @evehr/capacitor-jailbreak-root-detection repository.
|
|
5
7
|
|
|
6
8
|
## Install
|
|
@@ -15,6 +17,7 @@ npx cap sync
|
|
|
15
17
|
<docgen-index>
|
|
16
18
|
|
|
17
19
|
* [`isJailbrokenOrRooted()`](#isjailbrokenorrooted)
|
|
20
|
+
* [`isFridaRunning()`](#isfridarunning)
|
|
18
21
|
* [`isSimulator()`](#issimulator)
|
|
19
22
|
* [`isDebuggedMode()`](#isdebuggedmode)
|
|
20
23
|
* [`exitApp()`](#exitapp)
|
|
@@ -36,6 +39,17 @@ isJailbrokenOrRooted() => Promise<JailbreakRootResult>
|
|
|
36
39
|
--------------------
|
|
37
40
|
|
|
38
41
|
|
|
42
|
+
### isFridaRunning()
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
isFridaRunning() => Promise<JailbreakRootResult>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Returns:** <code>Promise<<a href="#jailbreakrootresult">JailbreakRootResult</a>></code>
|
|
49
|
+
|
|
50
|
+
--------------------
|
|
51
|
+
|
|
52
|
+
|
|
39
53
|
### isSimulator()
|
|
40
54
|
|
|
41
55
|
```typescript
|
|
@@ -6,6 +6,10 @@ public class CapacitorJailbreakRootDetection {
|
|
|
6
6
|
public boolean isJailbrokenOrRooted(boolean value) {
|
|
7
7
|
return value;
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
public boolean isFridaRunning(boolean value) {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
9
13
|
|
|
10
14
|
public boolean isSimulator(boolean value) {
|
|
11
15
|
return value;
|
|
@@ -31,6 +31,15 @@ public class CapacitorJailbreakRootDetectionPlugin extends Plugin {
|
|
|
31
31
|
ret.put("result", implementation.isJailbrokenOrRooted(result));
|
|
32
32
|
call.resolve(ret);
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
@PluginMethod
|
|
36
|
+
public void isFridaRunning(PluginCall call) {
|
|
37
|
+
boolean result = false;//rootedCheck.isFridaRunning();
|
|
38
|
+
|
|
39
|
+
JSObject ret = new JSObject();
|
|
40
|
+
ret.put("result", implementation.isFridaRunning(result));
|
|
41
|
+
call.resolve(ret);
|
|
42
|
+
}
|
|
34
43
|
|
|
35
44
|
|
|
36
45
|
@PluginMethod
|
package/dist/docs.json
CHANGED
|
@@ -17,6 +17,18 @@
|
|
|
17
17
|
],
|
|
18
18
|
"slug": "isjailbrokenorrooted"
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
"name": "isFridaRunning",
|
|
22
|
+
"signature": "() => Promise<JailbreakRootResult>",
|
|
23
|
+
"parameters": [],
|
|
24
|
+
"returns": "Promise<JailbreakRootResult>",
|
|
25
|
+
"tags": [],
|
|
26
|
+
"docs": "",
|
|
27
|
+
"complexTypes": [
|
|
28
|
+
"JailbreakRootResult"
|
|
29
|
+
],
|
|
30
|
+
"slug": "isfridarunning"
|
|
31
|
+
},
|
|
20
32
|
{
|
|
21
33
|
"name": "isSimulator",
|
|
22
34
|
"signature": "() => Promise<JailbreakRootResult>",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export interface CapacitorJailbreakRootDetectionPlugin {
|
|
2
2
|
isJailbrokenOrRooted(): Promise<JailbreakRootResult>;
|
|
3
|
+
isFridaRunning(): Promise<JailbreakRootResult>;
|
|
3
4
|
isSimulator(): Promise<JailbreakRootResult>;
|
|
4
5
|
isDebuggedMode(): Promise<JailbreakRootResult>;
|
|
5
6
|
exitApp(): void;
|
|
@@ -1 +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}"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CapacitorJailbreakRootDetectionPlugin {\n isJailbrokenOrRooted(): Promise<JailbreakRootResult>;\n isFridaRunning(): Promise<JailbreakRootResult>;\n isSimulator(): Promise<JailbreakRootResult>;\n isDebuggedMode(): Promise<JailbreakRootResult>;\n exitApp(): void;\n}\n\nexport interface JailbreakRootResult {\n result: boolean;\n}"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { CapacitorJailbreakRootDetectionPlugin, JailbreakRootResult } from
|
|
|
3
3
|
export declare class CapacitorJailbreakRootDetectionWeb extends WebPlugin implements CapacitorJailbreakRootDetectionPlugin {
|
|
4
4
|
exitApp(): void;
|
|
5
5
|
isJailbrokenOrRooted(): Promise<JailbreakRootResult>;
|
|
6
|
+
isFridaRunning(): Promise<JailbreakRootResult>;
|
|
6
7
|
isSimulator(): Promise<JailbreakRootResult>;
|
|
7
8
|
isDebuggedMode(): Promise<JailbreakRootResult>;
|
|
8
9
|
}
|
package/dist/esm/web.js
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +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"]}
|
|
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,cAAc;QAClB,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 isFridaRunning(): 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"]}
|
package/dist/plugin.cjs.js
CHANGED
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +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;;;;;;;;;"}
|
|
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 isFridaRunning() {\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,cAAc,GAAG;AAC3B,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
CHANGED
package/dist/plugin.js.map
CHANGED
|
@@ -1 +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;;;;;;;;;;;;;;;;;"}
|
|
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 isFridaRunning() {\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,cAAc,GAAG;IAC3B,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;;;;;;;;;;;;;;;;;"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
CAP_PLUGIN(CapacitorJailbreakRootDetectionPlugin, "CapacitorJailbreakRootDetection",
|
|
7
7
|
CAP_PLUGIN_METHOD(isJailbrokenOrRooted, CAPPluginReturnPromise);
|
|
8
8
|
CAP_PLUGIN_METHOD(isSimulator, CAPPluginReturnPromise);
|
|
9
|
+
CAP_PLUGIN_METHOD(isFridaRunning, CAPPluginReturnPromise);
|
|
9
10
|
CAP_PLUGIN_METHOD(isDebuggedMode, CAPPluginReturnPromise);
|
|
10
11
|
CAP_PLUGIN_METHOD(exitApp, CAPPluginReturnNone);
|
|
11
12
|
)
|
|
@@ -16,6 +16,12 @@ public class CapacitorJailbreakRootDetectionPlugin: CAPPlugin {
|
|
|
16
16
|
])
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
@objc func isFridaRunning(_ call: CAPPluginCall) {
|
|
20
|
+
call.resolve([
|
|
21
|
+
"result": UIDevice.current.isFridaRunning
|
|
22
|
+
])
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
@objc func isSimulator(_ call: CAPPluginCall) {
|
|
20
26
|
call.resolve([
|
|
21
27
|
"result": UIDevice.current.isSimulator
|
|
@@ -70,7 +70,8 @@ private struct JailBrokenHelper {
|
|
|
70
70
|
"/",
|
|
71
71
|
"/root/",
|
|
72
72
|
"/private/",
|
|
73
|
-
"/jb/"
|
|
73
|
+
"/jb/",
|
|
74
|
+
"/basebin/"
|
|
74
75
|
]
|
|
75
76
|
}
|
|
76
77
|
static func isDirectoriesWriteable() -> Bool {
|
|
@@ -192,13 +193,45 @@ private struct JailBrokenHelper {
|
|
|
192
193
|
"/Applications/RockApp.app",
|
|
193
194
|
"/Applications/SBSettings.app",
|
|
194
195
|
"/Applications/WinterBoard.app",
|
|
196
|
+
"/Applications/Dopamine.app",
|
|
195
197
|
|
|
196
198
|
"/var/.communication/launchd_to_boomerang",
|
|
197
199
|
"/var/.communication/boomerang_to_launchd",
|
|
198
|
-
"/usr/lib/systemhook.dylib"
|
|
200
|
+
"/usr/lib/systemhook.dylib",
|
|
201
|
+
"/basebin/libjailbreak.dylib",
|
|
202
|
+
"/var/.boot_info.plist",
|
|
203
|
+
"/basebin/jbctl",
|
|
204
|
+
"/usr/bin/dpkg",
|
|
205
|
+
"/basebin/LaunchDaemons/com.opa334.jailbreakd.plist"
|
|
199
206
|
]
|
|
200
207
|
}
|
|
201
|
-
|
|
208
|
+
|
|
209
|
+
static func isFridaRunning() -> Bool {
|
|
210
|
+
// func swapBytesIfNeeded(port: in_port_t) -> in_port_t {
|
|
211
|
+
// let littleEndian = Int(OSHostByteOrder()) == OSLittleEndian
|
|
212
|
+
// return littleEndian ? _OSSwapInt16(port) : port
|
|
213
|
+
// }
|
|
214
|
+
|
|
215
|
+
// var serverAddress = sockaddr_in()
|
|
216
|
+
// serverAddress.sin_family = sa_family_t(AF_INET)
|
|
217
|
+
// serverAddress.sin_addr.s_addr = inet_addr("127.0.0.1")
|
|
218
|
+
// serverAddress.sin_port = swapBytesIfNeeded(port: in_port_t(27042))
|
|
219
|
+
// let sock = socket(AF_INET, SOCK_STREAM, 0)
|
|
220
|
+
|
|
221
|
+
// let result = withUnsafePointer(to: &serverAddress) {
|
|
222
|
+
// $0.withMemoryRebound(to: sockaddr.self, capacity: 1) {
|
|
223
|
+
// connect(sock, $0, socklen_t(MemoryLayout<sockaddr_in>.stride))
|
|
224
|
+
// }
|
|
225
|
+
// }
|
|
226
|
+
// if result != -1 {
|
|
227
|
+
// return true
|
|
228
|
+
// }
|
|
229
|
+
let port = UInt16(27042);
|
|
230
|
+
if(isFridaPortOpen(port)) { return true; }
|
|
231
|
+
if(checkDYLD()) { return true; }
|
|
232
|
+
if(detectSuspiciousLibraries()) { return true; }
|
|
233
|
+
return false
|
|
234
|
+
}
|
|
202
235
|
static func checkDYLD() -> Bool {
|
|
203
236
|
let suspiciousLibraries = [
|
|
204
237
|
"FridaGadget",
|
|
@@ -217,27 +250,50 @@ private struct JailBrokenHelper {
|
|
|
217
250
|
}
|
|
218
251
|
return false
|
|
219
252
|
}
|
|
253
|
+
static func detectSuspiciousLibraries() -> Bool{
|
|
254
|
+
|
|
255
|
+
let libraries = ["FridaGadget",
|
|
256
|
+
"frida",
|
|
257
|
+
"cynject",
|
|
258
|
+
"libcycript", "MobileSubstrate", "SubstrateLoader", "SubstrateInserter"]
|
|
259
|
+
let imageCount = _dyld_image_count();
|
|
260
|
+
for i in 0..<imageCount{
|
|
261
|
+
let imgName = String(cString: _dyld_get_image_name(i));
|
|
262
|
+
for lib in libraries {
|
|
263
|
+
if imgName.lowercased().contains(lib.lowercased()){
|
|
264
|
+
return true
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return false
|
|
269
|
+
}
|
|
220
270
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
271
|
+
|
|
272
|
+
static func isFridaPortOpen(port: in_port_t) -> Bool {
|
|
273
|
+
|
|
274
|
+
let socketFileDescriptor = socket(AF_INET, SOCK_STREAM, 0)
|
|
275
|
+
if socketFileDescriptor == -1 {
|
|
276
|
+
return false
|
|
225
277
|
}
|
|
226
|
-
|
|
227
|
-
var
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
278
|
+
|
|
279
|
+
var addr = sockaddr_in()
|
|
280
|
+
let sizeOfSockkAddr = MemoryLayout<sockaddr_in>.size
|
|
281
|
+
addr.sin_len = __uint8_t(sizeOfSockkAddr)
|
|
282
|
+
addr.sin_family = sa_family_t(AF_INET)
|
|
283
|
+
addr.sin_port = Int(OSHostByteOrder()) == OSLittleEndian ? _OSSwapInt16(port) : port
|
|
284
|
+
addr.sin_addr = in_addr(s_addr: inet_addr("127.0.0.1"))
|
|
285
|
+
addr.sin_zero = (0, 0, 0, 0, 0, 0, 0, 0)
|
|
286
|
+
var bind_addr = sockaddr()
|
|
287
|
+
memcpy(&bind_addr, &addr, Int(sizeOfSockkAddr))
|
|
288
|
+
|
|
289
|
+
if Darwin.bind(socketFileDescriptor, &bind_addr, socklen_t(sizeOfSockkAddr)) == -1 {
|
|
290
|
+
return true
|
|
237
291
|
}
|
|
238
|
-
if
|
|
292
|
+
if listen(socketFileDescriptor, SOMAXCONN ) == -1 {
|
|
239
293
|
return true
|
|
240
294
|
}
|
|
241
295
|
return false
|
|
242
296
|
}
|
|
297
|
+
|
|
298
|
+
|
|
243
299
|
}
|