Skip to content

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ttwj committed Jun 9, 2012
1 parent b0ff59b commit 5bf71ce
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
5 changes: 5 additions & 0 deletions crack.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

int overdrive_enabled;
NSString *workingDir;
NSString *binary_name;
NSString *ipapath;
NSString *crackerName;


#define FAT_CIGAM 0xbebafeca
#define MH_MAGIC 0xfeedface
Expand All @@ -18,6 +22,7 @@ NSString *workingDir;
#define ARMV6 6
#define ARMV7 9

NSString * get_ipapath();
NSString * crack_application(NSString *application_basedir, NSString *basename);
NSString * init_crack_binary(NSString *application_basedir, NSString *bdir, NSString *workingDir, NSDictionary *infoplist);
NSString * crack_binary(NSString *binaryPath, NSString *finalPath, NSString **error);
Expand Down
48 changes: 35 additions & 13 deletions crack.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,28 @@
NSString *binary_name = @"";
NSString *ipapath = @"";
NSString *crackerName = @"";
NSString *application_base = @"";

NSMutableDictionary *infoplist;
NSThread *zipthread;

void zip_resources(NSString *dir, NSString *zip) {
NOTIFY("Compressing original app...");

void *zip_resources() {
NSString *zip = get_ipapath();
NOTIFY("Compressing original app...");
NSString *compressionArguments = [[ClutchConfiguration getValue:@"CompressionArguments"] stringByAppendingString:@" "];
if (compressionArguments == nil)
compressionArguments = @"-0 ";

[[NSFileManager defaultManager] createSymbolicLinkAtPath:[workingDir stringByAppendingString:@"Payload"] withDestinationPath:[dir stringByAppendingString:@"/../"] error:NULL];

system([[NSString stringWithFormat:@"cd %@; zip %@-u -y -r -n .jpg:.JPG:.jpeg:.png:.PNG:.gif:.GIF:.Z:.gz:.zip:.zoo:.arc:.lzh:.rar:.arj:.mp3:.mp4:.m4a:.m4v:.ogg:.ogv:.avi:.flac:.aac \"%@\" Payload/* -x Payload/iTunesArtwork Payload/iTunesMetadata.plist \"Payload/Documents/*\" \"Payload/Library/*\" \"Payload/tmp/*\" \"Payload/*/%@\" \"Payload/*/SC_Info/*\" 2>&1> /dev/null", workingDir, zip, binary_name] UTF8String]);
NSLog(@"working dir: %@\n app dir: %@", [workingDir stringByAppendingString:@"Payload"], [application_base stringByAppendingString:@"/../"]);
NSError* error = nil;
[[NSFileManager defaultManager] createSymbolicLinkAtPath:[workingDir stringByAppendingString:@"Payload"] withDestinationPath:[application_base stringByAppendingString:@"/../"] error:&error];
NSLog(@"%@", [error localizedDescription]);
NSLog(@"no segfault here bro");
NSLog(@"working %@ zip %@ binary %@", workingDir, zip, binary_name);
system([[NSString stringWithFormat:@"cd %@; zip %@-u -y -r -n .jpg:.JPG:.jpeg:.png:.PNG:.gif:.GIF:.Z:.gz:.zip:.zoo:.arc:.lzh:.rar:.arj:.mp3:.mp4:.m4a:.m4v:.ogg:.ogv:.avi:.flac:.aac \"%@\" Payload/* -x Payload/iTunesArtwork Payload/iTunesMetadata.plist \"Payload/Documents/*\" \"Payload/Library/*\" \"Payload/tmp/*\" \"Payload/*/%@\" \"Payload/*/SC_Info/*\" 2>&1> /dev/null", compressionArguments workingDir, zip, binary_name] UTF8String]);
//I love you dissident
[[NSFileManager defaultManager] removeItemAtPath:[workingDir stringByAppendingString:@"Payload"] error: NULL]; //I hope this doesn't remove the entire folder...
NSLog(@"Zip path: %@", zip);
return 0;
}
NSString * get_ipapath() {
if (ipapath.length > 1) {
Expand All @@ -41,10 +48,12 @@ void zip_resources(NSString *dir, NSString *zip) {
}
[[NSFileManager defaultManager] createDirectoryAtPath:@"/var/root/Documents/Cracked/" withIntermediateDirectories:TRUE attributes:nil error:NULL];
[[NSFileManager defaultManager] removeItemAtPath:ipapath error:NULL];
NSLog(@"IPA Path %@", ipapath);
return ipapath;

}
NSString * crack_application(NSString *application_basedir, NSString *basename) {
application_base = application_basedir;
crackerName = [ClutchConfiguration getValue:@"CrackerName"];
VERBOSE("Creating working directory...");
workingDir = [NSString stringWithFormat:@"%@%@/", @"/tmp/clutch_", genRandStringLength(8)];
Expand Down Expand Up @@ -88,9 +97,19 @@ void zip_resources(NSString *dir, NSString *zip) {
binary_name = [infoplist objectForKey:@"CFBundleExecutable"];

//zip thread

[NSThread detachNewThreadSelector:@selector(zip_resources) toTarget:zipthread withObject:nil];
/*pthread_t zip_thread;
if (pthread_create(&zip_thread, NULL, &zip_resources, NULL)) {
printf("error: Could not prepare zip thread\n");
goto fatalc;
}
*/
zip_resources();
if (ipapath.length < 1) {
printf("error: Could not prepare IPA directory\n");
goto fatalc;
}

NSLog(@"cracking binary %@ %@ %@ %@", application_basedir, basename, workingDir, infoplist);

NSString *fbinary_path = init_crack_binary(application_basedir, basename, workingDir, infoplist);
if (fbinary_path == nil) {
Expand Down Expand Up @@ -230,13 +249,16 @@ void zip_resources(NSString *dir, NSString *zip) {
//

stop_bar();

[[NSFileManager defaultManager] removeItemAtPath:workingDir error:NULL];
NSLog(@"hi %@", ipapath);
//[[NSFileManager defaultManager] removeItemAtPath:workingDir error:NULL];
return ipapath;

fatalc:
[[NSFileManager defaultManager] removeItemAtPath:workingDir error:NULL];
return nil;
@autoreleasepool {
[[NSFileManager defaultManager] removeItemAtPath:workingDir error:NULL];
return nil;
} //lazy

}

NSString * init_crack_binary(NSString *application_basedir, NSString *bdir, NSString *workingDir, NSDictionary *infoplist) {
Expand Down

0 comments on commit 5bf71ce

Please sign in to comment.