// // fuck-signing-services.m // Meridian // // Created by Ben Sparkes on 07/01/2018. // Copyright © 2018 Ben Sparkes. All rights reserved. // #import "fucksigningservices.h" @interface NSString (profileHelper) - (id)dictionaryFromString; @end @implementation NSString (profileHelper) // convert basic XML plist string from the profile and convert it into a mutable nsdictionary - (id)dictionaryFromString { NSData *theData = [self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; id theDict = [NSPropertyListSerialization propertyListWithData:theData options:NSPropertyListMutableContainersAndLeaves format:nil error:nil]; return theDict; } @end @implementation fucksigningservices : NSObject // creds @nitoTV/lechium the fuckin' madman // https://github.com/lechium/ProvisioningProfileCleaner/blob/master/ProvisioningProfileCleaner/KBProfileHelper.m#L648 + (Boolean)appIsPirated:(NSString *)profilePath { NSString *fileContents = [NSString stringWithContentsOfFile:profilePath encoding:NSUTF8StringEncoding error:nil]; NSUInteger fileLength = [fileContents length]; if (fileLength == 0) return false; // find NSRange location of "]; // adjust the location of endingRange to include into our newly trimmed string. NSUInteger endingLocation = endingRange.location + endingRange.length; // offset the ending location to trim out the "garbage" before NSRange plistRange = NSMakeRange(startingLocation, endingLocationAdjusted); NSString *plistString = [fileContents substringWithRange:plistRange]; NSMutableDictionary *dict = [plistString dictionaryFromString]; // Grab provisioning entries NSObject *provisionsAllDevices = [dict objectForKey:@"ProvisionsAllDevices"]; NSArray *provisionedDevices = [dict objectForKey:@"ProvisionedDevices"]; // Check whether keys are present & evaluate return (provisionsAllDevices != nil && provisionedDevices == nil); } @end