Przeglądaj źródła

添加越狱检查

fancy 5 lat temu
rodzic
commit
efd54eb56d

+ 4 - 0
o2ios/O2Platform.xcodeproj/project.pbxproj

@@ -273,6 +273,7 @@
 		B1D1BC8F234C8349002025DA /* CloudFileCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D1BC8E234C8349002025DA /* CloudFileCell.swift */; };
 		B1D4AFED24B409A9004E648E /* AudioTouchButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D4AFEC24B409A9004E648E /* AudioTouchButton.swift */; };
 		B1DA305F2282754500669418 /* QCalendarPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DA305E2282754500669418 /* QCalendarPicker.swift */; };
+		B1DB0843252314F400EE6673 /* SecurityCheckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DB0842252314F400EE6673 /* SecurityCheckManager.swift */; };
 		B1DB6EA5237E6F2C00D7BA94 /* O2VersionInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DB6EA4237E6F2C00D7BA94 /* O2VersionInfoModel.swift */; };
 		B1DE853823602D36003C36E2 /* Languager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DE853723602D36003C36E2 /* Languager.swift */; };
 		B1DE8564236030E2003C36E2 /* Bundle+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DE8563236030E2003C36E2 /* Bundle+Extension.swift */; };
@@ -1444,6 +1445,7 @@
 		B1D1BC8E234C8349002025DA /* CloudFileCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudFileCell.swift; sourceTree = "<group>"; };
 		B1D4AFEC24B409A9004E648E /* AudioTouchButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioTouchButton.swift; sourceTree = "<group>"; };
 		B1DA305E2282754500669418 /* QCalendarPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QCalendarPicker.swift; sourceTree = "<group>"; };
+		B1DB0842252314F400EE6673 /* SecurityCheckManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityCheckManager.swift; sourceTree = "<group>"; };
 		B1DB6EA4237E6F2C00D7BA94 /* O2VersionInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = O2VersionInfoModel.swift; sourceTree = "<group>"; };
 		B1DE853723602D36003C36E2 /* Languager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Languager.swift; sourceTree = "<group>"; };
 		B1DE8563236030E2003C36E2 /* Bundle+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Extension.swift"; sourceTree = "<group>"; };
@@ -2813,6 +2815,7 @@
 				B14E0C0B2484F1F0008AF6AE /* O2WebsocketManager.swift */,
 				B15BE0BD2499BCEF008CD1DB /* O2RecordVoiceManager.swift */,
 				B15BE110249A6002008CD1DB /* AudioPlayerManager.swift */,
+				B1DB0842252314F400EE6673 /* SecurityCheckManager.swift */,
 			);
 			path = Manager;
 			sourceTree = "<group>";
@@ -5645,6 +5648,7 @@
 				B15F8129210EF15E00B81F35 /* OOCalendarEventViewController.swift in Sources */,
 				09E02E941F16319600579887 /* String+Haneke.swift in Sources */,
 				E40E24B420B7DA3C009F8BE7 /* OOMeetingModels.swift in Sources */,
+				B1DB0843252314F400EE6673 /* SecurityCheckManager.swift in Sources */,
 				E4B888F61D9D48F1002E1A46 /* Application.swift in Sources */,
 				E4C24C3F208D7EDE00E426B0 /* OOContactSearchViewModel.swift in Sources */,
 				E4B697FC2076520E0062F6E8 /* OOFileModels.swift in Sources */,

+ 77 - 72
o2ios/O2Platform/App/Login-绑定登录/c/LoginViewController.swift

@@ -68,84 +68,89 @@ class LoginViewController: UIViewController {
     }
 
     func startFlowForPromise() {
-        
-        if !O2IsConnect2Collect {
-            let unit = O2BindUnitModel()
-            if let infoPath = Bundle.main.path(forResource: "Info", ofType: "plist"), let dic = NSDictionary(contentsOfFile: infoPath) {
-                let o2Server = dic["o2 server"] as? NSDictionary
-                let id = o2Server?["id"] as? String
-                let name = o2Server?["name"] as? String
-                let centerHost = o2Server?["centerHost"] as? String
-                let centerContext = o2Server?["centerContext"] as? String
-                let centerPort = o2Server?["centerPort"] as? Int
-                let httpProtocol = o2Server?["httpProtocol"] as? String
-                DDLogDebug("连接服务器:\(String(describing: name)) , host:\(String(describing: centerHost)) , context:\(String(describing: centerContext)), port:\(centerPort ?? 0), portocal:\(String(describing: httpProtocol)) ")
-                if name == nil || centerHost == nil || centerContext == nil {
-                    self.showError(title:  "服务器配置信息异常!")
+        //越狱检查
+        if SecurityCheckManager.shared.isJailBroken() {
+            self.showSystemAlert(title: "提示", message: "当前运行环境已经越狱,本应用将不提供服务!") { (action) in
+                DDLogError("已经越狱的机器,不进入app!")
+            }
+        }else {
+            if !O2IsConnect2Collect {
+                let unit = O2BindUnitModel()
+                if let infoPath = Bundle.main.path(forResource: "Info", ofType: "plist"), let dic = NSDictionary(contentsOfFile: infoPath) {
+                    let o2Server = dic["o2 server"] as? NSDictionary
+                    let id = o2Server?["id"] as? String
+                    let name = o2Server?["name"] as? String
+                    let centerHost = o2Server?["centerHost"] as? String
+                    let centerContext = o2Server?["centerContext"] as? String
+                    let centerPort = o2Server?["centerPort"] as? Int
+                    let httpProtocol = o2Server?["httpProtocol"] as? String
+                    DDLogDebug("连接服务器:\(String(describing: name)) , host:\(String(describing: centerHost)) , context:\(String(describing: centerContext)), port:\(centerPort ?? 0), portocal:\(String(describing: httpProtocol)) ")
+                    if name == nil || centerHost == nil || centerContext == nil {
+                        self.showError(title:  "服务器配置信息异常!")
+                        return
+                    }
+                    unit.id = id
+                    unit.centerContext = centerContext
+                    unit.centerHost = centerHost
+                    unit.centerPort = centerPort
+                    unit.httpProtocol = httpProtocol
+                    unit.name = name
+                }else {
+                    self.showError(title:  "没有配置服务器信息!")
                     return
                 }
-                unit.id = id
-                unit.centerContext = centerContext
-                unit.centerHost = centerHost
-                unit.centerPort = centerPort
-                unit.httpProtocol = httpProtocol
-                unit.name = name
-            }else {
-                self.showError(title:  "没有配置服务器信息!")
-                return
-            }
-            
-            O2AuthSDK.shared.launchInner(unit: unit) { (state, msg) in
-                switch state {
-                case .bindError:
-                    //校验绑定结点信息错误
-                   self.showError(title: "未知错误!")
-                    break
-                case .loginError:
-                    self.forwardToSegue("loginSystemSegue")
-                    //自动登录出错
-                    break
-                case .unknownError:
-                    self.showError(title: msg ?? "未知错误!")
-                    break
-                case .success:
-                    //处理移动端应用
-                    self.viewModel._saveAppConfigToDb()
-                    //跳转到主页
-                    let destVC = O2MainController.genernateVC()
-                    destVC.selectedIndex = 2 // 首页选中 TODO 图标不亮。。。。。
-                    UIApplication.shared.keyWindow?.rootViewController = destVC
-                    UIApplication.shared.keyWindow?.makeKeyAndVisible()
+                
+                O2AuthSDK.shared.launchInner(unit: unit) { (state, msg) in
+                    switch state {
+                    case .bindError:
+                        //校验绑定结点信息错误
+                       self.showError(title: "未知错误!")
+                        break
+                    case .loginError:
+                        self.forwardToSegue("loginSystemSegue")
+                        //自动登录出错
+                        break
+                    case .unknownError:
+                        self.showError(title: msg ?? "未知错误!")
+                        break
+                    case .success:
+                        //处理移动端应用
+                        self.viewModel._saveAppConfigToDb()
+                        //跳转到主页
+                        let destVC = O2MainController.genernateVC()
+                        destVC.selectedIndex = 2 // 首页选中 TODO 图标不亮。。。。。
+                        UIApplication.shared.keyWindow?.rootViewController = destVC
+                        UIApplication.shared.keyWindow?.makeKeyAndVisible()
+                    }
                 }
-            }
-        }else {
-            //本地 -> 校验 -> 下载NodeAPI -> 下载configInfo -> 自动登录
-            O2AuthSDK.shared.launch { (state, msg) in
-                switch state {
-                case .bindError:
-                    //校验绑定结点信息错误
-                    self.forwardToSegue("bindPhoneSegue")
-                    break
-                case .loginError:
-                    self.forwardToSegue("loginSystemSegue")
-                    //自动登录出错
-                    break
-                case .unknownError:
-//                    self.showError(title: msg ?? "未知错误!")
-                    self.needReBind(msg ?? "未知错误!")
-                    break
-                case .success:
-                    //处理移动端应用
-                    self.viewModel._saveAppConfigToDb()
-                    //跳转到主页
-                    let destVC = O2MainController.genernateVC()
-                    destVC.selectedIndex = 2 // 首页选中 TODO 图标不亮。。。。。
-                    UIApplication.shared.keyWindow?.rootViewController = destVC
-                    UIApplication.shared.keyWindow?.makeKeyAndVisible()
+            }else {
+                //本地 -> 校验 -> 下载NodeAPI -> 下载configInfo -> 自动登录
+                O2AuthSDK.shared.launch { (state, msg) in
+                    switch state {
+                    case .bindError:
+                        //校验绑定结点信息错误
+                        self.forwardToSegue("bindPhoneSegue")
+                        break
+                    case .loginError:
+                        self.forwardToSegue("loginSystemSegue")
+                        //自动登录出错
+                        break
+                    case .unknownError:
+    //                    self.showError(title: msg ?? "未知错误!")
+                        self.needReBind(msg ?? "未知错误!")
+                        break
+                    case .success:
+                        //处理移动端应用
+                        self.viewModel._saveAppConfigToDb()
+                        //跳转到主页
+                        let destVC = O2MainController.genernateVC()
+                        destVC.selectedIndex = 2 // 首页选中 TODO 图标不亮。。。。。
+                        UIApplication.shared.keyWindow?.rootViewController = destVC
+                        UIApplication.shared.keyWindow?.makeKeyAndVisible()
+                    }
                 }
             }
         }
-        
     }
 
     

+ 25 - 0
o2ios/O2Platform/App/Login-绑定登录/c/OOLoginViewController.swift

@@ -48,11 +48,22 @@ class OOLoginViewController: OOBaseViewController {
     
     override func viewDidLoad() {
         super.viewDidLoad()
+        //监听截屏通知
+        NotificationCenter.default.addObserver(self, selector: #selector(screenshots),
+                                               name: UIApplication.userDidTakeScreenshotNotification,
+                                               object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(didEnterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
+                
         //delegate
         passwordTextField.buttonDelegate = self
         setupUI()
         
     }
+    
+    deinit {
+        NotificationCenter.default.removeObserver(self, name: UIApplication.userDidTakeScreenshotNotification, object: nil)
+    }
+    
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         let bioAuthUser = AppConfigSettings.shared.bioAuthUser
@@ -71,6 +82,7 @@ class OOLoginViewController: OOBaseViewController {
         }
         
     }
+     
     
     @IBAction func unwindFromBioAuthLogin(_ unwindSegue: UIStoryboardSegue) {
         if unwindSegue.identifier == "goBack2Login" {
@@ -79,6 +91,19 @@ class OOLoginViewController: OOBaseViewController {
         }
     }
     
+    @objc private func didEnterBackground() {
+        DDLogDebug("进入后台.................")
+        self.userNameTextField.text = ""
+        self.passwordField.text = ""
+    }
+    
+    //截屏提示
+    @objc private func screenshots() {
+        self.showSystemAlert(title: "提示", message: "为了保护用户名密码安全,请不要截图!") { (action) in
+            DDLogDebug("确定提示。")
+        }
+    }
+    
     private func setupUI(){
         logoImageView.image = OOCustomImageManager.default.loadImage(.login_avatar)
         let backImageView = UIImageView(image: #imageLiteral(resourceName: "pic_beijing"))

+ 44 - 0
o2ios/O2Platform/Manager/SecurityCheckManager.swift

@@ -0,0 +1,44 @@
+//
+//  SecurityCheckManager.swift
+//  O2Platform
+//
+//  Created by FancyLou on 2020/9/29.
+//  Copyright © 2020 zoneland. All rights reserved.
+//
+
+import Foundation
+
+
+class SecurityCheckManager {
+    
+    static let shared : SecurityCheckManager = {
+        return SecurityCheckManager()
+    }()
+    
+    private init() {}
+    
+    ///判断是否存在越狱的软件
+    func isJailBroken() -> Bool {
+      //判断设备上是否安装了这些程序
+      let apps = ["/APPlications/Cydia.app",
+                  "/Library/MobileSubstrate/MobileSubstrate.dylib",
+                  "/bin/bash",
+                  "/usr/sbin/sshd",
+                  "/etc/apt",
+                  "/usr/bin/ssh",
+                  "/APPlications/limera1n.app",
+                  "/APPlications/greenpois0n.app",
+                  "/APPlications/blackra1n.app",
+                  "/APPlications/blacksn0w.app",
+                  "/APPlications/redsn0w.app",
+                  "/APPlications/Absinthe.app"]
+       for app in apps {
+           //通过文件管理器,判断在指定的目录下,是否在对应的应用程序。如果存在的话。就表示当前设备为越狱设备。
+           if FileManager.default.fileExists(atPath: app){
+               return true
+           }
+       }
+       return false
+   }
+    
+}