Permalink
Browse files

minor tweaks

  • Loading branch information...
ttwj committed Jun 19, 2012
1 parent d354c78 commit c9ccc7f251201ffd4391c435c84501e7d96514d3
Showing with 59 additions and 69 deletions.
  1. +0 −17 Classes/bash.h
  2. +0 −16 Classes/bash.m
  3. +1 −1 Classes/zip/unzip.c
  4. +1 −1 Classes/zip/zip.c
  5. +2 −0 Clutch.xcodeproj/project.pbxproj
  6. +15 −11 applist.m
  7. +3 −3 crack.h
  8. +26 −15 crack.m
  9. +11 −5 main.m
View
@@ -1,17 +0,0 @@
-//
-// bash.h
-// Clutch
-//
-// Created by Terence Tan on 7/6/12.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-#import <Foundation/Foundation.h>
-
-@interface bash : NSObject {
- NSString* script;
- NSDictionary* env;
-}
-- (void) run;
-@end
View
@@ -1,16 +0,0 @@
-//
-// bash.m
-// Clutch
-//
-// Created by Terence Tan on 7/6/12.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
-
-#import "bash.h"
-@implementation bash
-
-- (void) run {
-
-}
-
-@end
View
@@ -1239,7 +1239,7 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
return UNZ_PARAMERROR;
- if ((pfile_in_zip_read_info->read_buffer == NULL))
+ if (pfile_in_zip_read_info->read_buffer == NULL)
return UNZ_END_OF_LIST_OF_FILE;
if (len==0)
return 0;
View
@@ -758,7 +758,7 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
zi->ci.flag = 0;
if ((level==8) || (level==9))
zi->ci.flag |= 2;
- if ((level==2))
+ if (level==2)
zi->ci.flag |= 4;
if ((level==1))
zi->ci.flag |= 6;
@@ -295,6 +295,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Clutch_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "Clutch-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
LIBRARY_SEARCH_PATHS = (
@@ -317,6 +318,7 @@
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Clutch_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "Clutch-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
LIBRARY_SEARCH_PATHS = (
View
@@ -25,16 +25,16 @@
versions = [[NSMutableDictionary alloc] init];
}
else {
- versions = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/etc/clutch_cracked.plist"];
+ versions = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/cache/clutch_cracked.plist"];
}
}
NSDictionary *applicationDetailObject;
NSString *bundleDisplayName, *applicationRealname, *bundleVersionString;
while (applicationDirectory = [e nextObject]) {
- if ([cache objectForKey:applicationDirectory] != nil) {
- [returnArray addObject:[cache objectForKey:applicationDirectory]];
- } else {
+ //if ([cache objectForKey:applicationDirectory] != nil) {
+ //[returnArray addObject:[cache objectForKey:applicationDirectory]];
+ // } else {
NSArray *sandboxPath = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[basePath stringByAppendingFormat:@"%@/", applicationDirectory] error:NULL];
e2 = [sandboxPath objectEnumerator];
@@ -43,14 +43,14 @@
continue;
else {
bundleDisplayName = [[NSDictionary dictionaryWithContentsOfFile:[basePath stringByAppendingFormat:@"%@/%@/Info.plist", applicationDirectory, applicationSubdirectory]] objectForKey:@"CFBundleDisplayName"];
- bundleVersionString = [[[NSDictionary dictionaryWithContentsOfFile:[basePath stringByAppendingFormat:@"%@/%@/Info.plist", applicationDirectory, applicationSubdirectory]] objectForKey:@"CFBundleVersionKey"] stringByReplacingOccurrencesOfString:@"." withString:@""];
+ bundleVersionString = [[[NSDictionary dictionaryWithContentsOfFile:[basePath stringByAppendingFormat:@"%@/%@/Info.plist", applicationDirectory, applicationSubdirectory]] objectForKey:@"CFBundleVersion"] stringByReplacingOccurrencesOfString:@"." withString:@""];
applicationRealname = [applicationSubdirectory stringByReplacingOccurrencesOfString:@".app" withString:@""];
if (bundleDisplayName == nil) {
bundleDisplayName = applicationRealname;
}
-
+
if ([[NSFileManager defaultManager] fileExistsAtPath:[basePath stringByAppendingFormat:@"%@/%@/SC_Info/", applicationDirectory, applicationSubdirectory]]) {
applicationDetailObject = [NSDictionary dictionaryWithObjectsAndKeys:
[basePath stringByAppendingFormat:@"%@/", applicationDirectory], @"ApplicationBaseDirectory",
@@ -59,7 +59,9 @@
applicationRealname, @"ApplicationName",
applicationSubdirectory, @"ApplicationBasename",
applicationDirectory, @"RealUniqueID",
+ bundleVersionString, @"ApplicationVersion",
nil];
+
if (updates) {
if ([versions objectForKey:applicationRealname] != bundleVersionString) {
[returnArray addObject:applicationDetailObject];
@@ -70,24 +72,26 @@
[returnArray addObject:applicationDetailObject];
}
- [cache setValue:applicationDetailObject forKey:applicationDirectory];
+ [cache setValue:bundleDisplayName forKey:applicationDirectory];
cflush = TRUE;
}
}
}
}
- }
+ //}
if (cflush) {
[cache writeToFile:@"/var/cache/clutch.plist" atomically:TRUE];
}
-
- if ([returnArray count] == 0)
+
+ if ([returnArray count] == 0) {
[returnArray release];
return NULL;
+ }
- if (sort)
+ if (sort) {
return (NSArray *)[returnArray sortedArrayUsingFunction:alphabeticalSort context:NULL];
+ }
return (NSArray *) returnArray;
}
View
@@ -18,17 +18,17 @@ NSString *bash_script;
#define FAT_CIGAM 0xbebafeca
#define MH_MAGIC 0xfeedface
-#define CLUTCH_VERSION "Clutch 1.2.4"
+#define CLUTCH_VERSION "ClutchMod 0.1 (Clutch 1.2.4)"
#define ARMV6 6
#define ARMV7 9
-NSString * crack_application(NSString *application_basedir, NSString *basename);
+NSString * crack_application(NSString *application_basedir, NSString *basename, NSString *version);
NSString * init_crack_binary(NSString *application_basedir, NSString *bdir, NSString *workingDir, NSDictionary *infoplist);
NSString * crack_binary(NSString *binaryPath, NSString *finalPath, NSString **error);
NSString * genRandStringLength(int len);
ZipArchive * createZip(NSString *file);
-void zip(ZipArchive *zip, NSString *folder, int compression);
+void zip(ZipArchive *zip, NSString *folder);
int get_local_arch();
struct fat_arch {
View
41 crack.m
@@ -21,7 +21,7 @@
[archiver CreateZipFile2:file];
return archiver;
}
-void zip(ZipArchive *archiver, NSString *folder, int compression) {
+void zip(ZipArchive *archiver, NSString *folder) {
BOOL isDir=NO;
NSArray *subpaths;
int total = 0;
@@ -39,13 +39,13 @@ void zip(ZipArchive *archiver, NSString *folder, int compression) {
// Only add it if it's not a directory. ZipArchive will take care of those.
NSString *longPath = [folder stringByAppendingPathComponent:path];
if([fileManager fileExistsAtPath:longPath isDirectory:&isDir] && !isDir){
- [archiver addFileToZip:longPath newname:path compression:compression];
+ [archiver addFileToZip:longPath newname:path compression:compression_level];
}
}
return;
}
-void zip_original(ZipArchive *archiver, NSString *folder, NSString *binary, int compression) {
+void zip_original(ZipArchive *archiver, NSString *folder, NSString *binary) {
BOOL isDir=NO;
NSArray *subpaths;
int total = 0;
@@ -64,16 +64,14 @@ void zip_original(ZipArchive *archiver, NSString *folder, NSString *binary, int
// Only add it if it's not a directory. ZipArchive will take care of those.
NSString *longPath = [folder stringByAppendingPathComponent:path];
if([fileManager fileExistsAtPath:longPath isDirectory:&isDir] && !isDir){
- NSString* thepath = [NSString stringWithFormat:@"Payload/%@", path];
- //NSLog(@"adding longpath: %@ shortpath: %@", longPath, thepath);
- [archiver addFileToZip:longPath newname:thepath compression:compression];
+ [archiver addFileToZip:longPath newname:[NSString stringWithFormat:@"Payload/%@", path] compression:compression_level];
}
}
}
return;
}
-NSString * crack_application(NSString *application_basedir, NSString *basename) {
+NSString * crack_application(NSString *application_basedir, NSString *basename, NSString *version) {
VERBOSE("Creating working directory...");
NSString *workingDir = [NSString stringWithFormat:@"%@%@/", @"/tmp/clutch_", genRandStringLength(8)];
if (![[NSFileManager defaultManager] createDirectoryAtPath:[workingDir stringByAppendingFormat:@"Payload/%@", basename] withIntermediateDirectories:YES attributes:[NSDictionary
@@ -296,12 +294,11 @@ void zip_original(ZipArchive *archiver, NSString *folder, NSString *binary, int
NOTIFY("Compressing original application (1/2)...");
ZipArchive *archiver = [[ZipArchive alloc] init];
[archiver CreateZipFile2:ipapath];
- NSLog(@"%@", application_basedir);
- zip_original(archiver, [application_basedir stringByAppendingString:@"../"], binary_name, compression_level);
+ zip_original(archiver, [application_basedir stringByAppendingString:@"../"], binary_name);
stop_bar();
NOTIFY("Compressing cracked application (2/2)..");
- zip(archiver, workingDir, compression_level);
+ zip(archiver, workingDir);
stop_bar();
/*
//add symlink
@@ -332,13 +329,25 @@ void zip_original(ZipArchive *archiver, NSString *folder, NSString *binary, int
//
[archiver release];
- //[[NSFileManager defaultManager] removeItemAtPath:workingDir error:NULL];
+ NSMutableDictionary *dict;
+ if ([[NSFileManager defaultManager] fileExistsAtPath:@"/etc/clutch_cracked.plist"]) {
+ dict = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/etc/clutch_cracked.plist"];
+ }
+ else {
+ [[NSFileManager defaultManager] createFileAtPath:@"/etc/clutch_cracked.plist" contents:nil attributes:nil];
+ dict = [[NSMutableDictionary alloc] init];
+ }
+ [dict setObject:version forKey: [infoplist objectForKey:@"CFBundleDisplayName"]];
+ [dict writeToFile:@"/etc/clutch_cracked.plist" atomically:YES];
+ [[NSFileManager defaultManager] removeItemAtPath:workingDir error:NULL];
+ [dict release];
return ipapath;
-fatalc:
+fatalc: {
[[NSFileManager defaultManager] removeItemAtPath:workingDir error:NULL];
return nil;
}
+}
NSString * init_crack_binary(NSString *application_basedir, NSString *bdir, NSString *workingDir, NSDictionary *infoplist) {
VERBOSE("Performing cracking preflight...");
@@ -402,6 +411,10 @@ void zip_original(ZipArchive *archiver, NSString *folder, NSString *binary, int
fread(&armv6, sizeof(struct fat_arch), 1, oldbinary);
fread(&armv7, sizeof(struct fat_arch), 1, oldbinary);
if (only_armv7 == 1) {
+ if (local_arch == ARMV6) {
+ *error = @"You are not using an ARMV7 device";
+ goto c_err;
+ }
VERBOSE("Only dumping ARMV7 portion because you said so");
NOTIFY("Dumping ARMV7 portion...");
// we can only crack the armv7 portion
@@ -569,9 +582,7 @@ void zip_original(ZipArchive *archiver, NSString *folder, NSString *binary, int
fclose(newbinary); // close the new binary stream
fclose(oldbinary); // close the old binary stream
-
- NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/etc/clutch_cracked.plist"];
- [dict setObject:binaryPath forKey:<#(id)#>
+
return finalPath; // return cracked binary path
c_err:
View
16 main.m
@@ -75,14 +75,14 @@ int main(int argc, char *argv[]) {
while (applicationDetails = [e nextObject]) {
printf("Cracking %s...\n", [[applicationDetails objectForKey:@"ApplicationName"] UTF8String]);
- ipapath = crack_application([applicationDetails objectForKey:@"ApplicationDirectory"], [applicationDetails objectForKey:@"ApplicationBasename"]);
+ ipapath = crack_application([applicationDetails objectForKey:@"ApplicationDirectory"], [applicationDetails objectForKey:@"ApplicationBasename"], [applicationDetails objectForKey:@"ApplicationVersion"]);
if (ipapath == nil) {
printf("Failed.\n");
} else {
printf("\t%s\n", [ipapath UTF8String]);
}
}
- } else if (strncmp(argv[1], "-u", 2)) {
+ } else if (strncmp(argv[1], "-u", 2) == 0) {
NSArray *applist = get_application_list(FALSE, TRUE);
if (applist == NULL) {
printf("There are no new applications on this device that aren't cracked.\n");
@@ -96,7 +96,7 @@ int main(int argc, char *argv[]) {
while (applicationDetails = [e nextObject]) {
printf("Cracking %s...\n", [[applicationDetails objectForKey:@"ApplicationName"] UTF8String]);
- ipapath = crack_application([applicationDetails objectForKey:@"ApplicationDirectory"], [applicationDetails objectForKey:@"ApplicationBasename"]);
+ ipapath = crack_application([applicationDetails objectForKey:@"ApplicationDirectory"], [applicationDetails objectForKey:@"ApplicationBasename"], [applicationDetails objectForKey:@"ApplicationVersion"]);
if (ipapath == nil) {
printf("Failed.\n");
} else {
@@ -146,7 +146,7 @@ int main(int argc, char *argv[]) {
inCrackRoutine:
cracked = TRUE;
printf("Cracking %s...\n", [[applicationDetails objectForKey:compareWith] UTF8String]);
- ipapath = crack_application([applicationDetails objectForKey:@"ApplicationDirectory"], [applicationDetails objectForKey:@"ApplicationBasename"]);
+ ipapath = crack_application([applicationDetails objectForKey:@"ApplicationDirectory"], [applicationDetails objectForKey:@"ApplicationBasename"], [applicationDetails objectForKey:@"ApplicationVersion"]);
if (ipapath == nil) {
printf("Failed.\n");
} else {
@@ -170,7 +170,7 @@ int main(int argc, char *argv[]) {
else if (!strcmp(argv[i], "--script")) {
bash = 1;
NSLog(@"%@", argv[i]);
- bash_script = (NSString*) argv[i + 1];
+ //bash_script = (NSString*) argv[i + 1];
NSLog(@"script %@", bash_script);
if (![[NSFileManager defaultManager] fileExistsAtPath:bash_script]) {
printf("error: %s does not exist", [bash_script UTF8String]);
@@ -200,8 +200,14 @@ int main(int argc, char *argv[]) {
[pool release];
help:
printf("ClutchMod help\n");
+ printf("---------------------------------\n");
printf("-- Cracks all applications\n");
+ printf("-u Cracks updated applications\n");
printf("-f Clears cache\n");
printf("-v Shows version\n");
+ printf("\n");
+ printf("--[no|fast|best]-compression Set the compression level\n");
+ printf("--armv7 Only cracks armv7 portion of fat binary\n");
+
[pool release];
}

0 comments on commit c9ccc7f

Please sign in to comment.