MCareMessageRequest.swift 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // MCareMessageRequest.swift
  3. // MCareFramework
  4. //
  5. // Created by kangsh on 2018. 12. 04..
  6. // Copyright © 2018년 idatabank. All rights reserved.
  7. //
  8. import Foundation
  9. import UIKit
  10. public class MCareMessageRequest:MCareMessageRequestProtocol {
  11. private var obf:Obfuscator = Obfuscator(withSalt: ["mcareplus" as AnyObject])
  12. enum requestConstants {
  13. static let str1: [UInt8] = [66, 34, 17, 2, 9, 4, 0, 0, 6, 12, 2, 13, 78, 49, 28, 9, 10, 0, 92, 4, 29, 19]
  14. static let str2: [UInt8] = [66, 47, 8, 16, 23, 12, 17, 24, 93, 40, 2, 1, 8, 30, 0, 62, 22, 3, 1, 17, 31, 2, 21, 23, 74, 32, 12, 3, 27, 9, 8, 48, 20, 16, 22, 25, 17, 0, 6, 0, 67, 7, 24, 30, 12, 15]
  15. static let str3: [UInt8] = [66, 1, 8, 28, 74, 15, 2, 18, 26]
  16. static let str4: [UInt8] = [66, 22, 18, 0, 74, 30, 1, 8, 28, 74, 30, 16, 9, 22]
  17. static let str5: [UInt8] = [66, 6, 21, 17, 74, 12, 19, 21]
  18. static let str6: [UInt8] = [66, 19, 19, 27, 19, 12, 23, 4, 93, 15, 12, 10, 13, 16, 23, 8, 2, 10, 92, 17, 21, 23]
  19. static let str7: [UInt8] = [14, 26, 5, 27, 4, 87, 76, 78, 2, 4, 14, 8, 0, 21, 0, 66, 0, 14, 31, 75, 8, 27, 0, 31, 21, 1, 6, 79, 2, 4, 14, 8, 0, 21, 0]
  20. }
  21. public init() {
  22. // print("\n *********")
  23. // print(obf.bytesByObfuscatingString(string: "/Application/Cydia.app"))
  24. // print(obf.bytesByObfuscatingString(string: "/Library/MobileSubstrate/MobileSubstrate.dylib"))
  25. // print(obf.bytesByObfuscatingString(string: "/bin/bash"))
  26. // print(obf.bytesByObfuscatingString(string: "/usr/sbin/sshd"))
  27. // print(obf.bytesByObfuscatingString(string: "/etc/apt"))
  28. // print(obf.bytesByObfuscatingString(string: "/private/jailbreak.txt"))
  29. // print(obf.bytesByObfuscatingString(string: "cydia://package/com.example.package"))
  30. // print("\n *********")
  31. }
  32. public func isMsgRequest() -> Bool {
  33. let fileManager:FileManager = FileManager.default
  34. if fileManager.fileExists(atPath: obf.reveal(key:requestConstants.str1)) {
  35. return true
  36. }
  37. else if fileManager.fileExists(atPath: obf.reveal(key:requestConstants.str2)) {
  38. return true
  39. }
  40. else if fileManager.fileExists(atPath: obf.reveal(key:requestConstants.str3)) {
  41. return true
  42. }
  43. else if fileManager.fileExists(atPath: obf.reveal(key:requestConstants.str4)) {
  44. return true
  45. }
  46. else if fileManager.fileExists(atPath: obf.reveal(key:requestConstants.str5)) {
  47. return true
  48. }
  49. else if self.useSabonxd() {
  50. return true
  51. }
  52. //스키마 체크하는 부분이 세브란스에서 오작동하여 해당 기능은 프레임워크에서 제외함.
  53. // else if self.useCyschemedia() {
  54. // return true
  55. // }
  56. return false
  57. }
  58. private func useSabonxd() -> Bool {
  59. let beWritten:String = "This is a test."
  60. do {
  61. try beWritten.write(toFile: obf.reveal(key:requestConstants.str6), atomically: true, encoding: .utf8)
  62. return true
  63. } catch {
  64. do {
  65. try FileManager.default.removeItem(atPath: obf.reveal(key:requestConstants.str6))
  66. } catch {
  67. print("")
  68. }
  69. }
  70. return false
  71. }
  72. private func useCyschemedia() -> Bool {
  73. if UIApplication.shared.canOpenURL(URL.init(string: obf.reveal(key:requestConstants.str7))!) {
  74. return true
  75. }
  76. return false
  77. }
  78. }