File tree Expand file tree Collapse file tree 2 files changed +16
-20
lines changed Expand file tree Collapse file tree 2 files changed +16
-20
lines changed Original file line number Diff line number Diff line change @@ -318,8 +318,8 @@ internal class JailbreakChecker {
318318 }
319319
320320 private static func checkDYLD( ) -> CheckResult {
321-
322- let suspiciousLibraries = [
321+
322+ let suspiciousLibraries : Set < String > = [
323323 " SubstrateLoader.dylib " ,
324324 " SSLKillSwitch2.dylib " ,
325325 " SSLKillSwitch.dylib " ,
@@ -347,18 +347,16 @@ internal class JailbreakChecker {
347347 " libcycript "
348348 ]
349349
350- for libraryIndex in 0 ..< _dyld_image_count ( ) {
351-
352- // _dyld_get_image_name returns const char * that needs to be casted to Swift String
353- guard let loadedLibrary = String ( validatingUTF8: _dyld_get_image_name ( libraryIndex) ) else { continue }
354-
355- for suspiciousLibrary in suspiciousLibraries {
356- if loadedLibrary. lowercased ( ) . contains ( suspiciousLibrary. lowercased ( ) ) {
357- return ( false , " Suspicious library loaded: \( loadedLibrary) " )
358- }
350+ for index in 0 ..< _dyld_image_count ( ) {
351+
352+ let imageName = String ( cString: _dyld_get_image_name ( index) )
353+
354+ // The fastest case insensitive contains check.
355+ for library in suspiciousLibraries where imageName. localizedCaseInsensitiveContains ( library) {
356+ return ( false , " Suspicious library loaded: \( imageName) " )
359357 }
360358 }
361-
359+
362360 return ( true , " " )
363361 }
364362
Original file line number Diff line number Diff line change @@ -58,22 +58,20 @@ internal class ReverseEngineeringToolsChecker {
5858
5959 private static func checkDYLD( ) -> CheckResult {
6060
61- let suspiciousLibraries = [
61+ let suspiciousLibraries : Set < String > = [
6262 " FridaGadget " ,
6363 " frida " , // Needle injects frida-somerandom.dylib
6464 " cynject " ,
6565 " libcycript "
6666 ]
6767
68- for libraryIndex in 0 ..< _dyld_image_count ( ) {
68+ for index in 0 ..< _dyld_image_count ( ) {
6969
70- // _dyld_get_image_name returns const char * that needs to be casted to Swift String
71- guard let loadedLibrary = String ( validatingUTF8: _dyld_get_image_name ( libraryIndex) ) else { continue }
70+ let imageName = String ( cString: _dyld_get_image_name ( index) )
7271
73- for suspiciousLibrary in suspiciousLibraries {
74- if loadedLibrary. lowercased ( ) . contains ( suspiciousLibrary. lowercased ( ) ) {
75- return ( false , " Suspicious library loaded: \( loadedLibrary) " )
76- }
72+ // The fastest case insensitive contains check.
73+ for library in suspiciousLibraries where imageName. localizedCaseInsensitiveContains ( library) {
74+ return ( false , " Suspicious library loaded: \( imageName) " )
7775 }
7876 }
7977
You can’t perform that action at this time.
0 commit comments