Skip to content

Instantly share code, notes, and snippets.

@jcayzac
Created July 9, 2015 00:18
Show Gist options
  • Save jcayzac/c8c1435191522440c561 to your computer and use it in GitHub Desktop.
Save jcayzac/c8c1435191522440c561 to your computer and use it in GitHub Desktop.
Fun with embedded.mobileprovision
NSData *provisioningProfile = nil;
NSData *raw = [NSData dataWithContentsOfURL:[NSBundle.mainBundle URLForResource:@"embedded" withExtension:@"mobileprovision"]];
char *start = memmem(raw.bytes,
raw.length,
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0",
47);
if (start) {
char *end = memmem(start,
(uintptr_t)start - raw.length,
"</plist>",
8);
if (end) {
provisioningProfile = [NSData dataWithBytes:start length:8 + end - start];
}
}
if (provisioningProfile) {
NSDictionary* plist = [NSPropertyListSerialization propertyListWithData:provisioningProfile
options:NSPropertyListImmutable
format:0
error:0];
NSLog(@"\n\n\nTeam name: %@", plist[@"TeamName"]);
if ([plist[@"ProvisionsAllDevices"] boolValue]) {
NSLog(@"Enterprise");
} else if ([plist[@"ProvisionedDevices"] count] > 0) {
if ([plist[@"Entitlements"][@"get-task-allow"] boolValue]) {
NSLog(@"Development");
} else {
NSLog(@"Ad Hoc");
}
} else {
NSLog(@"App Store");
}
}
@MartinLau7
Copy link

nice! it's so cool! XD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment