-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathViewController.m
122 lines (95 loc) · 5.21 KB
/
ViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#import "ViewController.h"
#include "async_wake.h"
#include "fun.h"
#include "codesign.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <dlfcn.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)checkVersion {
NSString *rawgitHistory = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"githistory" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];
__block NSArray *gitHistory = [rawgitHistory componentsSeparatedByString:@"\n"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul), ^{
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://coolstar.org/electra/gitlatest.txt"]];
// User isn't on a network, or the request failed
if (data == nil) return;
NSString *gitCommit = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if (![gitHistory containsObject:gitCommit]){
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Update Available!" message:@"An update for Electra is available! Please visit https://coolstar.org/electra/ on a computer to download the latest IPA!" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alertController animated:YES completion:nil];
});
}
});
}
- (void)viewDidLoad {
[super viewDidLoad];
[self checkVersion];
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
BOOL enable3DTouch = YES;
//version_range=(1443, 1445.32) 11.0(15A5327g)=1438.0999999999999
if (kCFCoreFoundationVersionNumber < 1438.09 || kCFCoreFoundationVersionNumber > 1445.32){
[jailbreak setEnabled:NO];
[enableTweaks setEnabled:NO];
[jailbreak setTitle:@"Version Error" forState:UIControlStateNormal];
enable3DTouch = NO;
}
uint32_t flags;
csops(getpid(), CS_OPS_STATUS, &flags, 0);
if ((flags & CS_PLATFORM_BINARY)){
[jailbreak setEnabled:NO];
[enableTweaks setEnabled:NO];
[jailbreak setTitle:@"Already Jailbroken" forState:UIControlStateNormal];
enable3DTouch = NO;
}
if (enable3DTouch){
[notificationCenter addObserver:self selector:@selector(doit:) name:@"Jailbreak" object:nil];
}
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)credits:(id)sender {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Credits" message:@"Electra is brought to you by CoolStar, Ian Beer, theninjaprawn, stek29, Siguza and xerub.\n\nElectra includes the following software:\namfid patch by theninjaprawn\njailbreakd & tweak injection by CoolStar\nunlocknvram & sandbox fixes by stek29\nlibsubstitute by comex\nContains code from simject by angelXwind\nAnemone by CoolStar, kirb, isklikas and goeo\nPreferenceLoader by DHowett & rpetrich" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alertController animated:YES completion:nil];
}
- (IBAction)doit:(id)sender {
[jailbreak setEnabled:NO];
[enableTweaks setEnabled:NO];
[jailbreak setTitle:@"Please Wait (1/3)" forState:UIControlStateNormal];
BOOL shouldEnableTweaks = [enableTweaks isOn];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul), ^{
mach_port_t user_client;
mach_port_t tfp0 = get_tfp0(&user_client);
dispatch_async(dispatch_get_main_queue(), ^{
[jailbreak setTitle:@"Please Wait (2/3)" forState:UIControlStateNormal];
});
if (begin_fun(tfp0, user_client, shouldEnableTweaks) == 0){
dispatch_async(dispatch_get_main_queue(), ^{
[jailbreak setTitle:@"Jailbroken" forState:UIControlStateNormal];
UIAlertController *dropbearRunning = [UIAlertController alertControllerWithTitle:@"Dropbear Running" message:@"Dropbear is now running! Enjoy." preferredStyle:UIAlertControllerStyleAlert];
[dropbearRunning addAction:[UIAlertAction actionWithTitle:@"Exit" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
[dropbearRunning dismissViewControllerAnimated:YES completion:nil];
exit(0);
}]];
[self presentViewController:dropbearRunning animated:YES completion:nil];
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[jailbreak setTitle:@"Error Jailbreaking" forState:UIControlStateNormal];
});
}
NSLog(@" ♫ KPP never bothered me anyway... ♫ ");
});
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end