Last active
June 26, 2016 20:04
-
-
Save olxios/6f79102a3cd68c18a2feb7359a9e768d to your computer and use it in GitHub Desktop.
How to detect jailbroken device programmatically? http://swiftiostutorials.com/detect-jailbroken-device-programmatically/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <sys/stat.h> | |
void checkJailbreakSymlinks() | |
{ | |
NSArray *linksChecks = @[LOO_CRYPT_STR_N("/Applications", 13), | |
LOO_CRYPT_STR_N("/usr/libexec", 12), | |
LOO_CRYPT_STR_N("/usr/share", 10), | |
LOO_CRYPT_STR_N("/Library/Wallpaper", 18), | |
LOO_CRYPT_STR_N("/usr/include", 12)]; | |
for (NSString *checkPath in linksChecks) | |
{ | |
checkJailbreakSymLink(checkPath); | |
} | |
} | |
/* | |
The lstat() function shall be equivalent to stat(), | |
except when path refers to a symbolic link. | |
In that case lstat() shall return information about the link, | |
while stat() shall return information about the file the link references. | |
*/ | |
void checkJailbreakSymLink(NSString *checkPath) | |
{ | |
struct stat s; | |
if (lstat([checkPath UTF8String], &s) == 0) | |
{ | |
if (S_ISLNK(s.st_mode) == 1) | |
{ | |
foundJailbrokenDevice(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void checkJailbreakFiles() | |
{ | |
NSArray *fileChecks = @[LOO_CRYPT_STR_N("/bin/bash", 9), | |
LOO_CRYPT_STR_N("/etc/apt", 8), | |
LOO_CRYPT_STR_N("/usr/sbin/sshd", 14), | |
LOO_CRYPT_STR_N("/Library/MobileSubstrate/MobileSubstrate.dylib", 46), | |
LOO_CRYPT_STR_N("/Applications/Cydia.app", 23), | |
LOO_CRYPT_STR_N("/bin/sh", 7), | |
LOO_CRYPT_STR_N("/var/cache/apt", 14), | |
LOO_CRYPT_STR_N("/var/tmp/cydia.log", 18)]; | |
for (NSString *checkPath in fileChecks) | |
{ | |
checkJailbreakFile(checkPath); | |
} | |
} | |
void checkJailbreakFile(NSString *checkPath) | |
{ | |
struct stat s; | |
if (stat([checkPath UTF8String], &s) == 0) | |
{ | |
foundJailbrokenDevice(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void checkReadWritePermissions() | |
{ | |
if([[UIApplication sharedApplication] canOpenURL: | |
[NSURL URLWithString:LOO_CRYPT_STR_N("cydia://package/com.com.com", 27)]]) | |
{ | |
foundJailbrokenDevice(); | |
} | |
NSError *error; | |
NSString *stringToBeWritten = @"0"; | |
[stringToBeWritten writeToFile:LOO_CRYPT_STR_N("/private/jailbreak.test", 23) | |
atomically:YES | |
encoding:NSUTF8StringEncoding error:&error]; | |
if (error == nil) | |
{ | |
foundJailbrokenDevice(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment