|
@@ -75,6 +75,7 @@
|
|
|
@interface ViewController ()
|
|
|
{
|
|
|
BOOL _force;
|
|
|
+ BOOL _disabled;
|
|
|
}
|
|
|
@property (weak, nonatomic) IBOutlet UIImageView *logoView;
|
|
|
@property (weak, nonatomic) IBOutlet FocusedButton *goButton;
|
|
@@ -118,12 +119,15 @@ AVPlayerViewController *cont;
|
|
|
struct utsname u;
|
|
|
uname(&u);
|
|
|
[self log:[NSString stringWithFormat:@"%s \n", u.version]];
|
|
|
-
|
|
|
+ _disabled = NO;
|
|
|
// abort if already jailbroken
|
|
|
if (strstr(u.version, "MarijuanARM")) {
|
|
|
- self.goButton.enabled = NO;
|
|
|
- self.goButton.backgroundColor = UIColor.darkGrayColor;
|
|
|
+ //self.goButton.enabled = NO;
|
|
|
+ _disabled = YES;
|
|
|
+ //self.goButton.backgroundColor = UIColor.darkGrayColor;
|
|
|
[self.goButton setTitle:@"jailbroke yo!" forState:UIControlStateDisabled];
|
|
|
+ [self.goButton buttonColors:UIColor.darkGrayColor
|
|
|
+ andUnfocused:[UIColor whiteColor]];
|
|
|
}
|
|
|
|
|
|
// try to load offsets for device
|
|
@@ -171,7 +175,12 @@ AVPlayerViewController *cont;
|
|
|
|
|
|
- (IBAction)go:(UIButton *)sender {
|
|
|
|
|
|
-
|
|
|
+ if (_disabled) {
|
|
|
+
|
|
|
+ LOG("Already jailbroken bro!");
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
[self.consoleView.layoutManager ensureLayoutForTextContainer:self.consoleView.textContainer];
|
|
@@ -200,6 +209,7 @@ AVPlayerViewController *cont;
|
|
|
[self.goButton setTitle:@"try again" forState:UIControlStateNormal];
|
|
|
|
|
|
[self log:@"ERROR: exploit failed \n"];
|
|
|
+ [self kludgeBoot];
|
|
|
return;
|
|
|
}
|
|
|
LOG("v0rtex was successful");
|
|
@@ -248,6 +258,17 @@ AVPlayerViewController *cont;
|
|
|
|
|
|
}
|
|
|
|
|
|
+//we know retrying with reboot, and if we detect faiure wait a few seconds and try again to force a reboot
|
|
|
+- (void)kludgeBoot
|
|
|
+{
|
|
|
+ LOG("== Auto retrying in 3 seconds to trigger reboot ==");
|
|
|
+ [self log:@"== Auto retrying in 3 seconds to trigger reboot =="];
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
|
|
+
|
|
|
+ [self go:nil];
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
- (void)bootstrap {
|
|
|
[self log:@"bootstrapping"];
|
|
|
|
|
@@ -264,16 +285,40 @@ AVPlayerViewController *cont;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
++ (NSString *)returnForProcess:(NSString *)call
|
|
|
+{
|
|
|
+ if (call==nil)
|
|
|
+ return 0;
|
|
|
+ char line[200];
|
|
|
+ NSLog(@"running process: %@", call);
|
|
|
+ FILE* fp = popen([call UTF8String], "r");
|
|
|
+ NSMutableArray *lines = [[NSMutableArray alloc]init];
|
|
|
+ if (fp)
|
|
|
+ {
|
|
|
+ while (fgets(line, sizeof line, fp))
|
|
|
+ {
|
|
|
+ NSString *s = [NSString stringWithCString:line encoding:NSUTF8StringEncoding];
|
|
|
+ s = [s stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
|
+ [lines addObject:s];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pclose(fp);
|
|
|
+ return [lines componentsJoinedByString:@"\n"];
|
|
|
+}
|
|
|
+
|
|
|
- (void)finish {
|
|
|
+
|
|
|
+ NSString *hostname = [ViewController returnForProcess:@"/bin/hostname"];
|
|
|
+
|
|
|
[self log:@"device is now jailbroken!"];
|
|
|
[self log:@""];
|
|
|
- [self log:@"SSH server is ready on port 2222"];
|
|
|
+ [self log:[NSString stringWithFormat:@"SSH server is ready at %@.local", hostname]];
|
|
|
[self log:@"change your root/mobile passwords"];
|
|
|
[self log:@""];
|
|
|
[self log:@"respring to load tweaks"];
|
|
|
|
|
|
sleep(2);
|
|
|
-
|
|
|
+ RunCmd("/usr/libexec/substrate");
|
|
|
LOG("reloading daemons...");
|
|
|
pid_t pid;
|
|
|
posix_spawn(&pid, "/bin/launchctl", 0, 0, (char**)&(const char*[]){"/bin/launchctl", "load", "/Library/LaunchDaemons/0.reload.plist", NULL}, NULL);
|
|
@@ -288,7 +333,7 @@ AVPlayerViewController *cont;
|
|
|
|
|
|
- (void)restart {
|
|
|
|
|
|
- RunCmd("/usr/libexec/substrate");
|
|
|
+
|
|
|
LOG("Running uicache...");
|
|
|
|
|
|
//pid_t pd;
|