@@ -59,8 +59,11 @@ - (void)viewDidLoad {
5959 NSLog (@" Running on %@ with iOS %@ " , system_machine, system_version);
6060
6161 // disable button and toggle if jailbroken/untether detected (everuntether is also detected as daibutsu)
62- if (access (" /daibutsu" , F_OK) != -1 || (access (" /everuntether" , F_OK) != -1 ) ||
63- access (" /untether/untether" , F_OK) != -1 || (access (" /tmp/.jailbroken" , F_OK) != -1 )) {
62+ if (access (" /daibutsu" , F_OK) == 0 ||
63+ access (" /everuntether" , F_OK) == 0 ||
64+ access (" /untether/untether" , F_OK) == 0 ||
65+ access (" /tmp/.jailbroken" , F_OK) == 0 ) {
66+
6467 _tweaks_toggle.enabled = NO ;
6568 [_tweaks_toggle setOn: NO ];
6669 _jailbreak_button.enabled = NO ;
@@ -73,7 +76,10 @@ - (void)viewDidLoad {
7376 [_tweaks_toggle setOn: YES ];
7477 _jailbreak_button.enabled = YES ;
7578 [_jailbreak_button setTitle: @" Jailbreak" forState: UIControlStateNormal];
76- if (access (" /daibutsu" , F_OK) != -1 || access (" /everuntether" , F_OK) != -1 || access (" /untether/untether" , F_OK) != -1 ) {
79+ if (access (" /daibutsu" , F_OK) == 0 ||
80+ access (" /everuntether" , F_OK) == 0 ||
81+ access (" /untether/untether" , F_OK) == 0 ) {
82+
7783 untether_on = false ;
7884 }
7985 }
@@ -84,7 +90,7 @@ - (void)viewDidLoad {
8490 }
8591
8692 // disable openssh toggle if already installed
87- if (access (" /Library/LaunchDaemons/com.openssh.sshd.plist" , F_OK) != - 1 ) {
93+ if (access (" /Library/LaunchDaemons/com.openssh.sshd.plist" , F_OK) == 0 ) {
8894 install_openssh = false ;
8995 }
9096
@@ -128,10 +134,15 @@ - (void)jailbreak_begin {
128134- (void )jailbreak {
129135 print_log (" [*] jailbreak\n " );
130136
137+ dispatch_async (dispatch_get_main_queue (), ^{
138+ [_jailbreak_button setTitle: @" Running exploit" forState: UIControlStateDisabled];
139+ });
131140 run_exploit ();
132141 if (kinfo->tfp0 == 0 ) {
133- print_log (" failed to get tfp0 :(\n " );
134- exit (1 );
142+ dispatch_async (dispatch_get_main_queue (), ^{
143+ [_jailbreak_button setTitle: @" Exploit failed" forState: UIControlStateDisabled];
144+ });
145+ return ;
135146 }
136147 print_log (" [*] got tfp0: 0x%x \n " , kinfo->tfp0 );
137148 print_log (" [*] kbase=0x%08lx \n " , kinfo->kernel_base );
@@ -144,15 +155,27 @@ - (void)jailbreak {
144155 proc_ucred = 0x98 ;
145156 }
146157 if (getuid () != 0 || getgid () != 0 ) {
158+ dispatch_async (dispatch_get_main_queue (), ^{
159+ [_jailbreak_button setTitle: @" Set uid to 0" forState: UIControlStateDisabled];
160+ });
147161 print_log (" [*] Set uid to 0 (proc_ucred: %x )...\n " , proc_ucred);
148162 uint32_t kern_ucred = kread32 (kinfo->kern_proc_addr + proc_ucred);
149163 self_ucred = kread32 (kinfo->self_proc_addr + proc_ucred);
150164 kwrite32 (kinfo->self_proc_addr + proc_ucred, kern_ucred);
151165 setuid (0 );
152166 setgid (0 );
153167 }
154- if (getuid () != 0 || getgid () != 0 ) exit (1 );
168+ if (getuid () != 0 || getgid () != 0 ) {
169+ dispatch_async (dispatch_get_main_queue (), ^{
170+ [_jailbreak_button setTitle: @" setuid failed" forState: UIControlStateDisabled];
171+ });
172+ print_log (" [*] setuid failed\n " );
173+ return ;
174+ }
155175
176+ dispatch_async (dispatch_get_main_queue (), ^{
177+ [_jailbreak_button setTitle: @" Patching kernel" forState: UIControlStateDisabled];
178+ });
156179 print_log (" [*] patching kernel...\n " );
157180 jailbreak_init ();
158181 if (ios9)
@@ -162,13 +185,67 @@ - (void)jailbreak {
162185
163186 print_log (" [*] time for postjailbreak...\n " );
164187 tweaks_on = _tweaks_toggle.isOn ;
188+ // disable untether toggle again if 9.3.5/6 just to be sure
189+ if (strstr (ckernv, " 3248.61" )) {
190+ untether_on = false ;
191+ }
165192 print_log (" [*] untether_on: %d \n " , untether_on);
166193 print_log (" [*] tweaks_on: %d \n " , tweaks_on);
167- postjailbreak ();
194+ print_log (" [*] reinstall_strap: %d \n " , reinstall_strap);
195+
196+ dispatch_async (dispatch_get_main_queue (), ^{
197+ [_jailbreak_button setTitle: @" Remounting rootfs" forState: UIControlStateDisabled];
198+ });
199+ postjailbreak_remount ();
200+
201+ if (!postjailbreak_check_status () || reinstall_strap) {
202+ dispatch_async (dispatch_get_main_queue (), ^{
203+ [_jailbreak_button setTitle: @" Installing bootstrap" forState: UIControlStateDisabled];
204+ });
205+ postjailbreak_bootstrap ();
206+
207+ }
208+
209+ if (!postjailbreak_check_sbshowapp ()) {
210+ dispatch_async (dispatch_get_main_queue (), ^{
211+ [_jailbreak_button setTitle: @" Fixing icons" forState: UIControlStateDisabled];
212+ });
213+ postjailbreak_add_sbshowapp ();
214+ dispatch_async (dispatch_get_main_queue (), ^{
215+ [_jailbreak_button setTitle: @" Running uicache" forState: UIControlStateDisabled];
216+ });
217+ postjailbreak_uicache ();
218+ }
219+
220+ if (install_openssh) {
221+ dispatch_async (dispatch_get_main_queue (), ^{
222+ [_jailbreak_button setTitle: @" Installing OpenSSH" forState: UIControlStateDisabled];
223+ });
224+ postjailbreak_openssh ();
225+ }
226+
227+ if (tweaks_on) {
228+ dispatch_async (dispatch_get_main_queue (), ^{
229+ [_jailbreak_button setTitle: @" Loading daemons" forState: UIControlStateDisabled];
230+ });
231+ postjailbreak_tweaks ();
232+ }
233+
234+ if (untether_on) {
235+ dispatch_async (dispatch_get_main_queue (), ^{
236+ [_jailbreak_button setTitle: @" Installing untether" forState: UIControlStateDisabled];
237+ });
238+ postjailbreak_untether ();
239+ dispatch_async (dispatch_get_main_queue (), ^{
240+ [self showCompletionAlert ];
241+ });
242+ return ;
243+ }
168244
169245 dispatch_async (dispatch_get_main_queue (), ^{
170- [self showCompletionAlert ];
246+ [_jailbreak_button setTitle: @" Respringing " forState: UIControlStateDisabled ];
171247 });
248+ postjailbreak_respring ();
172249}
173250
174251// Show an alert after successful jailbreak
0 commit comments