Created
November 23, 2010 13:59
-
-
Save jessearmand/711794 to your computer and use it in GitHub Desktop.
A command line tool to parse .mobileprovision file
This file contains 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
// | |
// © 2008 Eugene Solodovnykov | |
// http://idevblog.info/mobileprovision-files-structure-and-reading/ | |
// | |
#import <Foundation/Foundation.h> | |
int main (int argc, const char * argv[]) { | |
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
if (argc < 3) { | |
printf("Usage: mpParse -f <fileName> [-o <option>]\n"); | |
return 1001; | |
} | |
//get arguments | |
NSUserDefaults *arguments = [NSUserDefaults standardUserDefaults]; | |
NSString *fileName = [arguments stringForKey:@"f"]; | |
NSString *propertyName = [arguments stringForKey:@"o"]; | |
if (!fileName) { | |
fileName = [arguments stringForKey:@"-file"]; | |
if (!fileName) { | |
return 1001; | |
} | |
} | |
if (!propertyName) { | |
propertyName = [arguments stringForKey:@"-option"]; | |
if (!propertyName) { | |
propertyName = @"type"; | |
} | |
} | |
//get plist XML | |
NSString *fileString = [[NSString alloc] initWithContentsOfFile:fileName]; | |
NSScanner *scanner = [[NSScanner alloc] initWithString:fileString]; | |
[fileString release]; | |
if ([scanner scanUpToString:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" intoString:NULL]) { | |
NSString *plistString; | |
if ([scanner scanUpToString:@"</plist>" intoString:&plistString]) { | |
[scanner release]; | |
NSDictionary *plist = [[plistString stringByAppendingString:@"</plist>"] propertyList]; | |
// get profile type | |
// possible types: | |
// ad-hoc | |
// appstore | |
// debug | |
if ([propertyName isEqualToString:@"type"]) { | |
if ([plist valueForKeyPath:@"ProvisionedDevices"]) { | |
if ([[plist valueForKeyPath:@"Entitlements.get-task-allow"] boolValue]) { | |
printf("debug\n"); | |
} else { | |
printf("ad-hoc\n"); | |
} | |
} else { | |
printf("appstore\n"); | |
} | |
} else | |
// get the UUID of the profile | |
if ([propertyName isEqualToString:@"uuid"]) { | |
printf("%s\n", [[plist valueForKeyPath:@"UUID"] cStringUsingEncoding:NSUTF8StringEncoding]); | |
} else | |
// get the supported devices list | |
if ([propertyName isEqualToString:@"devices"]) { | |
NSArray *devices = [plist valueForKeyPath:@"ProvisionedDevices"]; | |
if (devices) { | |
for (NSString *deviceId in devices) { | |
printf("%s\n", [deviceId cStringUsingEncoding:NSUTF8StringEncoding]); | |
} | |
} | |
} | |
} else { | |
[scanner release]; | |
return 1002; | |
} | |
} else { | |
[scanner release]; | |
return 1002; | |
} | |
[pool drain]; | |
return 0; | |
} |
Actually the blog has moved to http://0xc010d.net/mobileprovision-files-structure-and-reading/ and the related GitHub repo is https://github.com/0xc010d/mobileprovision-read
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like the blog related to this file is down, so I threw together a simple project and compiled it. You can download the binary at https://github.com/dwelch2344/mpParse/blob/master/build/mpParse (though GitHub adds .txt to the end of the file, so you'll probably want to strip that out)