@aalzehla/capacitor-jailbreak-root-detection 1.0.0 → 1.0.2

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 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&lt;<a href="#jailbreakrootresult">JailbreakRootResult</a>&gt;</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
@@ -8,6 +8,11 @@ export class CapacitorJailbreakRootDetectionWeb extends WebPlugin {
8
8
  result: false,
9
9
  };
10
10
  }
11
+ async isFridaRunning() {
12
+ return {
13
+ result: false,
14
+ };
15
+ }
11
16
  async isSimulator() {
12
17
  return {
13
18
  result: false,
@@ -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"]}
@@ -17,6 +17,11 @@ class CapacitorJailbreakRootDetectionWeb extends core.WebPlugin {
17
17
  result: false,
18
18
  };
19
19
  }
20
+ async isFridaRunning() {
21
+ return {
22
+ result: false,
23
+ };
24
+ }
20
25
  async isSimulator() {
21
26
  return {
22
27
  result: false,
@@ -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
@@ -14,6 +14,11 @@ var capacitorCapacitorJailbreakRootDetection = (function (exports, core) {
14
14
  result: false,
15
15
  };
16
16
  }
17
+ async isFridaRunning() {
18
+ return {
19
+ result: false,
20
+ };
21
+ }
17
22
  async isSimulator() {
18
23
  return {
19
24
  result: false,
@@ -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;;;;;;;;;;;;;;;;;"}
@@ -5,6 +5,10 @@ import Foundation
5
5
  print(value)
6
6
  return value
7
7
  }
8
+ @objc public func isFridaRunning(_ value: String) -> String {
9
+ print(value)
10
+ return value
11
+ }
8
12
 
9
13
  @objc public func isSimulator(_ value: String) -> String {
10
14
  print(value)
@@ -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
@@ -30,6 +30,12 @@ extension UIDevice {
30
30
  return JailBrokenHelper.canEditSystemFiles()
31
31
  }
32
32
  }
33
+
34
+ var isFridaRunning: Bool {
35
+ get {
36
+ return JailBrokenHelper.isFridaRunning()
37
+ }
38
+ }
33
39
  }
34
40
 
35
41
  private struct JailBrokenHelper {
@@ -206,6 +212,32 @@ private struct JailBrokenHelper {
206
212
  ]
207
213
  }
208
214
 
215
+ static func isFridaRunning() -> Bool {
216
+ // func swapBytesIfNeeded(port: in_port_t) -> in_port_t {
217
+ // let littleEndian = Int(OSHostByteOrder()) == OSLittleEndian
218
+ // return littleEndian ? _OSSwapInt16(port) : port
219
+ // }
220
+
221
+ // var serverAddress = sockaddr_in()
222
+ // serverAddress.sin_family = sa_family_t(AF_INET)
223
+ // serverAddress.sin_addr.s_addr = inet_addr("127.0.0.1")
224
+ // serverAddress.sin_port = swapBytesIfNeeded(port: in_port_t(27042))
225
+ // let sock = socket(AF_INET, SOCK_STREAM, 0)
226
+
227
+ // let result = withUnsafePointer(to: &serverAddress) {
228
+ // $0.withMemoryRebound(to: sockaddr.self, capacity: 1) {
229
+ // connect(sock, $0, socklen_t(MemoryLayout<sockaddr_in>.stride))
230
+ // }
231
+ // }
232
+ // if result != -1 {
233
+ // return true
234
+ // }
235
+ let port = UInt16(27042);
236
+ if(isFridaPortOpen(port: port)) { return true; }
237
+ if(checkDYLD()) { return true; }
238
+ if(detectSuspiciousLibraries()) { return true; }
239
+ return false
240
+ }
209
241
  static func checkDYLD() -> Bool {
210
242
  let suspiciousLibraries = [
211
243
  "FridaGadget",
@@ -224,27 +256,50 @@ private struct JailBrokenHelper {
224
256
  }
225
257
  return false
226
258
  }
259
+ static func detectSuspiciousLibraries() -> Bool{
260
+
261
+ let libraries = ["FridaGadget",
262
+ "frida",
263
+ "cynject",
264
+ "libcycript", "MobileSubstrate", "SubstrateLoader", "SubstrateInserter"]
265
+ let imageCount = _dyld_image_count();
266
+ for i in 0..<imageCount{
267
+ let imgName = String(cString: _dyld_get_image_name(i));
268
+ for lib in libraries {
269
+ if imgName.lowercased().contains(lib.lowercased()){
270
+ return true
271
+ }
272
+ }
273
+ }
274
+ return false
275
+ }
227
276
 
228
- static func isFridaRunning() -> Bool {
229
- func swapBytesIfNeeded(port: in_port_t) -> in_port_t {
230
- let littleEndian = Int(OSHostByteOrder()) == OSLittleEndian
231
- return littleEndian ? _OSSwapInt16(port) : port
277
+
278
+ static func isFridaPortOpen(port: in_port_t) -> Bool {
279
+
280
+ let socketFileDescriptor = socket(AF_INET, SOCK_STREAM, 0)
281
+ if socketFileDescriptor == -1 {
282
+ return false
232
283
  }
233
-
234
- var serverAddress = sockaddr_in()
235
- serverAddress.sin_family = sa_family_t(AF_INET)
236
- serverAddress.sin_addr.s_addr = inet_addr("127.0.0.1")
237
- serverAddress.sin_port = swapBytesIfNeeded(port: in_port_t(27042))
238
- let sock = socket(AF_INET, SOCK_STREAM, 0)
239
-
240
- let result = withUnsafePointer(to: &serverAddress) {
241
- $0.withMemoryRebound(to: sockaddr.self, capacity: 1) {
242
- connect(sock, $0, socklen_t(MemoryLayout<sockaddr_in>.stride))
243
- }
284
+
285
+ var addr = sockaddr_in()
286
+ let sizeOfSockkAddr = MemoryLayout<sockaddr_in>.size
287
+ addr.sin_len = __uint8_t(sizeOfSockkAddr)
288
+ addr.sin_family = sa_family_t(AF_INET)
289
+ addr.sin_port = Int(OSHostByteOrder()) == OSLittleEndian ? _OSSwapInt16(port) : port
290
+ addr.sin_addr = in_addr(s_addr: inet_addr("127.0.0.1"))
291
+ addr.sin_zero = (0, 0, 0, 0, 0, 0, 0, 0)
292
+ var bind_addr = sockaddr()
293
+ memcpy(&bind_addr, &addr, Int(sizeOfSockkAddr))
294
+
295
+ if Darwin.bind(socketFileDescriptor, &bind_addr, socklen_t(sizeOfSockkAddr)) == -1 {
296
+ return true
244
297
  }
245
- if result != -1 {
298
+ if listen(socketFileDescriptor, SOMAXCONN ) == -1 {
246
299
  return true
247
300
  }
248
301
  return false
249
302
  }
303
+
304
+
250
305
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aalzehla/capacitor-jailbreak-root-detection",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Jailbreak Root detection plugin for capacitor.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",