IntegritySwift

一个统一的产品,用于检查关于完整性和安全性的多个主题。

安装

从URL将Swift包添加到您的项目:https://github.com/CodeNationDev/IntegritySwift.git

定义 & 接口

该产品已开发为具有@objc标志的类类型,以便允许从Swift和ObjC中使用。

@objc public static var isSecure: Bool

当您请求此变量的值时,结果(true/false)是基于当时通过的所有安全检查生成的。

@objc public static var globalControlsResults: [SecurityResult]

此对象返回一个包含对象(在models文件中定义)的数组,该对象包含所有已评估检查的结果,并且具有以下结构

@objc public enum SecurityControlType: Int {
    case jailbreak = 0
    case simulator = 1
    case debugger = 2
    case reverse = 3
}

@objc public class SecurityResult: NSObject {
    @objc public var passed: Bool = true
    @objc public var reason: String = ""
    @objc public var type: SecurityControlType
    
    @objc public init(_ passed: Bool, _ reason: String, _ type: SecurityControlType) {
        self.passed = passed
        self.reason = reason
        self.type = type
    }
}

此外,您可以请求所有可用检查中任何单个检查的状态。

越狱

全局越狱通过检查

@objc public static var isDeviceJailbroken: Bool

包含检查结果的对象数组。

@objc public static var jailbreakControlsResults: [SecurityResult]

沙盒违规通过检查。检查越狱设备常见的文件的存在

@objc public static func jailbreakSuspiciousFilesCheck() -> SecurityResult

如果我们能够执行一个Cyda urlScheme,则设备已越狱

@objc public static func jailbreakUrlSchemes() -> SecurityResult

此检查查找可疑的dylib的存在。

@objc public static func jailbreakDYLD() -> SecurityResult

此检查检测到一个forked进程。

public static func jailbreakFork() -> SecurityResult

调试器状态

全局调试器状态通过检查

@objc public static func amIDebugged() -> SecurityResult

用于拒绝调试模式的函数

@objc public static func denyDebugger()

逆向工程

用于逆向工程的全局检查

@objc public static func amIReverseEngineered() -> Bool

包含检查结果的对象数组。

public static var antiReverseControlsResults: [SecurityResult]

检查可疑的库。

public static func checkDYLD() -> SecurityResult

检查可疑文件

public static func checkExistenceOfSuspiciousFiles() -> SecurityResult 

检查已打开的端口

public static func checkOpenedPorts() -> SecurityResult 

检查我们是否可以在特定端口中打开本地连接。

public static func canOpenLocalConnection(port: Int) -> SecurityResult

模拟器

用于模拟器发现的全局检查。

@objc public static func isRunningInSimulator() -> Bool

使用示例

只需获取isSecure值

Swift

//
import UIKit
import IntegirtySwift

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        if !IntegrityManager.isSecure {
            //do something if device device is not secure.
        }
        
        if !JailbreakDiscoverer.isDeviceJailbroken {
            //do something if device jailbroken
        }
        
        if DebuggerDiscoverer.amIDebugged().passed {
            //do something if the device is a simulator
        }
        
        return true
    }

Objetive-C

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (!SecurityManager.isSecure) {
      //do something if device is not secure.
    }
}

元数据

David Martin Saiz – @deividmarshalldavms81@gmail.com

在MIT许可下分发。 有关更多信息,请参见LICENSE

https://github.com/CodeNationDev/

版本历史