IOS - Jailbreak Erkennung
Quellenangabe:
"Apps programmieren für iPhone und iPad - Das umfassende Handbuch" (link)
Autoren: Klaus M. Rodewig, Clemens Wagner
root partition rw
NSError *error = nil;
NSString *fstab = [NSString stringWithContentsOfFile:@"/etc/fstab" encoding:NSISOLatin1StringEncoding error:&error];
NSRange textRange;
NSString *substring = [NSString stringWithString:@" / hfs rw"];
textRange =[[fstab lowercaseString] rangeOfString:[substring lowercaseString]];
if(textRange.location != NSNotFound) {
NSLog(@"[+] / writeable");
forecast += 25;
} else {
NSLog(@"[+] / not writeable");
}
locate Cydia
NSString *docsDir = @"/Applications/";
NSFileManager *localFileManager=[[NSFileManager alloc] init];
error =nil;
NSArray *dirEnum = [localFileManager contentsOfDirectoryAtPath:docsDir error:&error];
for(id object in dirEnum){
if([object isEqual:@"Cydia.app"]){
forecast += 25;
NSLog(@"[+] Cydia found");
}
}
write in /
if([localFileManager createDirectoryAtPath:@"/tmp/..." withIntermediateDirectories:NO attributes:nil error:&error]){
forecast += 25;
NSLog(@"[+] could write to /tmp");
[localFileManager removeItemAtPath:@"/tmp/..." error:&error];
} else {
NSLog(@"[+] error creating dir: %@", error);
}
find sshd
if([localFileManager fileExistsAtPath:@"/usr/sbin/sshd"]){
forecast += 25;
NSLog(@"[+] sshd found");
}
find apt
if([localFileManager fileExistsAtPath:@"/private/var/lib/apt"]){
forecast += 25;
NSLog(@"[+] apt found");
}
find bash
if([localFileManager fileExistsAtPath:@"/bin/bash"]){
forecast += 25;
NSLog(@"[+] bash found");
}