Skip to content

Commit

Permalink
adding bash
Browse files Browse the repository at this point in the history
  • Loading branch information
ttwj committed Jun 18, 2012
1 parent 6fed755 commit 38cc987
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Clutch.xcodeproj/project.pbxproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
AD2ABA541580A71D00146E30 /* Clutch.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Clutch.entitlements; sourceTree = "<group>"; }; AD2ABA541580A71D00146E30 /* Clutch.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Clutch.entitlements; sourceTree = "<group>"; };
AD2ABA581580FA9700146E30 /* CrackApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrackApp.h; sourceTree = "<group>"; }; AD2ABA581580FA9700146E30 /* CrackApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrackApp.h; sourceTree = "<group>"; };
AD2ABA591580FA9700146E30 /* CrackApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CrackApp.m; sourceTree = "<group>"; }; AD2ABA591580FA9700146E30 /* CrackApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CrackApp.m; sourceTree = "<group>"; };
AD838DCC158F7FCE0044E042 /* NSTask.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSTask.h; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */


/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -108,6 +109,7 @@
29B97316FDCFA39411CA2CEA /* main.m */, 29B97316FDCFA39411CA2CEA /* main.m */,
41E0DFD1123823030068268F /* applist.h */, 41E0DFD1123823030068268F /* applist.h */,
41E0DFD2123823030068268F /* applist.m */, 41E0DFD2123823030068268F /* applist.m */,
AD838DCC158F7FCE0044E042 /* NSTask.h */,
); );
name = "Other Sources"; name = "Other Sources";
sourceTree = "<group>"; sourceTree = "<group>";
Expand Down Expand Up @@ -210,7 +212,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate\nif [ \"${PLATFORM_NAME}\" == \"iphoneos\" ]; then\n/Users/ttwj/entitlements/gen_entitlements.py \"us.hackulo.${PROJECT_NAME}\" \"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent\";\ncodesign -f -s \"iPhone Developer\" --entitlements \"/Users/ttwj/Clutch/Clutch.entitlements\" \"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/\"\nfi"; shellScript = "export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate\nif [ \"${PLATFORM_NAME}\" == \"iphoneos\" ]; then\n/Users/ttwj/entitlements/gen_entitlements.py \"us.hackulo.${PROJECT_NAME}\" \"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent\";\n# whoops remove my name\ncodesign -f -s \"iPhone Developer\" --entitlements \"/Users/ttwj/Clutch/Clutch.entitlements\" \"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/\"\nfi";
}; };
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */


Expand Down
72 changes: 72 additions & 0 deletions NSTask.h
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,72 @@
/* NSTask.h
Copyright (c) 1996-2007, Apple Inc. All rights reserved.
*/

#import <Foundation/NSObject.h>

@class NSString, NSArray, NSDictionary;

@interface NSTask : NSObject

// Create an NSTask which can be run at a later time
// An NSTask can only be run once. Subsequent attempts to
// run an NSTask will raise.
// Upon task death a notification will be sent
// { Name = NSTaskDidTerminateNotification; object = task; }
//

- (id)init;

// set parameters
// these methods can only be done before a launch
- (void)setLaunchPath:(NSString *)path;
- (void)setArguments:(NSArray *)arguments;
- (void)setEnvironment:(NSDictionary *)dict;
// if not set, use current
- (void)setCurrentDirectoryPath:(NSString *)path;
// if not set, use current

// set standard I/O channels; may be either an NSFileHandle or an NSPipe
- (void)setStandardInput:(id)input;
- (void)setStandardOutput:(id)output;
- (void)setStandardError:(id)error;

// get parameters
- (NSString *)launchPath;
- (NSArray *)arguments;
- (NSDictionary *)environment;
- (NSString *)currentDirectoryPath;

// get standard I/O channels; could be either an NSFileHandle or an NSPipe
- (id)standardInput;
- (id)standardOutput;
- (id)standardError;

// actions
- (void)launch;

- (void)interrupt; // Not always possible. Sends SIGINT.
- (void)terminate; // Not always possible. Sends SIGTERM.

- (BOOL)suspend;
- (BOOL)resume;

// status
- (int)processIdentifier;
- (BOOL)isRunning;

- (int)terminationStatus;

@end

@interface NSTask (NSTaskConveniences)

+ (NSTask *)launchedTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments;
// convenience; create and launch

- (void)waitUntilExit;
// poll the runLoop in defaultMode until task completes

@end

FOUNDATION_EXPORT NSString * const NSTaskDidTerminateNotification;
2 changes: 2 additions & 0 deletions crack.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
int overdrive_enabled; int overdrive_enabled;
int only_armv7; int only_armv7;
int only_armv6; int only_armv6;
int bash;
NSString *bash_script;


#define FAT_CIGAM 0xbebafeca #define FAT_CIGAM 0xbebafeca
#define MH_MAGIC 0xfeedface #define MH_MAGIC 0xfeedface
Expand Down
41 changes: 40 additions & 1 deletion crack.m
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,11 @@
#import "crack.h" #import "crack.h"
#import <Foundation/Foundation.h>
#import "NSTask.h"


int overdrive_enabled = 0; int overdrive_enabled = 0;
int only_armv7 = 0; int only_armv7 = 0;
int only_armv6 = 0; int only_armv6 = 0;
int bash = 0;


NSString * crack_application(NSString *application_basedir, NSString *basename) { NSString * crack_application(NSString *application_basedir, NSString *basename) {
VERBOSE("Creating working directory..."); VERBOSE("Creating working directory...");
Expand Down Expand Up @@ -169,6 +172,7 @@


if (overdrive_enabled) if (overdrive_enabled)
addendum = @"-OD"; addendum = @"-OD";



NSString *ipapath; NSString *ipapath;
if ([[ClutchConfiguration getValue:@"FilenameCredit"] isEqualToString:@"YES"]) { if ([[ClutchConfiguration getValue:@"FilenameCredit"] isEqualToString:@"YES"]) {
Expand All @@ -178,8 +182,43 @@
} }
[[NSFileManager defaultManager] createDirectoryAtPath:@"/var/root/Documents/Cracked/" withIntermediateDirectories:TRUE attributes:nil error:NULL]; [[NSFileManager defaultManager] createDirectoryAtPath:@"/var/root/Documents/Cracked/" withIntermediateDirectories:TRUE attributes:nil error:NULL];
[[NSFileManager defaultManager] removeItemAtPath:ipapath error:NULL]; [[NSFileManager defaultManager] removeItemAtPath:ipapath error:NULL];

NSString *compressionArguments = [[ClutchConfiguration getValue:@"CompressionArguments"] stringByAppendingString:@" "]; NSString *compressionArguments = [[ClutchConfiguration getValue:@"CompressionArguments"] stringByAppendingString:@" "];

if (bash) {
//BASH!!11!!

NSDictionary *environment = [NSDictionary dictionaryWithObjectsAndKeys:
@"ipapath", ipapath,
@"CompressionArguments", compressionArguments,
@"appname", [infoplist objectForKey:@"CFBundleDisplayName"],
@"appversion", [infoplist objectForKey:@"CFBundleVersion"],
nil];

NSTask * bash = [[NSTask alloc] init];
[bash setLaunchPath:@"/bin/bash"];
[bash setCurrentDirectoryPath:@"/"];
NSPipe * out = [NSPipe pipe];
[bash setStandardOutput:out];
[bash setEnvironment:environment];

[bash launch];
[bash waitUntilExit];
[bash release];

NSFileHandle * read = [out fileHandleForReading];
NSData * dataRead = [read readDataToEndOfFile];
NSString * stringRead = [[[NSString alloc] initWithData:dataRead encoding:NSUTF8StringEncoding] autorelease];
NSArray* dataArray = [stringRead componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
for (NSString *string in dataArray) {
NSArray *split = [string componentsSeparatedByString:[NSCharacterSet whitespaceCharacterSet]];
if ([[split objectAtIndex:0] isEqualToString:@"ipapath"]) {
ipapath = [split objectAtIndex:1];
}
}
NSLog(@"output: %@", stringRead);
}

if (compressionArguments == nil) if (compressionArguments == nil)
compressionArguments = @""; compressionArguments = @"";


Expand Down

0 comments on commit 38cc987

Please sign in to comment.