Skip to content

Commit

Permalink
1.4.5-git1
Browse files Browse the repository at this point in the history
  • Loading branch information
ttwj committed May 15, 2014
1 parent b28fab9 commit b806aa2
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 297 deletions.
4 changes: 3 additions & 1 deletion Classes/Binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
@public
BOOL overdriveEnabled;
BOOL skip_64;
BOOL patchPIE;
}

- (id)initWithBinary:(NSString *)path;
- (BOOL)crackBinaryToFile:(NSString *)path error:(NSError **)error;
- (BOOL)dumpOrigFile:(FILE *) origin withLocation:(NSString*)originPath toFile:(FILE *) target withArch:(struct fat_arch)arch;
- (BOOL)dump64bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toFile:(FILE *) target withTop:(uint32_t) top patchPIE:(BOOL) patchPIE;
- (BOOL)dump64bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toFile:(FILE *) target withTop:(uint32_t) top;
- (BOOL)dump32bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toFile:(FILE *) target withTop:(uint32_t) top;

@end
36 changes: 18 additions & 18 deletions Classes/Binary.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ - (id)init
return nil;
}

-(void)patchPIE:(BOOL)patch {
self->patchPIE = patch;
}

-(NSString *) genRandStringLength: (int) len
{
NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Expand Down Expand Up @@ -455,7 +459,7 @@ - (BOOL)crackBinaryToFile:(NSString *)finalPath error:(NSError * __autoreleasing
return NO;
}

if (![self dump64bitOrigFile:oldbinary withLocation:oldbinaryPath toFile:newbinary withTop:0 patchPIE:FALSE])
if (![self dump64bitOrigFile:oldbinary withLocation:oldbinaryPath toFile:newbinary withTop:0])
{
// Dumping failed
DEBUG(@"Failed to dump %@",[self readable_cpusubtype:mh64->cpusubtype]);
Expand Down Expand Up @@ -504,7 +508,7 @@ - (BOOL)crackBinaryToFile:(NSString *)finalPath error:(NSError * __autoreleasing
return NO;
}

if (![self dump32bitOrigFile:oldbinary withLocation:oldbinaryPath toFile:newbinary withTop:0 patchPIE:false])
if (![self dump32bitOrigFile:oldbinary withLocation:oldbinaryPath toFile:newbinary withTop:0])
{
// Dumping failed
DEBUG(@"Failed to dump %@",[self readable_cpusubtype:mh32->cpusubtype]);
Expand Down Expand Up @@ -702,18 +706,18 @@ - (BOOL)dumpOrigFile:(FILE *) origin withLocation:(NSString*)originPath toFile:(
if (CFSwapInt32(arch.cputype) == CPU_TYPE_ARM64)
{
DEBUG(@"currently cracking 64bit portion");
return [self dump64bitOrigFile:origin withLocation:originPath toFile:target withTop:CFSwapInt32(arch.offset) patchPIE:FALSE];
return [self dump64bitOrigFile:origin withLocation:originPath toFile:target withTop:CFSwapInt32(arch.offset)];
}
else
{
DEBUG(@"currently cracking 32bit portion");
return [self dump32bitOrigFile:origin withLocation:originPath toFile:target withTop:CFSwapInt32(arch.offset) patchPIE:FALSE];
return [self dump32bitOrigFile:origin withLocation:originPath toFile:target withTop:CFSwapInt32(arch.offset)];
}
return true;
}


- (BOOL)dump64bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toFile:(FILE *) target withTop:(uint32_t) top patchPIE:(BOOL) patchPIE
- (BOOL)dump64bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toFile:(FILE *) target withTop:(uint32_t) top
{
fseek(target, top, SEEK_SET); // go the top of the target

Expand Down Expand Up @@ -951,13 +955,14 @@ - (BOOL)dump64bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toF
DEBUG(@"dum_error: %u", err);
VERBOSE("dumping binary: failed to dump a page (64)");

if (__text_start == 16384) {
if (__text_start == 0x4000) {
printf("\n=================\n");
printf("0x4000 binary detected, attempting to remove MH_PIE flag");
printf("\n=================\n\n");
free(checksum); // free checksum table
kill(pid, SIGKILL); // kill fork
return [self dump32bitOrigFile:origin withLocation:originPath toFile:target withTop:top patchPIE:true];
[self patchPIE:TRUE];
return [self dump64bitOrigFile:origin withLocation:originPath toFile:target withTop:top];
}

free(checksum); // free checksum table
Expand Down Expand Up @@ -1067,8 +1072,9 @@ - (BOOL)dump64bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toF

}

- (BOOL)dump32bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toFile:(FILE *) target withTop:(uint32_t) top patchPIE:(BOOL) patchPIE {
DEBUG(@"32bit dumping!!!");
- (BOOL)dump32bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toFile:(FILE *) target withTop:(uint32_t) top
{
DEBUG(@"Dumping 32bit segment..");
fseek(target, top, SEEK_SET); // go the top of the target
// we're going to be going to this position a lot so let's save it
fpos_t topPosition;
Expand All @@ -1088,7 +1094,7 @@ - (BOOL)dump32bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toF
BOOL foundStartText = FALSE;
uint64_t __text_start = 0;
//uint64_t __text_size = 0;
DEBUG(@"32bit dumping, offset %u", top);
DEBUG(@"32bit dumping: offset %u", top);
//VERBOSE("dumping binary: analyzing load commands");
MSG(DUMPING_ANALYZE_LOAD_COMMAND);
fread(&mach, sizeof(struct mach_header), 1, target); // read mach header to get number of load commands
Expand Down Expand Up @@ -1293,13 +1299,6 @@ - (BOOL)dump32bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toF
// get a percentage for the progress bar
PERCENT((int)ceil((((double)total - togo) / (double)total) * 100));

// move an entire page into memory (we have to move an entire page regardless of whether it's a resultant or not)
/*if((err = vm_read_overwrite(port, (mach_vm_address_t) __text_start + (pages_d * 0x1000), (vm_size_t) 0x1000, (pointer_t) buf, &local_size)) != KERN_SUCCESS) {
VERBOSE("dumping binary: failed to dump a page");
free(checksum); // free checksum table
kill(pid, SIGKILL); // kill fork
return FALSE;
}*/

if ((err = mach_vm_read_overwrite(port, (mach_vm_address_t) __text_start + (pages_d * 0x1000), (vm_size_t) 0x1000, (pointer_t) buf, &local_size)) != KERN_SUCCESS) {

Expand All @@ -1310,7 +1309,8 @@ - (BOOL)dump32bitOrigFile:(FILE *) origin withLocation:(NSString*)originPath toF
printf("\n=================\n\n");
free(checksum); // free checksum table
kill(pid, SIGKILL); // kill the fork
return [self dump32bitOrigFile:origin withLocation:originPath toFile:target withTop:top patchPIE:true];
[self patchPIE:TRUE];
return [self dump32bitOrigFile:origin withLocation:originPath toFile:target withTop:top];
}
free(checksum); // free checksum table
kill(pid, SIGKILL); // kill the fork
Expand Down
7 changes: 3 additions & 4 deletions Classes/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Constants.h
// Clutch
//
// Created by Zorro on 30.12.13.
//
//

Expand All @@ -25,10 +24,10 @@
*/

#define CLUTCH_TITLE "Clutch"
#define CLUTCH_VERSION "1.4.4"
#define CLUTCH_VERSION "1.4.5"
#define CLUTCH_RELEASE "git-1"
#define CLUTCH_BUILD 14401
#define CLUTCH_DEV 0 //1
#define CLUTCH_BUILD 14501
#define CLUTCH_DEV 1 //0


void sha1(uint8_t *hash, uint8_t *data, size_t size);
Expand Down
71 changes: 1 addition & 70 deletions Classes/Cracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,75 +51,6 @@ -(void)dealloc
[super dealloc];
}

static BOOL forceRemoveDirectory(NSString *dirpath)
{
BOOL isDir;
NSFileManager *fileManager=[NSFileManager defaultManager];

if(![fileManager fileExistsAtPath:dirpath isDirectory:&isDir])
{
if(![fileManager removeItemAtPath:dirpath error:NULL])
{
return NO;
}
}

return YES;
}

static BOOL forceCreateDirectory(NSString *dirpath)
{
BOOL isDir;
NSFileManager *fileManager= [NSFileManager defaultManager];

if([fileManager fileExistsAtPath:dirpath isDirectory:&isDir])
{
if(![fileManager removeItemAtPath:dirpath error:NULL])
{
return NO;
}
}

if(![fileManager createDirectoryAtPath:dirpath withIntermediateDirectories:YES attributes:nil error:NULL])
{
return NO;
}

return YES;
}

static BOOL copyFile(NSString *infile, NSString *outfile)
{
NSFileManager *fileManager= [NSFileManager defaultManager];

if(![fileManager createDirectoryAtPath:[outfile stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:NULL])
{
return NO;
}

if(![fileManager copyItemAtPath:infile toPath:outfile error:NULL])
{
return NO;
}

return YES;
}

static ZipArchive * createZip(NSString *file) {
ZipArchive *archiver = [[ZipArchive alloc] init];

if (!file)
{
DEBUG(@"File string is nil");

[archiver release];
return nil;
}

[archiver CreateZipFile2:file];

return archiver;
}


static NSString * genRandStringLength(int len)
Expand Down Expand Up @@ -543,7 +474,7 @@ void generateMetadata(NSString *origPath,NSString *output)

[metadataPlist removeObjectForKey:@"com.apple.iTunesStore.downloadInfo"];

DEBUG(@"metadataplist %@", metadataPlist);
//DEBUG(@"metadataplist %@", metadataPlist);

[metadataPlist writeToFile:output atomically:NO];

Expand Down
2 changes: 1 addition & 1 deletion Classes/Preferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ - (void)tempSetObject:(id)value forKey:(NSString *)defaultName
[_dict setObject:value forKey:defaultName];

}
DEBUG(@"da dict %@", _dict);
//DEBUG(@"Preferences dictionary: %@", _dict);

}

Expand Down
14 changes: 8 additions & 6 deletions Classes/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -531,35 +531,37 @@ int main(int argc, char *argv[])
else if ([arg isEqualToString:@"--info"])
{
get_info = 1;
DEBUG(@"getting info wow");

}
else
{
if ([arg isEqualToString:arguments[0]])
{

continue;
}

if ([arg intValue] != 0)
{
if ([[Preferences sharedInstance] numberBasedMenu])
if ([[Preferences sharedInstance] numberBasedMenu]) {
if ([arg intValue] != 0)
{
int number = [arg intValue] - 1;
Application *app = applist[number];

retVal = cmd_crack_app(app, skip_64);
//printf("continuing after int crack");
}

}
else
{

NSString* _arg = arg;
Application* crackApp = NULL;

for (Application *app in applist)
{
if ([[[Preferences sharedInstance] objectForKey:@"ListWithDisplayName"] isEqualToString:@"DIRECTORY"])
{
DEBUG(@"holy shiit wow");
if ([app.applicationDirectory caseInsensitiveCompare:_arg] == NSOrderedSame)
{
crackApp = app;
Expand Down Expand Up @@ -600,7 +602,7 @@ int main(int argc, char *argv[])
retVal = 0;
goto endMain;
}

DEBUG(@"app to crack %@", crackApp->_info);
retVal = cmd_crack_app(crackApp, skip_64);
goto endMain;
}
Expand Down
67 changes: 0 additions & 67 deletions Classes/minizip/ChangeLogUnzip

This file was deleted.

6 changes: 0 additions & 6 deletions Classes/minizip/MiniZip64_Changes.txt

This file was deleted.

Loading

0 comments on commit b806aa2

Please sign in to comment.