Skip to content

Commit

Permalink
Bug Fixes in Main, updated version
Browse files Browse the repository at this point in the history
  • Loading branch information
NinjaLikesCheez committed Jan 28, 2014
1 parent 25d3130 commit 91ae071
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Classes/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#define CLUTCH_TITLE "Clutch"
#define CLUTCH_VERSION "1.4"
#define CLUTCH_RELEASE "git-5"
#define CLUTCH_RELEASE "git-7"
#define CLUTCH_BUILD 14005
#define CLUTCH_DEV 1

Expand Down
40 changes: 28 additions & 12 deletions Classes/Cracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ static BOOL copyFile(NSString *infile, NSString *outfile)
// set up application cracking from an installed application
-(BOOL)prepareFromInstalledApp:(Application*)app
{
DEBUG(@"------Prepairing from Installed App------");
// Create the app description
_app = app;
_appDescription = [NSString stringWithFormat:@"%@: %@ (%@)",
Expand All @@ -154,7 +155,7 @@ -(BOOL)prepareFromInstalledApp:(Application*)app
_tempPath = [NSString stringWithFormat:@"%@%@", @"/tmp/clutch_", genRandStringLength(8)];
_workingDir = [NSString stringWithFormat:@"%@/Payload/%@", _tempPath, app.appDirectory];

DEBUG(@"temporary directory %@", _workingDir);
DEBUG(@"Temporary Directory: %@", _workingDir);
MSG(CRACKING_CREATE_WORKING_DIR);

if (![[NSFileManager defaultManager] createDirectoryAtPath:_workingDir withIntermediateDirectories:YES attributes:@{NSFileOwnerAccountName:@"mobile",NSFileGroupOwnerAccountName:@"mobile"} error:NULL])
Expand All @@ -165,24 +166,27 @@ -(BOOL)prepareFromInstalledApp:(Application*)app

_tempBinaryPath = [_workingDir stringByAppendingFormat:@"/%@", app.applicationExecutableName];

DEBUG(@"tempBinaryPath: %@", _tempBinaryPath);
DEBUG(@"Temporary Binary Path: %@", _tempBinaryPath);

_binaryPath = [[app.applicationContainer stringByAppendingPathComponent:app.appDirectory] stringByAppendingPathComponent:app.applicationExecutableName];

_binary = [[Binary alloc] initWithBinary:_binaryPath];

_binary->overdriveEnabled = [[Preferences sharedInstance] useOverdrive];

DEBUG(@"binaryPath: %@", _binaryPath);
DEBUG(@"Binary Path: %@", _binaryPath);

return (!_binary)?NO:YES;
DEBUG(@"-------End Prepairing Installed App-----");

return (!_binary) ? NO : YES;
}

-(NSString*) generateIPAPath
{
DEBUG(@"------Generating Paths------");
NSString *crackerName = [[Preferences sharedInstance] crackerName];

NSString *crackedPath = [NSString stringWithFormat:@"%@/", [[Preferences sharedInstance] ipaDirectory]];
NSString *crackedPath = [NSString stringWithFormat:@"%@/", [[Preferences sharedInstance] ipaDirectory]];

if ([[Preferences sharedInstance] addMinOS])
{
Expand All @@ -195,11 +199,18 @@ -(NSString*) generateIPAPath
_yopaPath = [NSString stringWithFormat:@"%@%@-v%@-%@-(Clutch-%@).7z.yopa.ipa", crackedPath, _app.applicationDisplayName, _app.applicationVersion, crackerName, [NSString stringWithUTF8String:CLUTCH_VERSION]];
}

DEBUG(_ipapath);

DEBUG(@"------End Generating Paths-----");

return _ipapath;
}

-(BOOL) execute
{

DEBUG(@"------Executing crack------")

//1. dump binary
__block NSError* error;
__block BOOL* crackOk, *zipComplete = false;
Expand All @@ -218,6 +229,7 @@ -(BOOL) execute
NSOperationQueue *queue = [[NSOperationQueue alloc] init];

NSBlockOperation *crackOperation = [NSBlockOperation blockOperationWithBlock:^{
DEBUG(@"------Crack Operation------");
NSError* _error;
DEBUG(@"beginning crack operation");

Expand All @@ -240,6 +252,7 @@ -(BOOL) execute

DEBUG(@"crack operation ok!");
MSG(PACKAGING_WAITING_ZIP);
DEBUG(@"-----End Crack Op------");
}
}];

Expand All @@ -254,6 +267,7 @@ -(BOOL) execute
__block __weak NSBlockOperation *zipOriginalweakOperation = zipOriginalOperation;

[zipOriginalOperation addExecutionBlock:^{
DEBUG(@"------Zip Operation------");
DEBUG(@"beginning zip operation");

if ([[Preferences sharedInstance] useNativeZip])
Expand Down Expand Up @@ -282,10 +296,12 @@ -(BOOL) execute

DEBUG(@"zip original ok");
zipComplete = true;
DEBUG(@"------End Zip Op------");
}];


NSOperation *zipCrackedOperation = [NSBlockOperation blockOperationWithBlock:^{
DEBUG(@"------Zip Cracked Op------");
//check if crack was successful
if (crackOk)
{
Expand Down Expand Up @@ -320,6 +336,7 @@ -(BOOL) execute
}

[[NSFileManager defaultManager] removeItemAtPath:_tempPath error:nil];
DEBUG(@"------End Zip Crack Op------");
}];

[zipCrackedOperation addDependency:crackOperation];
Expand All @@ -334,6 +351,8 @@ -(BOOL) execute

[queue release];

DEBUG(@"------End Execute Crack------");

return crackOk;
}

Expand Down Expand Up @@ -535,16 +554,13 @@ -(void)packageIPA
}
else
{
NSError *err;
//NSError *err;
DEBUG(@"Moving iTunesMetadata");
DEBUG(@"copy from %@ to %@", [_app.applicationContainer stringByAppendingString:@"iTunesMetadata.plist"], [[[_workingDir stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingString:@"iTunesMetadata.plist"]);
DEBUG(@"copy from %@ to %@", [_app.applicationContainer stringByAppendingString:@"iTunesMetadata.plist"], [[[_workingDir stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingString:@"/iTunesMetadata.plist"]);

[[NSFileManager defaultManager] copyItemAtPath:[_app.applicationContainer stringByAppendingPathComponent:@"iTunesMetadata.plist"] toPath:[[[_workingDir stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"iTunesMetadata.plist"] error:&err];

if (err)
{
NSLog(@"error moving itunesmetadata %@", err);
}
[[NSFileManager defaultManager] copyItemAtPath:[_app.applicationContainer stringByAppendingPathComponent:@"iTunesMetadata.plist"] toPath:[[[_workingDir stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"iTunesMetadata.plist"] error:nil];

}

if ([[Preferences sharedInstance] useOverdrive])
Expand Down
47 changes: 27 additions & 20 deletions Classes/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ void cmd_help()
{
printf("Clutch Help\n");
printf("----------------------\n");
printf("-c Runs configuration utility\n");
printf("-a Cracks all applications\n");
printf("-u Cracks updated applications\n");
printf("-f Clears cache\n");
printf("-v Shows version\n");
printf("-c Runs configuration utility\n");
printf("-a Cracks all applications\n");
printf("-u Cracks updated applications\n");
printf("-f Clears cache\n");
printf("-v Shows version\n");
printf("-i <IPA> <Binary> <OutBinary> Installs IPA and cracks it\n");
printf("--yopa Creates a YOPA package\n");
printf("\n");
}

Expand Down Expand Up @@ -365,7 +367,25 @@ int main(int argc, char *argv[])
goto endMain;
}

if ([arg isEqualToString:@"-a"] || [arg isEqualToString:@"-all"])
if ([arg isEqualToString:@"-i"] || [arg isEqualToString:@"-install"])
{
if (arguments.count < 3)
{
printf("%s %s requires 3 arugments (%d found).\n", argv[0], [arg UTF8String], (int)(arguments.count - 2));

return retVal;
}

NSString *ipa = arguments[2];
NSString *binary = arguments[3];
NSString *outbinary = arguments[4];

Install *install = [[Install alloc] initWithIPA:ipa withBinary:binary];
[install installIPA];
[install crackWithOutBinary:outbinary];
[install release];
}
else if ([arg isEqualToString:@"-a"] || [arg isEqualToString:@"-all"])
{
retVal = cmd_crack_all(applist);
}
Expand All @@ -389,17 +409,6 @@ int main(int argc, char *argv[])

goto endMain;
}
else if ([arg isEqualToString:@"-i"] || [arg isEqualToString:@"-install"])
{
NSString *ipa = [NSString stringWithUTF8String:argv[2]];
NSString *binary = [NSString stringWithUTF8String:argv[3]];
NSString *outbinary = [NSString stringWithUTF8String:argv[4]];

Install *install = [[Install alloc] initWithIPA:ipa withBinary:binary];
[install installIPA];
[install crackWithOutBinary:outbinary];
[install release];
}
else if ([arg isEqualToString:@"-h"] || [arg isEqualToString:@"-help"])
{
cmd_help();
Expand All @@ -418,14 +427,12 @@ int main(int argc, char *argv[])
continue;
}

DEBUG(@"yolo swag");
int i = 1;
if ([arg isEqualToString:@"-k"]) {

}

for (int i = 1; i < arguments.count; i++)
{
DEBUG(@"hi %u", i);
NSString* _arg = arguments[i];
if ([[Preferences sharedInstance] numberBasedMenu])
{
Expand Down
Binary file not shown.

0 comments on commit 91ae071

Please sign in to comment.