123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // McareCrackCheck.swift
- // MCareSwift
- //
- // Created by heesungkim on 2017. 2. 14..
- // Copyright © 2017년 idatabank. All rights reserved.
- //
- import Foundation
- import MCareFramework
- class McareCrackCheck {
-
- private let bundlePath:String = Bundle.main.bundlePath
- private var mcareLog:MCareLogger?
-
- public init(){
- mcareLog = MCareLogger.sharedInstance()
- }
-
- func isCrack() -> String {
-
- var isCrack = false
- var result:String = ""
-
- if self.checkInfoFile() {
- isCrack = true
- result = result.appending(", ").appending(CommonConstants.CRACK_CODE_1002)
- }
-
- if self.checkPid() {
- isCrack = true
- result = result.appending(", ").appending(CommonConstants.CRACK_CODE_1003)
- }
-
- if self.checkPiratNameCodeSignature() {
- isCrack = true
- result = result.appending(", ").appending(CommonConstants.CRACK_CODE_1004)
- }
-
- if self.checkPiratNameCodeResource() {
- isCrack = true
- result = result.appending(", ").appending(CommonConstants.CRACK_CODE_1005)
- }
- if isCrack {
- result = result.substring(from: result.index(result.startIndex, offsetBy: 2))
- }
- else {
- result = result.appending(CommonConstants.CRACK_CODE_1001)
- }
-
- return result
- }
-
- func checkInfoFile() -> Bool {
- let path:String = self.bundlePath.appending("/Info.plist")
- let fileInfo:NSDictionary = Bundle.main.infoDictionary! as NSDictionary
- let fileManager:FileManager = FileManager.default
- var fileAttr:NSDictionary!
-
- do {
- fileAttr = try fileManager.attributesOfItem(atPath: path) as NSDictionary
- } catch {
- mcareLog?.error(output:"")
- }
-
- if fileAttr != nil {
- let cSIDArr = ["Si", "gne", "rIde", "ntity"]
- let cSID:String = cSIDArr.joined()
-
- if fileInfo.value(forKey: cSID) != nil {
- return true
- }
- }
- return false
- }
-
- func checkPid() -> Bool {
- let root:Int = Int(getpid())
- if root <= 10 {
- return true
- }
- return false
- }
-
- func checkPiratNameCodeSignature() -> Bool {
- let fileExists:Bool = FileManager.default.fileExists(atPath: bundlePath.appending("/_CodeSignature"))
- if !fileExists {
- return true
- }
- return false
- }
-
- func checkPiratNameCodeResource() -> Bool {
- let fileExists:Bool = FileManager.default.fileExists(atPath: bundlePath.appending("/_CodeSignature/CodeResources"))
- if !fileExists {
- return true
- }
- return false
- }
-
- }
|