007.代码判断设备是否越狱
Swift
import UIKit
public struct Jailbreak {
private enum JailbreakType : String {
case dydia
= "/Applications/Cydia.app"
case limera1n
= "/Applications/limera1n.app"
case greenpois0n
= "/Applications/greenpois0n.app"
case blackra1n
= "/Applications/blackra1n.app"
case blacksn0w
= "/Applications/blacksn0w.app"
case redsn0w
= "/Applications/redsn0w.app"
case absinthe
= "/Applications/Absinthe.app"
case bash
= "/bin/bash"
case sshd
= "/usr/sbin/sshd"
case etc_apt
= "/etc/apt"
case lib_apt
= "/private/var/lib/apt"
case substrate
= "/Library/MobileSubstrate/MobileSubstrate.dylib"
case libsystem_kernel
= "/usr/lib/system/libsystem_kernel.dylib"
}
public static var isJailbreakForFilePath
: Bool {
guard FileManager.default.fileExists(atPath
: JailbreakType.dydia
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.limera1n
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.greenpois0n
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.blackra1n
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.blacksn0w
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.redsn0w
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.absinthe
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.bash
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.sshd
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.etc_apt
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.lib_apt
.rawValue
) else {
return true
}
guard FileManager.default.fileExists(atPath
: JailbreakType.substrate
.rawValue
) else {
return true
}
guard !FileManager.default.fileExists(atPath
: JailbreakType.libsystem_kernel
.rawValue
) else {
return true
}
return false
}
}
OC
if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/Applications/Cydia.app"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/Applications/Cydia.app"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/Applications/greenpois0n.app"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/Applications/blacksn0w.app"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/Applications/redsn0w.app"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/Applications/Absinthe.app"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/bin/bash"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/usr/sbin/sshd"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/etc/apt"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/private/var/lib/apt"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/Library/MobileSubstrate/MobileSubstrate.dylib"]) {
NSLog(@"此设备已越狱");
} else if ([[NSFileManager defaultManager
] fileExistsAtPath
:@"/usr/lib/system/libsystem_kernel.dylib"]) {
NSLog(@"此设备未越狱");
}else {
NSLog(@"此设备未越狱");
}
XMind - Trial Version