@@ -21,7 +21,7 @@ public final class BrightSide {
2121 }
2222
2323 // Check 2 : existence of files that are common for jailbroken devices
24- if isJailbreakDirectoriesExist ( ) || canOpenCydia ( ) {
24+ if isJailbreakDirectoriesExist ( ) || suspiciousURLs . contains ( where : { canOpenUrl ( urlString : $0 ) } ) {
2525 return false
2626 }
2727
@@ -46,31 +46,41 @@ private extension BrightSide {
4646
4747 /// Method will return true, if any of the files or dir, typical for the jailbreak, exists
4848 static func isJailbreakDirectoriesExist( ) -> Bool {
49- let jailbreakRelativelyFilesAndPaths = suspiciousSystemFiles
50- + suspiciousAppsDir
51- + suspiciousSystemDir
52- return jailbreakRelativelyFilesAndPaths
53- . allSatisfy ( FileManager . default. fileExists ( atPath: ) )
49+ let jailbreakPaths = suspiciousSystemFiles + suspiciousAppsDir + suspiciousSystemDir
50+ // These files can give false positive in the simulator
51+ let deviceOnlyPaths = [
52+ " /bin/bash " ,
53+ " /usr/sbin/sshd " ,
54+ " /usr/libexec/ssh-keysign " ,
55+ " /bin/sh " ,
56+ " /etc/ssh/sshd_config " ,
57+ " /usr/libexec/sftp-server " ,
58+ " /usr/bin/ssh "
59+ ]
60+
61+ let pathsToCheck = isSimulator ( ) ? jailbreakPaths : ( jailbreakPaths + deviceOnlyPaths)
62+
63+ return pathsToCheck. contains { FileManager . default. fileExists ( atPath: $0) }
5464 }
5565
5666 /// Method will return true if we can open cydia package
57- static func canOpenCydia ( ) -> Bool {
58- guard let cydiaURL = URL ( string: " cydia://package/com.example.package " ) else {
67+ static func canOpenUrl ( urlString : String ) -> Bool {
68+ guard let URL = URL ( string: urlString ) else {
5969 return false
6070 }
61- return UIApplication . shared. canOpenURL ( cydiaURL )
71+ return UIApplication . shared. canOpenURL ( URL )
6272 }
6373
6474 /// Method will return true if current device is simulator
6575 static func isSimulator( ) -> Bool {
66- return ProcessInfo . processInfo . environment [ " SIMULATOR_DEVICE_NAME " ] != nil
76+ return isSimulatorCompile ( ) || isSimulatorRuntime ( )
6777 }
6878
6979}
7080
71- // MARK: - Suspicious dir
81+ // MARK: - Suspicious directories and files
7282
73- extension BrightSide {
83+ private extension BrightSide {
7484
7585 static var suspiciousAppsDir : [ String ] {
7686 return [
@@ -84,22 +94,23 @@ extension BrightSide {
8494 " /Applications/MxTube.app " ,
8595 " /Applications/RockApp.app " ,
8696 " /Applications/SBSettings.app " ,
87- " /Applications/WinterBoard.app "
97+ " /Applications/WinterBoard.app " ,
98+ " /Applications/Activator.app " ,
99+ " /Applications/BytaFont.app " ,
100+ " /Applications/Filza.app "
88101 ]
89102 }
90103
91104 static var suspiciousSystemDir : [ String ] {
92105 return [
93106 " /private/var/lib/apt " ,
94- " /private/var/lib/apt/ " ,
95107 " /private/var/lib/cydia " ,
96108 " /private/var/mobile/Library/SBSettings/Themes " ,
97109 " /private/var/stash " ,
98110 " /usr/bin/sshd " ,
99- " /usr/libexec/sftp-server " ,
100- " /usr/sbin/sshd " ,
101111 " /etc/apt " ,
102- " /bin/bash "
112+ " /usr/libexec/cydia " ,
113+ " /private/var/jb "
103114 ]
104115 }
105116
@@ -110,8 +121,40 @@ extension BrightSide {
110121 " /private/var/tmp/cydia.log " ,
111122 " /System/Library/LaunchDaemons/com.ikey.bbot.plist " ,
112123 " /System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist " ,
113- " /Library/MobileSubstrate/MobileSubstrate.dylib "
124+ " /Library/MobileSubstrate/MobileSubstrate.dylib " ,
125+ " /private/var/db/crashreporter/LiveClock.plist " ,
126+ " /System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist " ,
127+ " /usr/lib/libsubstitute.dylib " ,
128+ " /private/var/lib/apt/periodic "
129+ ]
130+ }
131+
132+ static var suspiciousURLs : [ String ] {
133+ return [
134+ " cydia://package/com.example.package " ,
135+ " filza:// " ,
136+ " undecimus:// " ,
137+ " zbra:// " ,
138+ " sileo:// "
114139 ]
115140 }
116141
117142}
143+
144+ // MARK: - Private Methods
145+
146+ private extension BrightSide {
147+
148+ static func isSimulatorRuntime( ) -> Bool {
149+ return ProcessInfo . processInfo. environment [ " SIMULATOR_DEVICE_NAME " ] != nil
150+ }
151+
152+ static func isSimulatorCompile( ) -> Bool {
153+ #if targetEnvironment(simulator)
154+ return true
155+ #else
156+ return false
157+ #endif
158+ }
159+
160+ }
0 commit comments