├── README.md └── main.m /README.md: -------------------------------------------------------------------------------- 1 | How to easily build it 2 | ===================== 3 | 4 | Just run the command below in your terminal: 5 | 6 | curl https://raw.githubusercontent.com/0xc010d/mobileprovision-read/master/main.m | clang -framework Foundation -framework Security -o /usr/local/bin/mobileprovision-read -x objective-c - 7 | 8 | This command would download the source, compile it and put resulting binary to `/usr/local/bin/mobileprovision-read` 9 | 10 | Run `mobileprovision-read` without any parameter to get short help. 11 | 12 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Eugene Solodovnykov 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #import 24 | #import 25 | 26 | int main(int argc, const char *argv[]) { 27 | NSUserDefaults *arguments = [NSUserDefaults standardUserDefaults]; 28 | NSString *file = [arguments stringForKey:@"f"]; 29 | NSString *option = [arguments stringForKey:@"o"]; 30 | 31 | if (!file) { 32 | printf("\ 33 | \033[1m%1$s\033[0m -- mobileprovision files querying tool.\n\ 34 | \n\ 35 | \033[1mUSAGE\033[0m\n\ 36 | \033[1m%1$s\033[0m \033[1m-f\033[0m \033[4mfileName\033[0m [\033[1m-o\033[0m \033[4moption\033[0m]\n\n\ 37 | \033[1mOPTIONS\033[0m\n\ 38 | \033[1mtype\033[0m – prints mobileprovision profile type (debug, ad-hoc, enterprise, appstore)\n\ 39 | \033[1mappid\033[0m – prints application identifier\n\ 40 | Will print raw provision's plist if option is not specified.\n\ 41 | You can also use \033[1mkey path\033[0m as an option.\n\ 42 | \n\ 43 | \033[1mEXAMPLES\033[0m\n\ 44 | %1$s -f test.mobileprovision -o type\n\ 45 | Prints profile type\n\ 46 | \n\ 47 | %1$s -f test.mobileprovision -o UUID\n\ 48 | Prints profile UUID\n\ 49 | \n\ 50 | %1$s -f test.mobileprovision -o ProvisionedDevices\n\ 51 | Prints provisioned devices UDIDs\n\ 52 | \n\ 53 | %1$s -f test.mobileprovision -o Entitlements.get-task-allow\n\ 54 | Prints 0 if profile doesn't allow debugging 1 otherwise\n\ 55 | ", argv[0]); 56 | return 1001; 57 | } 58 | 59 | CMSDecoderRef decoder = NULL; 60 | CFDataRef dataRef = NULL; 61 | NSString *plistString = nil; 62 | NSDictionary *plist = nil; 63 | 64 | @try { 65 | CMSDecoderCreate(&decoder); 66 | NSData *fileData = [NSData dataWithContentsOfFile:file]; 67 | CMSDecoderUpdateMessage(decoder, fileData.bytes, fileData.length); 68 | CMSDecoderFinalizeMessage(decoder); 69 | CMSDecoderCopyContent(decoder, &dataRef); 70 | plistString = [[[NSString alloc] initWithData:(NSData *)dataRef encoding:NSUTF8StringEncoding] autorelease]; 71 | plist = [plistString propertyList]; 72 | } 73 | @catch (NSException *exception) { 74 | printf("Could not decode file.\n"); 75 | } 76 | @finally { 77 | if (decoder) CFRelease(decoder); 78 | if (dataRef) CFRelease(dataRef); 79 | } 80 | 81 | if (!option) { 82 | printf("%s", [plistString UTF8String]); 83 | } 84 | if ([option isEqualToString:@"type"]) { 85 | if ([plist valueForKeyPath:@"ProvisionedDevices"]){ 86 | if ([[plist valueForKeyPath:@"Entitlements.get-task-allow"] boolValue]) { 87 | printf("debug\n"); 88 | } 89 | else { 90 | printf("ad-hoc\n"); 91 | } 92 | } 93 | else if ([[plist valueForKeyPath:@"ProvisionsAllDevices"] boolValue]) { 94 | printf("enterprise\n"); 95 | } 96 | else { 97 | printf("appstore\n"); 98 | } 99 | } 100 | else if ([option isEqualToString:@"appid"]) { 101 | NSString *applicationIdentifier = [plist valueForKeyPath:@"Entitlements.application-identifier"]; 102 | NSString *prefix = [[[plist valueForKeyPath:@"ApplicationIdentifierPrefix"] objectAtIndex:0] stringByAppendingString:@"."]; 103 | printf("%s\n", [[applicationIdentifier stringByReplacingOccurrencesOfString:prefix withString:@""] UTF8String]); 104 | } 105 | else { 106 | id result = [plist valueForKeyPath:option]; 107 | if (result) { 108 | if ([result isKindOfClass:[NSArray class]] && [result count]) { 109 | printf("%s\n", [[result componentsJoinedByString:@"\n"] UTF8String]); 110 | } 111 | else { 112 | printf("%s\n", [[result description] UTF8String]); 113 | } 114 | } 115 | } 116 | 117 | return 0; 118 | } 119 | --------------------------------------------------------------------------------