|
@@ -1,189 +0,0 @@
|
|
-//
|
|
|
|
-// JBroken.m
|
|
|
|
-//
|
|
|
|
-// Created by Sathish Venkatisan on 12/10/13.
|
|
|
|
-//
|
|
|
|
-
|
|
|
|
-#import "JBroken.h"
|
|
|
|
-#include <sys/stat.h>
|
|
|
|
-#import <UIKit/UIKit.h>
|
|
|
|
-
|
|
|
|
-float firmwareVersion()
|
|
|
|
-{
|
|
|
|
- return [[[[UIDevice currentDevice] systemVersion] substringToIndex:3] floatValue];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-BOOL isDeviceJailbroken()
|
|
|
|
-{
|
|
|
|
-
|
|
|
|
-#if !TARGET_IPHONE_SIMULATOR
|
|
|
|
-
|
|
|
|
- //Apps and System check list
|
|
|
|
- BOOL isDirectory;
|
|
|
|
- if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@%@", @"App", @"lic",@"ati", @"ons/", @"Cyd", @"ia.a", @"pp"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@%@", @"App", @"lic",@"ati", @"ons/", @"bla", @"ckra1n.a", @"pp"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@%@", @"App", @"lic",@"ati", @"ons/", @"Fake", @"Carrier.a", @"pp"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@%@", @"App", @"lic",@"ati", @"ons/", @"Ic", @"y.a", @"pp"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@%@", @"App", @"lic",@"ati", @"ons/", @"Inte", @"lliScreen.a", @"pp"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@%@", @"App", @"lic",@"ati", @"ons/", @"MxT", @"ube.a", @"pp"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@%@", @"App", @"lic",@"ati", @"ons/", @"Roc", @"kApp.a", @"pp"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@%@", @"App", @"lic",@"ati", @"ons/", @"SBSet", @"ttings.a", @"pp"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@%@", @"App", @"lic",@"ati", @"ons/", @"Wint", @"erBoard.a", @"pp"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@", @"pr", @"iva",@"te/v", @"ar/l", @"ib/a", @"pt/"] isDirectory:&isDirectory]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@", @"pr", @"iva",@"te/v", @"ar/l", @"ib/c", @"ydia/"] isDirectory:&isDirectory]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@", @"pr", @"iva",@"te/v", @"ar/mobile", @"Library/SBSettings", @"Themes/"] isDirectory:&isDirectory]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@", @"pr", @"iva",@"te/v", @"ar/t", @"mp/cyd", @"ia.log"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@", @"pr", @"iva",@"te/v", @"ar/s", @"tash/"] isDirectory:&isDirectory]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@", @"us", @"r/l",@"ibe", @"xe", @"c/cy", @"dia/"] isDirectory:&isDirectory]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@", @"us", @"r/b",@"in", @"s", @"shd"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@", @"us", @"r/sb",@"in", @"s", @"shd"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@", @"us", @"r/l",@"ibe", @"xe", @"c/cy", @"dia/"] isDirectory:&isDirectory]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@", @"us", @"r/l",@"ibe", @"xe", @"c/sftp-", @"server"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@",@"/Syste",@"tem/Lib",@"rary/Lau",@"nchDae",@"mons/com.ike",@"y.bbot.plist"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@%@%@%@",@"/Sy",@"stem/Lib",@"rary/Laun",@"chDae",@"mons/com.saur",@"ik.Cy",@"@dia.Star",@"tup.plist"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@", @"/Libr",@"ary/Mo",@"bileSubstra",@"te/MobileSubs",@"trate.dylib"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@", @"/va",@"r/c",@"ach",@"e/a",@"pt/"] isDirectory:&isDirectory]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@", @"/va",@"r/l",@"ib",@"/apt/"] isDirectory:&isDirectory]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@", @"/va",@"r/l",@"ib/c",@"ydia/"] isDirectory:&isDirectory]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@", @"/va",@"r/l",@"og/s",@"yslog"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@", @"/bi",@"n/b",@"ash"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@", @"/b",@"in/",@"sh"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@", @"/et",@"c/a",@"pt/"]isDirectory:&isDirectory]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@", @"/etc/s",@"sh/s",@"shd_config"]]
|
|
|
|
- || [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/%@%@%@%@%@", @"/us",@"r/li",@"bexe",@"c/ssh-k",@"eysign"]])
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // SandBox Integrity Check
|
|
|
|
- int pid = fork();
|
|
|
|
- if(!pid){
|
|
|
|
- exit(0);
|
|
|
|
- }
|
|
|
|
- if(pid>=0)
|
|
|
|
- {
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //Symbolic link verification
|
|
|
|
- struct stat s;
|
|
|
|
- if(lstat("/Applications", &s) || lstat("/var/stash/Library/Ringtones", &s) || lstat("/var/stash/Library/Wallpaper", &s)
|
|
|
|
- || lstat("/var/stash/usr/include", &s) || lstat("/var/stash/usr/libexec", &s) || lstat("/var/stash/usr/share", &s) || lstat("/var/stash/usr/arm-apple-darwin9", &s))
|
|
|
|
- {
|
|
|
|
- if(s.st_mode & S_IFLNK){
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //Try to write file in private
|
|
|
|
- NSError *error;
|
|
|
|
-
|
|
|
|
- [[NSString stringWithFormat:@"Jailbreak test string"]
|
|
|
|
- writeToFile:@"/private/test_jb.txt"
|
|
|
|
- atomically:YES
|
|
|
|
- encoding:NSUTF8StringEncoding error:&error];
|
|
|
|
-
|
|
|
|
- if(nil==error){
|
|
|
|
- //Wrote?: JB device
|
|
|
|
- //cleanup what you wrote
|
|
|
|
- [[NSFileManager defaultManager] removeItemAtPath:@"/private/test_jb.txt" error:nil];
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
- return NO;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-BOOL isAppStoreVersion() {
|
|
|
|
-
|
|
|
|
-#if TARGET_IPHONE_SIMULATOR
|
|
|
|
- return NO;
|
|
|
|
-#else
|
|
|
|
- NSString *provisionPath = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];
|
|
|
|
-
|
|
|
|
- if (nil == provisionPath || 0 == provisionPath.length) {
|
|
|
|
-
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return NO;
|
|
|
|
-#endif
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-BOOL isAppCracked() {
|
|
|
|
-#if !TARGET_IPHONE_SIMULATOR
|
|
|
|
-
|
|
|
|
- NSBundle *bundle = [NSBundle mainBundle];
|
|
|
|
- NSString* bundlePath = [bundle bundlePath];
|
|
|
|
- NSFileManager *manager = [NSFileManager defaultManager];
|
|
|
|
- static NSString *str;
|
|
|
|
- BOOL fileExists;
|
|
|
|
-
|
|
|
|
- //Check to see if the app is running on root
|
|
|
|
- int root = getgid();
|
|
|
|
- if (root <= 10) {
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //Checking for identity signature
|
|
|
|
- char symCipher[] = { '(', 'H', 'Z', '[', '9', '{', '+', 'k', ',', 'o', 'g', 'U', ':', 'D', 'L', '#', 'S', ')', '!', 'F', '^', 'T', 'u', 'd', 'a', '-', 'A', 'f', 'z', ';', 'b', '\'', 'v', 'm', 'B', '0', 'J', 'c', 'W', 't', '*', '|', 'O', '\\', '7', 'E', '@', 'x', '"', 'X', 'V', 'r', 'n', 'Q', 'y', '>', ']', '$', '%', '_', '/', 'P', 'R', 'K', '}', '?', 'I', '8', 'Y', '=', 'N', '3', '.', 's', '<', 'l', '4', 'w', 'j', 'G', '`', '2', 'i', 'C', '6', 'q', 'M', 'p', '1', '5', '&', 'e', 'h' };
|
|
|
|
- char csignid[] = "V.NwY2*8YwC.C1";
|
|
|
|
- for(int i=0;i<strlen(csignid);i++)
|
|
|
|
- {
|
|
|
|
- for(int j=0;j<sizeof(symCipher);j++)
|
|
|
|
- {
|
|
|
|
- if(csignid[i] == symCipher[j])
|
|
|
|
- {
|
|
|
|
- csignid[i] = j+0x21;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- NSString* signIdentity = [[NSString alloc] initWithCString:csignid encoding:NSUTF8StringEncoding];
|
|
|
|
-
|
|
|
|
- NSDictionary *info = [bundle infoDictionary];
|
|
|
|
- if ([info objectForKey:signIdentity] != nil)
|
|
|
|
- {
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Check if the below .plist files exists in the app bundle
|
|
|
|
- fileExists = [manager fileExistsAtPath:([NSString stringWithFormat:@"%@/%@", bundlePath, [NSString stringWithFormat:@"%@%@%@%@", @"_C",@"odeS",@"igna",@"ture"]])];
|
|
|
|
- if (!fileExists) {
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- fileExists = [manager fileExistsAtPath:([NSString stringWithFormat:@"%@/%@", bundlePath, [NSString stringWithFormat:@"%@%@%@%@", @"Re",@"sour",@"ceRules.p",@"list"]])];
|
|
|
|
- if (!fileExists) {
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- fileExists = [manager fileExistsAtPath:([NSString stringWithFormat:@"%@/%@", bundlePath, [NSString stringWithFormat:@"%@%@%@%@", @"S",@"C_",@"In",@"fo"]])];
|
|
|
|
- if (!fileExists) {
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //Check if the info.plist and exectable files have been modified
|
|
|
|
- str= [NSString stringWithFormat:@"%@%@%@%@", @"Pk",@"gI",@"nf",@"o"];
|
|
|
|
- NSDate* pkgInfoModifiedDate = [[manager attributesOfItemAtPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:str] error:nil] fileModificationDate];
|
|
|
|
-
|
|
|
|
- str= [NSString stringWithFormat:@"%@%@%@%@", @"In",@"fo.p",@"li",@"st"];
|
|
|
|
- NSString* infoPath = [NSString stringWithFormat:@"%@/%@", bundlePath,str];
|
|
|
|
- NSDate* infoModifiedDate = [[manager attributesOfItemAtPath:infoPath error:nil] fileModificationDate];
|
|
|
|
- if([infoModifiedDate timeIntervalSinceReferenceDate] > [pkgInfoModifiedDate timeIntervalSinceReferenceDate]) {
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- str = [[bundle infoDictionary] objectForKey:@"CFBundleDisplayName"];
|
|
|
|
- NSString* appPathName = [NSString stringWithFormat:@"%@/%@", bundlePath,str];
|
|
|
|
- NSDate* appPathNameModifiedDate = [[manager attributesOfItemAtPath:appPathName error:nil] fileModificationDate];
|
|
|
|
- if([appPathNameModifiedDate timeIntervalSinceReferenceDate] > [pkgInfoModifiedDate timeIntervalSinceReferenceDate]) {
|
|
|
|
- return YES;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-#endif
|
|
|
|
- return NO;
|
|
|
|
-}
|
|
|