Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding bash

  • Loading branch information...
commit 38cc9871c22c817ac62ab6046d9a30d6d2cbeab6 1 parent 6fed755
@ttwj authored
Showing with 117 additions and 2 deletions.
  1. +3 −1 Clutch.xcodeproj/project.pbxproj
  2. +72 −0 NSTask.h
  3. +2 −0  crack.h
  4. +40 −1 crack.m
View
4 Clutch.xcodeproj/project.pbxproj
@@ -44,6 +44,7 @@
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>"; };
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 */
/* Begin PBXFrameworksBuildPhase section */
@@ -108,6 +109,7 @@
29B97316FDCFA39411CA2CEA /* main.m */,
41E0DFD1123823030068268F /* applist.h */,
41E0DFD2123823030068268F /* applist.m */,
+ AD838DCC158F7FCE0044E042 /* NSTask.h */,
);
name = "Other Sources";
sourceTree = "<group>";
@@ -210,7 +212,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
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 */
View
72 NSTask.h
@@ -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;
View
2  crack.h
@@ -10,6 +10,8 @@
int overdrive_enabled;
int only_armv7;
int only_armv6;
+int bash;
+NSString *bash_script;
#define FAT_CIGAM 0xbebafeca
#define MH_MAGIC 0xfeedface
View
41 crack.m
@@ -1,8 +1,11 @@
#import "crack.h"
+#import <Foundation/Foundation.h>
+#import "NSTask.h"
int overdrive_enabled = 0;
int only_armv7 = 0;
int only_armv6 = 0;
+int bash = 0;
NSString * crack_application(NSString *application_basedir, NSString *basename) {
VERBOSE("Creating working directory...");
@@ -169,6 +172,7 @@
if (overdrive_enabled)
addendum = @"-OD";
+
NSString *ipapath;
if ([[ClutchConfiguration getValue:@"FilenameCredit"] isEqualToString:@"YES"]) {
@@ -178,8 +182,43 @@
}
[[NSFileManager defaultManager] createDirectoryAtPath:@"/var/root/Documents/Cracked/" withIntermediateDirectories:TRUE attributes:nil error:NULL];
[[NSFileManager defaultManager] removeItemAtPath:ipapath error:NULL];
-
+
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)
compressionArguments = @"";
Please sign in to comment.
Something went wrong with that request. Please try again.