diff --git a/LSApplicationProxy+AltList.h b/LSApplicationProxy+AltList.h new file mode 100644 index 0000000..055c4de --- /dev/null +++ b/LSApplicationProxy+AltList.h @@ -0,0 +1,37 @@ +#import +#import + +@interface LSApplicationRecord : NSObject +@property (nonatomic,readonly) NSArray* appTags; // 'hidden' +@property (getter=isLaunchProhibited,readonly) BOOL launchProhibited; +@end + +@interface LSApplicationProxy (Additions) +@property (readonly, nonatomic) NSString *shortVersionString; +@property (nonatomic,readonly) NSString* localizedName; +@property (nonatomic,readonly) NSString* applicationType; // (User/System) +@property (nonatomic,readonly) NSArray* appTags; // 'hidden' +@property (getter=isLaunchProhibited,nonatomic,readonly) BOOL launchProhibited; ++ (instancetype)applicationProxyForIdentifier:(NSString*)identifier; +- (LSApplicationRecord*)correspondingApplicationRecord; +@end + +@interface LSApplicationWorkspace (Additions) +- (void)addObserver:(id)arg1; +- (void)removeObserver:(id)arg1; +- (void)enumerateApplicationsOfType:(NSUInteger)type block:(void (^)(LSApplicationProxy*))block; +@end + +@interface LSApplicationProxy (AltList) +- (BOOL)atl_isSystemApplication; +- (BOOL)atl_isUserApplication; +- (BOOL)atl_isHidden; +- (NSString*)atl_fastDisplayName; +- (NSString*)atl_nameToDisplay; +- (NSString*)atl_shortVersionString; +@property (nonatomic,readonly) NSString* atl_bundleIdentifier; +@end + +@interface LSApplicationWorkspace (AltList) +- (NSArray*)atl_allInstalledApplications; +@end \ No newline at end of file diff --git a/LSApplicationProxy+AltList.m b/LSApplicationProxy+AltList.m new file mode 100644 index 0000000..a0ab461 --- /dev/null +++ b/LSApplicationProxy+AltList.m @@ -0,0 +1,183 @@ +#import +#import "LSApplicationProxy+AltList.h" + +@implementation LSApplicationProxy (AltList) + +- (BOOL)atl_isSystemApplication +{ + return [self.applicationType isEqualToString:@"System"] && ![self atl_isHidden]; +} + +- (BOOL)atl_isUserApplication +{ + return [self.applicationType isEqualToString:@"User"] && ![self atl_isHidden]; +} + +// the tag " hidden " is also valid, so we need to check if any strings contain "hidden" instead +BOOL tagArrayContainsTag(NSArray* tagArr, NSString* tag) +{ + if(!tagArr || !tag) return NO; + + __block BOOL found = NO; + + [tagArr enumerateObjectsUsingBlock:^(NSString* tagToCheck, NSUInteger idx, BOOL* stop) + { + if(![tagToCheck isKindOfClass:[NSString class]]) + { + return; + } + + if([tagToCheck rangeOfString:tag options:0].location != NSNotFound) + { + found = YES; + *stop = YES; + } + }]; + + return found; +} + +// always returns NO on iOS 7 +- (BOOL)atl_isHidden +{ + NSArray* appTags; + NSArray* recordAppTags; + NSArray* sbAppTags; + + BOOL launchProhibited = NO; + + if([self respondsToSelector:@selector(correspondingApplicationRecord)]) + { + // On iOS 14, self.appTags is always empty but the application record still has the correct ones + LSApplicationRecord* record = [self correspondingApplicationRecord]; + recordAppTags = record.appTags; + launchProhibited = record.launchProhibited; + } + if([self respondsToSelector:@selector(appTags)]) + { + appTags = self.appTags; + } + if(!launchProhibited && [self respondsToSelector:@selector(isLaunchProhibited)]) + { + launchProhibited = self.launchProhibited; + } + + NSURL* bundleURL = self.bundleURL; + if(bundleURL && [bundleURL checkResourceIsReachableAndReturnError:nil]) + { + NSBundle* bundle = [NSBundle bundleWithURL:bundleURL]; + sbAppTags = [bundle objectForInfoDictionaryKey:@"SBAppTags"]; + } + + BOOL isWebApplication = ([self.atl_bundleIdentifier rangeOfString:@"com.apple.webapp" options:NSCaseInsensitiveSearch].location != NSNotFound); + return tagArrayContainsTag(appTags, @"hidden") || tagArrayContainsTag(recordAppTags, @"hidden") || tagArrayContainsTag(sbAppTags, @"hidden") || isWebApplication || launchProhibited; +} + +// Getting the display name is slow (up to 2ms) because it uses an IPC call +// this stacks up if you do it for every single application +// This method provides a faster way (around 0.5ms) to get the display name +// This reduces the overall time needed to sort the applications from ~230 to ~120ms on my test device +- (NSString*)atl_fastDisplayName +{ + NSString* cachedDisplayName = [self valueForKey:@"_localizedName"]; + if(cachedDisplayName && ![cachedDisplayName isEqualToString:@""]) + { + return cachedDisplayName; + } + + NSString* localizedName; + + NSURL* bundleURL = self.bundleURL; + if(!bundleURL || ![bundleURL checkResourceIsReachableAndReturnError:nil]) + { + localizedName = self.localizedName; + } + else + { + NSBundle* bundle = [NSBundle bundleWithURL:bundleURL]; + + localizedName = [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"]; + if(![localizedName isKindOfClass:[NSString class]]) localizedName = nil; + if(!localizedName || [localizedName isEqualToString:@""]) + { + localizedName = [bundle objectForInfoDictionaryKey:@"CFBundleName"]; + if(![localizedName isKindOfClass:[NSString class]]) localizedName = nil; + if(!localizedName || [localizedName isEqualToString:@""]) + { + localizedName = [bundle objectForInfoDictionaryKey:@"CFBundleExecutable"]; + if(![localizedName isKindOfClass:[NSString class]]) localizedName = nil; + if(!localizedName || [localizedName isEqualToString:@""]) + { + //last possible fallback: use slow IPC call + localizedName = self.localizedName; + } + } + } + } + + [self setValue:localizedName forKey:@"_localizedName"]; + return localizedName; +} + +- (NSString*)atl_nameToDisplay +{ + NSString* localizedName = [self atl_fastDisplayName]; + + if([self.atl_bundleIdentifier rangeOfString:@"carplay" options:NSCaseInsensitiveSearch].location != NSNotFound) + { + if([localizedName rangeOfString:@"carplay" options:NSCaseInsensitiveSearch range:NSMakeRange(0, localizedName.length) locale:[NSLocale currentLocale]].location == NSNotFound) + { + return [localizedName stringByAppendingString:@" (CarPlay)"]; + } + } + + return localizedName; +} + +-(id)atl_bundleIdentifier +{ + // iOS 8-14 + if([self respondsToSelector:@selector(bundleIdentifier)]) + { + return [self bundleIdentifier]; + } + // iOS 7 + else + { + return [self applicationIdentifier]; + } +} + +- (NSString *)atl_shortVersionString { + NSString *version = self.shortVersionString; + if (version == nil || [version isEqualToString:@""]) { + version = @"1.0"; + } + + return version; +} + +@end + +@implementation LSApplicationWorkspace (AltList) + +- (NSArray*)atl_allInstalledApplications +{ + if(![self respondsToSelector:@selector(enumerateApplicationsOfType:block:)]) + { + return [self allInstalledApplications]; + } + + NSMutableArray* installedApplications = [NSMutableArray new]; + [self enumerateApplicationsOfType:0 block:^(LSApplicationProxy* appProxy) + { + [installedApplications addObject:appProxy]; + }]; + [self enumerateApplicationsOfType:1 block:^(LSApplicationProxy* appProxy) + { + [installedApplications addObject:appProxy]; + }]; + return installedApplications; +} + +@end \ No newline at end of file diff --git a/Makefile b/Makefile index 6c66155..7ad6324 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ include $(THEOS)/makefiles/common.mk APPLICATION_NAME = TrollDecrypt TrollDecrypt_FILES = SSZipArchive/minizip/unzip.c SSZipArchive/minizip/crypt.c SSZipArchive/minizip/ioapi_buf.c SSZipArchive/minizip/ioapi_mem.c SSZipArchive/minizip/ioapi.c SSZipArchive/minizip/minishared.c SSZipArchive/minizip/zip.c SSZipArchive/minizip/aes/aes_ni.c SSZipArchive/minizip/aes/aescrypt.c SSZipArchive/minizip/aes/aeskey.c SSZipArchive/minizip/aes/aestab.c SSZipArchive/minizip/aes/fileenc.c SSZipArchive/minizip/aes/hmac.c SSZipArchive/minizip/aes/prng.c SSZipArchive/minizip/aes/pwd2key.c SSZipArchive/minizip/aes/sha1.c SSZipArchive/SSZipArchive.m -TrollDecrypt_FILES += main.m TDAppDelegate.m TDRootViewController.m TDDumpDecrypted.m TDUtils.m TDFileManagerViewController.m +TrollDecrypt_FILES += main.m TDAppDelegate.m TDRootViewController.m TDDumpDecrypted.m TDUtils.m TDFileManagerViewController.m LSApplicationProxy+AltList.m TrollDecrypt_FRAMEWORKS = UIKit CoreGraphics MobileCoreServices TrollDecrypt_CFLAGS = -fobjc-arc TrollDecrypt_CODESIGN_FLAGS = -Sentitlements.plist @@ -22,4 +22,4 @@ after-stage:: ldid -Sentitlements.plist $(THEOS_STAGING_DIR)/Applications/TrollDecrypt.app/TrollDecrypt cp -a $(THEOS_STAGING_DIR)/Applications/* $(THEOS_STAGING_DIR)/Payload mv $(THEOS_STAGING_DIR)/Payload . - zip -q -r TrollDecrypt.ipa Payload + zip -q -r TrollDecrypt.tipa Payload diff --git a/README.md b/README.md index 87c8827..ffdc4be 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,5 @@ make package - [TrollDecryptor](https://github.com/wh1te4ever/TrollDecryptor) by wh1te4ever - [dumpdecrypted](https://github.com/stefanesser/dumpdecrypted) by Stefan Esser - [bfdecrypt](https://github.com/BishopFox/bfdecrypt) by BishopFox -- App Icon by super.user +- [opa334](https://github.com/opa334) for some pieces of code +- App Icon by super.user \ No newline at end of file diff --git a/Resources/AppIcon-1024.png b/Resources/AppIcon-1024.png new file mode 100644 index 0000000..80f4afb Binary files /dev/null and b/Resources/AppIcon-1024.png differ diff --git a/Resources/AppIcon-20.png b/Resources/AppIcon-20.png new file mode 100644 index 0000000..45d384e Binary files /dev/null and b/Resources/AppIcon-20.png differ diff --git a/Resources/AppIcon-20@2x.png b/Resources/AppIcon-20@2x.png new file mode 100644 index 0000000..57977c1 Binary files /dev/null and b/Resources/AppIcon-20@2x.png differ diff --git a/Resources/AppIcon-20@3x.png b/Resources/AppIcon-20@3x.png new file mode 100644 index 0000000..ba994e2 Binary files /dev/null and b/Resources/AppIcon-20@3x.png differ diff --git a/Resources/AppIcon-29.png b/Resources/AppIcon-29.png new file mode 100644 index 0000000..bc56c43 Binary files /dev/null and b/Resources/AppIcon-29.png differ diff --git a/Resources/AppIcon-29@2x.png b/Resources/AppIcon-29@2x.png new file mode 100644 index 0000000..b54c1ee Binary files /dev/null and b/Resources/AppIcon-29@2x.png differ diff --git a/Resources/AppIcon-29@3x.png b/Resources/AppIcon-29@3x.png new file mode 100644 index 0000000..1e71e1d Binary files /dev/null and b/Resources/AppIcon-29@3x.png differ diff --git a/Resources/AppIcon-40.png b/Resources/AppIcon-40.png new file mode 100644 index 0000000..57977c1 Binary files /dev/null and b/Resources/AppIcon-40.png differ diff --git a/Resources/AppIcon-40@2x.png b/Resources/AppIcon-40@2x.png new file mode 100644 index 0000000..d13455b Binary files /dev/null and b/Resources/AppIcon-40@2x.png differ diff --git a/Resources/AppIcon-40@3x.png b/Resources/AppIcon-40@3x.png new file mode 100644 index 0000000..88bdedd Binary files /dev/null and b/Resources/AppIcon-40@3x.png differ diff --git a/Resources/AppIcon-60@2x.png b/Resources/AppIcon-60@2x.png new file mode 100644 index 0000000..88bdedd Binary files /dev/null and b/Resources/AppIcon-60@2x.png differ diff --git a/Resources/AppIcon-60@3x.png b/Resources/AppIcon-60@3x.png new file mode 100644 index 0000000..19f9796 Binary files /dev/null and b/Resources/AppIcon-60@3x.png differ diff --git a/Resources/AppIcon-76.png b/Resources/AppIcon-76.png new file mode 100644 index 0000000..c4c9556 Binary files /dev/null and b/Resources/AppIcon-76.png differ diff --git a/Resources/AppIcon-76@2x.png b/Resources/AppIcon-76@2x.png new file mode 100644 index 0000000..8b4ae00 Binary files /dev/null and b/Resources/AppIcon-76@2x.png differ diff --git a/Resources/AppIcon-83.5@2x.png b/Resources/AppIcon-83.5@2x.png new file mode 100644 index 0000000..86397f6 Binary files /dev/null and b/Resources/AppIcon-83.5@2x.png differ diff --git a/Resources/Info.plist b/Resources/Info.plist index 598a85f..6a24d83 100644 --- a/Resources/Info.plist +++ b/Resources/Info.plist @@ -10,7 +10,10 @@ CFBundleIconFiles - AppIcon60x60 + AppIcon-29 + AppIcon-40 + AppIcon-57 + AppIcon-60 UIPrerenderedIcon @@ -22,8 +25,13 @@ CFBundleIconFiles - AppIcon60x60 - AppIcon76x76~ipad + AppIcon-29 + AppIcon-40 + AppIcon-57 + AppIcon-60 + AppIcon-50 + AppIcon-72 + AppIcon-76 UIPrerenderedIcon @@ -42,7 +50,7 @@ iPhoneOS CFBundleVersion - 1.0 + 1.1 LSRequiresIPhoneOS UIDeviceFamily diff --git a/TDDumpDecrypted.m b/TDDumpDecrypted.m index 36aabda..c10a460 100644 --- a/TDDumpDecrypted.m +++ b/TDDumpDecrypted.m @@ -238,7 +238,8 @@ int find_off_cryptid(const char *filePath) { self.appVersion = appVersion; [self setAppPath:[pathToBinary stringByDeletingLastPathComponent]]; - [self setDocPath:[NSString stringWithFormat:@"%@/Documents", NSHomeDirectory()]]; + // [self setDocPath:[NSString stringWithFormat:@"%@/Documents", NSHomeDirectory()]]; + [self setDocPath:docPath()]; char *lastPartOfAppPath = strdup([[self appPath] UTF8String]); lastPartOfAppPath = strrchr(lastPartOfAppPath, '/') + 1; diff --git a/TDRootViewController.m b/TDRootViewController.m index 1a5e1d0..40dff9d 100644 --- a/TDRootViewController.m +++ b/TDRootViewController.m @@ -18,6 +18,29 @@ self.refreshControl = refreshControl; } +- (void)viewDidAppear:(bool)animated { + [super viewDidAppear:animated]; + + fetchLatestTrollDecryptVersion(^(NSString *latestVersion) { + NSString *currentVersion = trollDecryptVersion(); + NSComparisonResult result = [currentVersion compare:latestVersion options:NSNumericSearch]; + NSLog(@"[trolldecrypter] Current version: %@, Latest version: %@", currentVersion, latestVersion); + if (result == NSOrderedAscending) { + dispatch_async(dispatch_get_main_queue(), ^{ + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Update Available" message:@"An update for TrollDecrypt is available." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; + UIAlertAction *update = [UIAlertAction actionWithTitle:@"Download" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://github.com/donato-fiore/TrollDecrypt/releases/latest"]] options:@{} completionHandler:nil]; + }]; + + [alert addAction:update]; + [alert addAction:cancel]; + [self presentViewController:alert animated:YES completion:nil]; + }); + } + }); +} + - (void)openDocs:(id)sender { TDFileManagerViewController *fmVC = [[TDFileManagerViewController alloc] init]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:fmVC]; diff --git a/TDUtils.h b/TDUtils.h index d7f61de..0d4ab96 100644 --- a/TDUtils.h +++ b/TDUtils.h @@ -17,23 +17,6 @@ - (BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2; @end -@interface LSApplicationProxy : NSObject -@property (readonly, nonatomic) NSString *bundleIdentifier; // ivar: _bundleIdentifier -@property (readonly) NSString *shortVersionString; -@property (readonly, nonatomic) NSString *canonicalExecutablePath; -@property (getter=isLaunchProhibited) BOOL launchProhibited; -@property (readonly, nonatomic) NSArray *appTags; -@property(readonly) NSString * applicationType; -- (NSString *)localizedName; -+ (instancetype)applicationProxyForIdentifier:(NSString*)identifier; -@end - -@interface LSApplicationWorkspace : NSObject -+ (instancetype)defaultWorkspace; -- (NSMutableArray *)allApplications; -- (NSArray *)allInstalledApplications; -@end - @interface UIImage (Private) + (UIImage *)_applicationIconImageForBundleIdentifier:(NSString *)bundleIdentifier format:(NSUInteger)format scale:(CGFloat)scale; @end @@ -42,6 +25,7 @@ #define PROC_PIDPATHINFO_SIZE (MAXPATHLEN) #define PROC_PIDPATHINFO_MAXSIZE (4 * MAXPATHLEN) #define PROC_ALL_PIDS 1 + #ifndef DEBUG # define NSLog(...) (void)0 #endif @@ -55,4 +39,7 @@ void decryptApp(NSDictionary *app); void decryptAppWithPID(pid_t pid); void bfinject_rocknroll(pid_t pid, NSString *appName, NSString *version); NSArray *decryptedFileList(void); -NSString *docPath(void); \ No newline at end of file +NSString *docPath(void); +void fetchLatestTrollDecryptVersion(void (^completionHandler)(NSString *version)); +void github_fetchLatedVersion(NSString *repo, void (^completionHandler)(NSString *latestVersion)); +NSString *trollDecryptVersion(void); \ No newline at end of file diff --git a/TDUtils.m b/TDUtils.m index c907ab7..68a5b75 100644 --- a/TDUtils.m +++ b/TDUtils.m @@ -1,5 +1,6 @@ #import "TDUtils.h" #import "TDDumpDecrypted.h" +#import "LSApplicationProxy+AltList.h" UIWindow *alertWindow = NULL; UIWindow *kw = NULL; @@ -10,14 +11,17 @@ UIAlertController *errorController = NULL; NSArray *appList(void) { NSMutableArray *apps = [NSMutableArray array]; - - for (LSApplicationProxy *app in [[LSApplicationWorkspace defaultWorkspace] allInstalledApplications]) { - if (![[app applicationType] isEqualToString:@"User"]) continue; - NSString *bundleID = app.bundleIdentifier; - NSString *name = [app localizedName]; - NSString *version = app.shortVersionString; - NSString *executable = [app canonicalExecutablePath]; + NSArray *installedApplications = [[LSApplicationWorkspace defaultWorkspace] atl_allInstalledApplications]; + [installedApplications enumerateObjectsUsingBlock:^(LSApplicationProxy *proxy, NSUInteger idx, BOOL *stop) { + if (![proxy atl_isUserApplication]) return; + + NSString *bundleID = [proxy atl_bundleIdentifier]; + NSString *name = [proxy atl_nameToDisplay]; + NSString *version = [proxy atl_shortVersionString]; + NSString *executable = proxy.canonicalExecutablePath; + + if (!bundleID || !name || !version || !executable) return; NSDictionary *item = @{ @"bundleID":bundleID, @@ -27,11 +31,11 @@ NSArray *appList(void) { }; [apps addObject:item]; - } - + }]; + NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]; [apps sortUsingDescriptors:@[descriptor]]; - + [apps addObject:@{@"bundleID":@"", @"name":@"", @"version":@"", @"executable":@""}]; return [apps copy]; @@ -42,42 +46,6 @@ NSUInteger iconFormat(void) { } NSArray *sysctl_ps(void) { - // int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0}; - // size_t miblen = 4; - // size_t size; - // int st = sysctl(mib, miblen, NULL, &size, NULL, 0); - // struct kinfo_proc * process = NULL; - // struct kinfo_proc * newprocess = NULL; - - // do { - // size += size / 10; - // newprocess = realloc(process, size); - // if (!newprocess){ - // if (process){ - // free(process); - // } - // return nil; - // } - // process = newprocess; - // st = sysctl(mib, miblen, process, &size, NULL, 0); - // } while (st == -1 && errno == ENOMEM); - - // if (st == 0) { - // if (size % sizeof(struct kinfo_proc) == 0){ - // int nprocess = size / sizeof(struct kinfo_proc); - // if (nprocess){ - // NSMutableArray * array = [[NSMutableArray alloc] init]; - // for (int i = nprocess - 1; i >= 0; i--){ - // NSString *processID = [[NSString alloc] initWithFormat:@"%d", process[i].kp_proc.p_pid]; - // NSString *processName = [[NSString alloc] initWithFormat:@"%s", process[i].kp_proc.p_comm]; - // NSDictionary *dict = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:processID, processName, nil] forKeys:[NSArray arrayWithObjects:@"pid", @"proc_name", nil]]; - // [array addObject:dict]; - // } - // free(process); - // return array; - // } - // } - // } NSMutableArray *array = [[NSMutableArray alloc] init]; int numberOfProcesses = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0); @@ -246,6 +214,7 @@ void bfinject_rocknroll(pid_t pid, NSString *appName, NSString *version) { NSArray *decryptedFileList(void) { NSMutableArray *files = [NSMutableArray array]; + NSMutableArray *fileNames = [NSMutableArray array]; // iterate through all files in the Documents directory NSFileManager *fileManager = [NSFileManager defaultManager]; @@ -257,7 +226,7 @@ NSArray *decryptedFileList(void) { NSString *filePath = [[docPath() stringByAppendingPathComponent:file] stringByStandardizingPath]; NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:filePath error:nil]; - NSDate *modificationDate = [fileAttributes fileModificationDate]; + NSDate *modificationDate = fileAttributes[NSFileModificationDate]; NSDictionary *fileInfo = @{@"fileName": file, @"modificationDate": modificationDate}; [files addObject:fileInfo]; @@ -271,11 +240,22 @@ NSArray *decryptedFileList(void) { return [date2 compare:date1]; }]; - return [sortedFiles valueForKey:@"fileName"]; + // Get the file names from the sorted array + for (NSDictionary *fileInfo in sortedFiles) { + [fileNames addObject:[fileInfo objectForKey:@"fileName"]]; + } + + return [fileNames copy]; } NSString *docPath(void) { - return [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; + NSError * error = nil; + [[NSFileManager defaultManager] createDirectoryAtPath:@"/var/mobile/Library/TrollDecrypt/decrypted" withIntermediateDirectories:YES attributes:nil error:&error]; + if (error != nil) { + NSLog(@"[trolldecrypt] error creating directory: %@", error); + } + + return @"/var/mobile/Library/TrollDecrypt/decrypted"; } void decryptAppWithPID(pid_t pid) { @@ -341,17 +321,11 @@ void decryptAppWithPID(pid_t pid) { NSLog(@"[trolldecrypt] app: %@", app); - NSString *name = [app localizedName]; - NSString *version = app.shortVersionString; - if (!version) version = @"1.0"; - - NSString *exec = [app canonicalExecutablePath]; - NSDictionary *appInfo = @{ @"bundleID":bundleID, - @"name":name, - @"version":version, - @"executable":exec + @"name":[app atl_nameToDisplay], + @"version":[app atl_shortVersionString], + @"executable":executable }; NSLog(@"[trolldecrypt] appInfo: %@", appInfo); @@ -369,4 +343,33 @@ void decryptAppWithPID(pid_t pid) { [root presentViewController:alert animated:YES completion:nil]; }); +} + +void github_fetchLatedVersion(NSString *repo, void (^completionHandler)(NSString *latestVersion)) { + NSString *urlString = [NSString stringWithFormat:@"https://api.github.com/repos/%@/releases/latest", repo]; + NSURL *url = [NSURL URLWithString:urlString]; + + NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (!error) { + if ([response isKindOfClass:[NSHTTPURLResponse class]]) { + NSError *jsonError; + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError]; + + if (!jsonError) { + NSString *version = [json[@"tag_name"] stringByReplacingOccurrencesOfString:@"v" withString:@""]; + completionHandler(version); + } + } + } + }]; + + [task resume]; +} + +void fetchLatestTrollDecryptVersion(void (^completionHandler)(NSString *version)) { + github_fetchLatedVersion(@"donato-fiore/TrollDecrypt", completionHandler); +} + +NSString *trollDecryptVersion(void) { + return [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"]; } \ No newline at end of file diff --git a/control b/control index bee2982..432bcce 100644 --- a/control +++ b/control @@ -1,6 +1,6 @@ Package: com.fiore.trolldecrypt Name: TrollDecrypt -Version: 0.0.1 +Version: 1.1 Architecture: iphoneos-arm Description: An awesome application! Maintainer: fiore diff --git a/entitlements.plist b/entitlements.plist index 357e5fb..6829acc 100644 --- a/entitlements.plist +++ b/entitlements.plist @@ -34,5 +34,17 @@ com.apple.springboard.launchapplications + com.apple.security.exception.iokit-user-client-class + + IOUserClient + IOUserServer + RootDomainUserClient + + com.apple.security.iokit-user-client-class + + IOUserClient + IOUserServer + RootDomainUserClient + \ No newline at end of file