Browse Source

don't reinstall bootstrap every jailbreak; added force reinstall button

Sticktron 6 years ago
parent
commit
8553d09335

+ 6 - 0
g0blin.xcodeproj/project.pbxproj

@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		EE0A1C281FF8891A001030DB /* SettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = EE0A1C271FF8891A001030DB /* SettingsController.m */; };
 		EE59F3C31FF81C1E006BCFE1 /* bootstrap.tgz in Resources */ = {isa = PBXBuildFile; fileRef = EE59F3C21FF81C1E006BCFE1 /* bootstrap.tgz */; };
 		EE9402401FF33CAE00C9325F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EE94023F1FF33CAE00C9325F /* AppDelegate.m */; };
 		EE9402431FF33CAE00C9325F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9402421FF33CAE00C9325F /* ViewController.m */; };
@@ -30,6 +31,8 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		EE0A1C261FF8891A001030DB /* SettingsController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SettingsController.h; sourceTree = "<group>"; };
+		EE0A1C271FF8891A001030DB /* SettingsController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SettingsController.m; sourceTree = "<group>"; };
 		EE59F3C21FF81C1E006BCFE1 /* bootstrap.tgz */ = {isa = PBXFileReference; lastKnownFileType = file; path = bootstrap.tgz; sourceTree = "<group>"; };
 		EE94023B1FF33CAE00C9325F /* g0blin.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = g0blin.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		EE94023E1FF33CAE00C9325F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -118,6 +121,8 @@
 				EE94023F1FF33CAE00C9325F /* AppDelegate.m */,
 				EE9402411FF33CAE00C9325F /* ViewController.h */,
 				EE9402421FF33CAE00C9325F /* ViewController.m */,
+				EE0A1C261FF8891A001030DB /* SettingsController.h */,
+				EE0A1C271FF8891A001030DB /* SettingsController.m */,
 				EE9402441FF33CAE00C9325F /* Main.storyboard */,
 				EE9402471FF33CAE00C9325F /* Assets.xcassets */,
 				EE9402491FF33CAE00C9325F /* LaunchScreen.storyboard */,
@@ -235,6 +240,7 @@
 				EE9402621FF375E700C9325F /* kpp.m in Sources */,
 				EE9828C01FF3E2C50085B633 /* remount.m in Sources */,
 				EE9828C31FF3E9AA0085B633 /* bootstrap.m in Sources */,
+				EE0A1C281FF8891A001030DB /* SettingsController.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 72 - 2
g0blin/Base.lproj/Main.storyboard

@@ -32,7 +32,7 @@
                                 <nil key="highlightedColor"/>
                             </label>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="(wip) jailbreak for iOS 10.3.x A7-A9" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UcM-Ne-vdF">
-                                <rect key="frame" x="16" y="97" width="312" height="25"/>
+                                <rect key="frame" x="16" y="97" width="288" height="25"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" name="Menlo-Regular" family="Menlo" pointSize="12"/>
                                 <color key="textColor" red="0.37055522200000002" green="0.37056469920000001" blue="0.37055957319999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -85,6 +85,23 @@
                                 <color key="progressTintColor" red="0.58188301320000002" green="0.21569153669999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <color key="trackTintColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                             </progressView>
+                            <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="detailDisclosure" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ida-x7-w8p">
+                                <rect key="frame" x="337" y="45" width="22" height="22"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                <color key="tintColor" red="0.37055522200000002" green="0.37056469920000001" blue="0.37055957319999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <connections>
+                                    <segue destination="E4R-mI-ttA" kind="popoverPresentation" popoverAnchorView="ida-x7-w8p" id="VLf-rO-Vwz">
+                                        <popoverArrowDirection key="popoverArrowDirection" up="YES" down="YES" left="YES" right="YES"/>
+                                    </segue>
+                                </connections>
+                            </button>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="force reinstall bootstrap: YES" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YdP-3g-Mny">
+                                <rect key="frame" x="19" y="221" width="337" height="25"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <fontDescription key="fontDescription" name="Menlo-Regular" family="Menlo" pointSize="10"/>
+                                <color key="textColor" red="0.37055522200000002" green="0.37056469920000001" blue="0.37055957319999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <nil key="highlightedColor"/>
+                            </label>
                         </subviews>
                         <color key="backgroundColor" red="0.12984204290000001" green="0.12984612579999999" blue="0.12984395030000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                         <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
@@ -93,11 +110,64 @@
                         <outlet property="consoleView" destination="Elh-sj-UCK" id="gJk-Xf-NFc"/>
                         <outlet property="goButton" destination="LzW-79-NNF" id="z7c-UD-HAE"/>
                         <outlet property="progressView" destination="bbB-ma-TGm" id="lIa-zO-eEL"/>
+                        <outlet property="reinstallBootstrapLabel" destination="YdP-3g-Mny" id="fSl-BT-ogn"/>
+                        <outlet property="settingsButton" destination="ida-x7-w8p" id="Qpa-PV-mI8"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="138.40000000000001" y="131.78410794602701"/>
+            <point key="canvasLocation" x="136.80000000000001" y="130.88455772113943"/>
+        </scene>
+        <!--Settings Controller-->
+        <scene sceneID="3qZ-li-ZPj">
+            <objects>
+                <viewController id="E4R-mI-ttA" customClass="SettingsController" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="Gs4-qb-pme">
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="UjU-65-8UT">
+                                <rect key="frame" x="310" y="130" width="49" height="31"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+                                <color key="onTintColor" red="0.58188301320000002" green="0.21569153669999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                            </switch>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="force re-install bootstrap" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YTP-i7-QOK">
+                                <rect key="frame" x="16" y="133" width="273" height="25"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <fontDescription key="fontDescription" name="Menlo-Regular" family="Menlo" pointSize="12"/>
+                                <color key="textColor" red="0.37055522200000002" green="0.37056469920000001" blue="0.37055957319999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="SETTINGS" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PVP-8v-gf0">
+                                <rect key="frame" x="16" y="45" width="265" height="65"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <fontDescription key="fontDescription" name="Menlo-Bold" family="Menlo" pointSize="55"/>
+                                <color key="textColor" red="0.58188301320000002" green="0.21569153669999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Mof-uo-FQE">
+                                <rect key="frame" x="157" y="603" width="60" height="34"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="18"/>
+                                <state key="normal" title="Save">
+                                    <color key="titleColor" red="0.58188301320000002" green="0.21569153669999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                </state>
+                                <connections>
+                                    <segue destination="ckB-rY-P5O" kind="unwind" unwindAction="prepareForUnwind:" id="5Dj-k2-63R"/>
+                                </connections>
+                            </button>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <viewLayoutGuide key="safeArea" id="WAO-C2-OHy"/>
+                    </view>
+                    <connections>
+                        <outlet property="reinstallBootstrapSwitch" destination="UjU-65-8UT" id="pvk-Ve-lp5"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="9aX-FD-mDM" userLabel="First Responder" sceneMemberID="firstResponder"/>
+                <exit id="ckB-rY-P5O" userLabel="Exit" sceneMemberID="exit"/>
+            </objects>
+            <point key="canvasLocation" x="855" y="132.04225352112675"/>
         </scene>
     </scenes>
 </document>

+ 15 - 0
g0blin/SettingsController.h

@@ -0,0 +1,15 @@
+//
+//  SettingsController.h
+//  g0blin
+//
+//  Created by Sticktron on 2017-12-30.
+//  Copyright © 2017 Sticktron. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface SettingsController : UIViewController
+
+@property (weak, nonatomic) IBOutlet UISwitch *reinstallBootstrapSwitch;
+
+@end

+ 39 - 0
g0blin/SettingsController.m

@@ -0,0 +1,39 @@
+//
+//  SettingsController.m
+//  g0blin
+//
+//  Created by Sticktron on 2017-12-30.
+//  Copyright © 2017 Sticktron. All rights reserved.
+//
+
+#import "SettingsController.h"
+
+@interface SettingsController ()
+
+@end
+
+@implementation SettingsController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    [self.reinstallBootstrapSwitch setOn:NO animated:NO];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+/*
+#pragma mark - Navigation
+
+// In a storyboard-based application, you will often want to do a little preparation before navigation
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+    // Get the new view controller using [segue destinationViewController].
+    // Pass the selected object to the new view controller.
+}
+*/
+
+@end

+ 23 - 4
g0blin/ViewController.m

@@ -7,6 +7,7 @@
 //
 
 #import "ViewController.h"
+#import "SettingsController.h"
 #include "v0rtex.h"
 #include "common.h"
 #include "offsets.h"
@@ -24,6 +25,8 @@
 @property (weak, nonatomic) IBOutlet UIButton *goButton;
 @property (weak, nonatomic) IBOutlet UIProgressView *progressView;
 @property (weak, nonatomic) IBOutlet UITextView *consoleView;
+@property (weak, nonatomic) IBOutlet UIButton *settingsButton;
+@property (weak, nonatomic) IBOutlet UILabel *reinstallBootstrapLabel;
 @end
 
 
@@ -46,6 +49,9 @@ static uint64_t kbase;
     
     self.goButton.layer.cornerRadius = 16;
     
+    self.reinstallBootstrapLabel.hidden = YES;
+    
+    
     // print kernel version
     struct utsname u;
     uname(&u);
@@ -78,6 +84,13 @@ static uint64_t kbase;
     self.consoleView.text = [NSString stringWithFormat:@"%@%@ \n", self.consoleView.text, text];
 }
 
+- (IBAction)prepareForUnwind:(UIStoryboardSegue *)segue {
+    //segue exit marker
+    
+    SettingsController *settingsController = segue.sourceViewController;
+    self.reinstallBootstrapLabel.hidden = !settingsController.reinstallBootstrapSwitch.on;
+}
+
 - (IBAction)go:(UIButton *)sender {
     self.goButton.enabled = NO;
     self.goButton.backgroundColor = UIColor.darkGrayColor;
@@ -147,12 +160,17 @@ static uint64_t kbase;
 - (void)bootstrap {
     
     [self.progressView setProgress:0.6 animated:YES];
-    [self log:@"installing bootstrap"];
+    [self log:@"bootstrapping"];
+    
+    BOOL force = NO;
+    if (self.reinstallBootstrapLabel.hidden == NO) {
+        force = YES;
+        [self log:@"(forcing reinstall)"];
+    }
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
-        
-        if (do_bootstrap() != KERN_SUCCESS) {
-            [self log:@"ERROR: failed to install bootstrap \n"];
+        if (do_bootstrap(force) != KERN_SUCCESS) {
+            [self log:@"ERROR: failed to bootstrap \n"];
             return;
         }
         
@@ -172,6 +190,7 @@ static uint64_t kbase;
     LOG("reloading...");
     pid_t pid;
     posix_spawn(&pid, "/bin/launchctl", 0, 0, (char**)&(const char*[]){"/bin/launchctl", "load", "/Library/LaunchDaemons/0.reload.plist", NULL}, NULL);
+//    waitpid(pid, 0, 0);
 }
 
 @end

+ 1 - 1
g0blin/bootstrap.h

@@ -13,6 +13,6 @@
 #include <stdio.h>
 #include <mach/mach.h>
 
-kern_return_t do_bootstrap(void);
+kern_return_t do_bootstrap(bool force);
 
 #endif /* bootstrap_h */

+ 12 - 9
g0blin/bootstrap.m

@@ -14,7 +14,7 @@
 #include <mach-o/dyld.h>
 
 
-kern_return_t do_bootstrap() {
+kern_return_t do_bootstrap(bool force) {
     
     char path[256];
     uint32_t size = sizeof(path);
@@ -24,9 +24,8 @@ kern_return_t do_bootstrap() {
     NSString* execpath = [[NSString stringWithUTF8String:pt] stringByDeletingLastPathComponent];
     
     int f = open("/.installed_g0blin", O_RDONLY);
-//    if (f == -1) {
-    if (f == f) { // ALWAYS INSTALL THE BOOTSTRAP FOR NOW.....
-        LOG("bootstrap not yet installed");
+    if (f == -1 || force) {
+        LOG("installing bootstrap...");
         
         NSString* bootstrap = [execpath stringByAppendingPathComponent:@"bootstrap.tgz"];
         NSString* tar = [execpath stringByAppendingPathComponent:@"tar"];
@@ -37,14 +36,13 @@ kern_return_t do_bootstrap() {
         
         // copy over tar, launchctl
         copyfile([tar UTF8String], "/bin/tar", 0, COPYFILE_ALL);
-        chmod("/bin/tar", 0777);
+        chmod("/bin/tar", 0755);
         copyfile([launchctl UTF8String], "/bin/launchctl", 0, COPYFILE_ALL);
         chmod("/bin/launchctl", 0755);
         
         // unpack bootstrap tarball
         chdir("/");
         posix_spawn(&pd, "/bin/tar", 0, 0, (char**)&(const char*[]){"/bin/tar", "--preserve-permissions", "--no-overwrite-dir", "-xvf", [bootstrap UTF8String], NULL}, NULL);
-        NSLog(@"pid = %x", pd);
         waitpid(pd, 0, 0);
         LOG("bootstrap unpacked");
         
@@ -97,8 +95,12 @@ kern_return_t do_bootstrap() {
         LOG("running uicache");
         posix_spawn(&pd, "/usr/bin/uicache", 0, 0, (char**)&(const char*[]){"/usr/bin/uicache", NULL}, NULL);
         waitpid(pd, 0, 0);
+        
+        LOG("bootstrap installed");
+        
+    } else {
+        LOG("bootstrap already installed");
     }
-    LOG("bootstrapped!");
     
     
     // copy reload
@@ -140,7 +142,8 @@ kern_return_t do_bootstrap() {
     chmod("/var/MobileAsset/Assets/com_apple_MobileAsset_SoftwareUpdate", 000);
     chown("/var/MobileAsset/Assets/com_apple_MobileAsset_SoftwareUpdate", 0, 0);
     LOG("killed OTA updater");
-    
-    
+
+    LOG("finished bootstrapping");
+        
     return KERN_SUCCESS;
 }