|
@@ -286,6 +286,52 @@ public class Nexilis: NSObject {
|
|
|
//print("MANIA \(UIFont.systemFont(ofSize: 12)) <> \(UIFont.italicSystemFont(ofSize: 12)) <> \(UIFont.boldSystemFont(ofSize: 12))")
|
|
|
}
|
|
|
|
|
|
+ private static func isDebuggerAttached() -> Bool {
|
|
|
+ var name = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]
|
|
|
+ var info = kinfo_proc()
|
|
|
+ var infoSize = MemoryLayout<kinfo_proc>.stride
|
|
|
+
|
|
|
+ let success = name.withUnsafeMutableBytes { (namePointer: UnsafeMutableRawBufferPointer) -> Bool in
|
|
|
+ guard let baseAddress = namePointer.baseAddress else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return sysctl(UnsafeMutablePointer<Int32>(baseAddress.assumingMemoryBound(to: Int32.self)), 4, &info, &infoSize, nil, 0) == 0
|
|
|
+ }
|
|
|
+
|
|
|
+ return success && (info.kp_proc.p_flag & P_TRACED) != 0
|
|
|
+ }
|
|
|
+
|
|
|
+ private static func checkForBreakpoints() -> Bool {
|
|
|
+ #if arch(arm64) || arch(i386) || arch(x86_64)
|
|
|
+ var result: Int = 0
|
|
|
+ var bpt = 0xCC // x86/x64 breakpoint instruction
|
|
|
+
|
|
|
+ result = Int(bitPattern: UnsafeMutableRawPointer(mutating: &bpt))
|
|
|
+
|
|
|
+ return result == bpt
|
|
|
+ #else
|
|
|
+ return false
|
|
|
+ #endif
|
|
|
+ }
|
|
|
+
|
|
|
+ private static func checkForDebuggerEnvironment() -> Bool {
|
|
|
+ let debuggerEnvVars = ["DYLD_INSERT_LIBRARIES", "DYLD_LIBRARY_PATH", "DYLD_FRAMEWORK_PATH"]
|
|
|
+ for varName in debuggerEnvVars {
|
|
|
+ if let value = getenv(varName), String(cString: value).isEmpty == false {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ private static func checkingDebuggerDetected() -> Bool {
|
|
|
+ if Utils.getCheckDebugger(){
|
|
|
+ UIApplication.shared.visibleViewController?.view.makeToast("123:Debugging detected".localized(), duration: 2)
|
|
|
+ return isDebuggerAttached() || checkForBreakpoints() || checkForDebuggerEnvironment()
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
private static func checkingEmulator() -> Bool {
|
|
|
if Utils.getCheckEmulator() {
|
|
|
#if arch(i386) || arch(x86_64)
|
|
@@ -466,6 +512,7 @@ public class Nexilis: NSObject {
|
|
|
let checkEmu = jsonArray[0]["check_emulator"] as? String
|
|
|
let checkRooted = jsonArray[0]["check_rooted_device"] as? String
|
|
|
let checkScreenCapt = jsonArray[0]["check_screen_capture"] as? String
|
|
|
+ let checkDebug = jsonArray[0]["check_usb_debugging"] as? String
|
|
|
if umr != nil {
|
|
|
Utils.setMaxRetryUpload(value: "\(umr ?? 0)")
|
|
|
}
|
|
@@ -481,6 +528,9 @@ public class Nexilis: NSObject {
|
|
|
if checkScreenCapt != nil {
|
|
|
Utils.setCheckScreenCapture(b: checkScreenCapt == "1")
|
|
|
}
|
|
|
+ if checkDebug != nil {
|
|
|
+ Utils.setCheckDebugger(b: checkDebug == "1")
|
|
|
+ }
|
|
|
} catch {
|
|
|
}
|
|
|
}
|