├── .github └── workflows │ └── blank.yml ├── GeneratorAutoSetterRootListController.m ├── Makefile ├── README ├── Resources ├── Info.plist └── Root.plist ├── control ├── entitlements.xml ├── entry.plist ├── libdementia.h ├── libdementia.tbd ├── postinst.c ├── rcsetgenerator.m ├── setgenerator.m └── tfp0.xml /.github/workflows/blank.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | # Controls when the action will run. 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the master branch 8 | push: 9 | branches: [ master ] 10 | pull_request: 11 | branches: [ master ] 12 | 13 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 14 | jobs: 15 | # This workflow contains a single job called "build" 16 | build: 17 | # The type of runner that the job will run on 18 | runs-on: macos-10.15 19 | 20 | # Steps represent a sequence of tasks that will be executed as part of the job 21 | steps: 22 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 23 | - uses: actions/checkout@v2 24 | 25 | # Runs a set of commands using the runners shell 26 | - name: Run a multi-line script 27 | run: | 28 | sudo xcode-select -s /Applications/Xcode_11.7.app 29 | brew update 30 | brew install ldid dpkg xz gnu-sed 31 | export THEOS=/opt/theos 32 | sudo git clone --recursive https://github.com/Halo-Michael/theos.git $THEOS 33 | make all 34 | mkdir build 35 | cp com.michael.generatorautosetter_*_iphoneos-arm.deb build 36 | - name: Upload build 37 | uses: actions/upload-artifact@v1 38 | with: 39 | name: package file 40 | path: build/ 41 | -------------------------------------------------------------------------------- /GeneratorAutoSetterRootListController.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | UIAlertController *alert(NSString *alertTitle, NSString *alertMessage, NSString *actionTitle) { 5 | UIAlertController *theAlert = [UIAlertController alertControllerWithTitle:alertTitle message:alertMessage preferredStyle:UIAlertControllerStyleAlert]; 6 | UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:actionTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {}]; 7 | [theAlert addAction:defaultAction]; 8 | return theAlert; 9 | } 10 | 11 | bool vaildGenerator(NSString *generator) { 12 | if ([generator length] != 18 || [generator characterAtIndex:0] != '0' || [generator characterAtIndex:1] != 'x') { 13 | return false; 14 | } 15 | for (int i = 2; i <= 17; i++) { 16 | if (!isxdigit([generator characterAtIndex:i])) { 17 | return false; 18 | } 19 | } 20 | return true; 21 | } 22 | 23 | @interface GeneratorAutoSetterRootListController : PSListController 24 | 25 | @end 26 | 27 | @implementation GeneratorAutoSetterRootListController 28 | 29 | - (NSArray *)specifiers { 30 | if (!_specifiers) { 31 | _specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self]; 32 | } 33 | return _specifiers; 34 | } 35 | 36 | - (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier { 37 | if ([[specifier propertyForKey:@"key"] isEqualToString:@"generator"]) { 38 | if (!vaildGenerator(value)) { 39 | [self presentViewController:alert(@"setgenerator", [NSString stringWithFormat:@"Wrong generator \"%@\":\nFormat error!", value], @"OK") animated:YES completion:nil]; 40 | return; 41 | } 42 | } 43 | [super setPreferenceValue:value specifier:specifier]; 44 | } 45 | 46 | -(void)setgenerator { 47 | [self.view endEditing:YES]; 48 | NSMutableString *alertMessage = [[NSMutableString alloc] init]; 49 | FILE *fp = popen("setgenerator", "r"); 50 | char buffer = fgetc(fp); 51 | while (!feof(fp)) { 52 | [alertMessage appendFormat:@"%c", buffer]; 53 | buffer = fgetc(fp); 54 | } 55 | pclose(fp); 56 | [alertMessage deleteCharactersInRange:NSMakeRange([alertMessage length] - 1, 1)]; 57 | [self presentViewController:alert(@"setgenerator", alertMessage, @"OK") animated:YES completion:nil]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VERSION = 0.5.11 2 | THEOS=/opt/theos 3 | 64CC = xcrun -sdk $(THEOS)/sdks/iPhoneOS13.0.sdk clang -arch arm64 -miphoneos-version-min=9.0 -O2 4 | 64eCC = $(64CC) -arch arm64e 5 | SED = gsed 6 | LDID = ldid 7 | 8 | .PHONY: all clean 9 | 10 | all: clean rcsetgenerator postinst setgenerator GeneratorAutoSetterRootListController 11 | mkdir com.michael.generatorautosetter_$(VERSION)_iphoneos-arm 12 | mkdir com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/DEBIAN 13 | cp control com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/DEBIAN 14 | $(SED) -i 's/^Version:\x24/Version: $(VERSION)/g' com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/DEBIAN/control 15 | mv postinst com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/DEBIAN 16 | mkdir com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/usr 17 | mkdir com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/usr/bin 18 | mv setgenerator com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/usr/bin 19 | mkdir com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/etc 20 | mkdir com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/etc/rc.d 21 | mv rcsetgenerator com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/etc/rc.d/setgenerator 22 | mkdir com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/Library 23 | mkdir com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/Library/PreferenceLoader 24 | mkdir com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/Library/PreferenceLoader/Preferences 25 | cp entry.plist com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/Library/PreferenceLoader/Preferences/GeneratorAutoSetter.plist 26 | mkdir com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/Library/PreferenceBundles 27 | cp -r Resources com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/Library/PreferenceBundles/GeneratorAutoSetter.bundle 28 | mv GeneratorAutoSetterRootListController com.michael.generatorautosetter_$(VERSION)_iphoneos-arm/Library/PreferenceBundles/GeneratorAutoSetter.bundle/GeneratorAutoSetter 29 | dpkg -b com.michael.generatorautosetter_$(VERSION)_iphoneos-arm 30 | 31 | postinst: clean 32 | $(64CC) postinst.c -o postinst 33 | strip postinst 34 | $(LDID) -Sentitlements.xml postinst 35 | 36 | rcsetgenerator: clean 37 | $(64CC) -fobjc-arc rcsetgenerator.m -framework Foundation -o rcsetgenerator 38 | strip rcsetgenerator 39 | $(LDID) -Sentitlements.xml rcsetgenerator 40 | 41 | setgenerator: clean 42 | $(64CC) -fobjc-arc setgenerator.m libdementia.tbd -framework Foundation -o setgenerator 43 | strip setgenerator 44 | $(LDID) -Stfp0.xml setgenerator 45 | 46 | GeneratorAutoSetterRootListController: clean 47 | $(64eCC) -dynamiclib -fobjc-arc -install_name /Library/PreferenceBundles/GeneratorAutoSetter.bundle/GeneratorAutoSetter -I${THEOS}/vendor/include/ -framework Foundation -framework UIKit ${THEOS}/sdks/iPhoneOS13.0.sdk/System/Library/PrivateFrameworks/Preferences.framework/Preferences.tbd GeneratorAutoSetterRootListController.m -o GeneratorAutoSetterRootListController 48 | strip -x GeneratorAutoSetterRootListController 49 | $(LDID) -S GeneratorAutoSetterRootListController 50 | 51 | clean: 52 | rm -rf com.michael.generatorautosetter_* 53 | rm -f postinst rcsetgenerator setgenerator GeneratorAutoSetterRootListController 54 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Auto set your generator when jailbreaking! 2 | Usage: setgenerator [generator] 3 | If you didn't choose a generator, Generator Auto Setter will set 0x1111111111111111 as default generator. 4 | Only Support Checkra1n. (Because other jailbreak tool doesn't need that.) 5 | -------------------------------------------------------------------------------- /Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | GeneratorAutoSetter 9 | CFBundleIdentifier 10 | com.michael.generatorautosetter 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | NSPrincipalClass 22 | GeneratorAutoSetterRootListController 23 | 24 | 25 | -------------------------------------------------------------------------------- /Resources/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | cell 9 | PSGroupCell 10 | label 11 | Auto Set Generator 12 | footerText 13 | Auto set generator when jailbreaking 14 | 15 | 16 | cell 17 | PSSwitchCell 18 | default 19 | 20 | defaults 21 | com.michael.generator 22 | key 23 | enabled 24 | label 25 | Enable 26 | 27 | 28 | cell 29 | PSGroupCell 30 | label 31 | Generator 32 | footerText 33 | Set a generator 34 | 35 | 36 | cell 37 | PSEditTextCell 38 | defaults 39 | com.michael.generator 40 | default 41 | 0x1111111111111111 42 | label 43 | Generator 44 | key 45 | generator 46 | 47 | 48 | cell 49 | PSButtonCell 50 | label 51 | Set 52 | action 53 | setgenerator 54 | 55 | 56 | title 57 | Generator Auto Setter 58 | 59 | 60 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.michael.generatorautosetter 2 | Version: 3 | Section: Tweaks 4 | Name: Generator Auto Setter 5 | Author: Halo Michael 6 | Sponsor: Halo Michael 7 | Maintainer: Halo Michael 8 | Depends: firmware (>= 12.0), com.michael.libdementia (>= 0.2.7), preferenceloader 9 | Architecture: iphoneos-arm 10 | Description: Auto set your generator when jailbreaking! 11 | Depiction: https://halo-michael.github.io/repo/info/generatorautosetter 12 | -------------------------------------------------------------------------------- /entitlements.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | platform-application 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /entry.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | entry 6 | 7 | bundle 8 | GeneratorAutoSetter 9 | cell 10 | PSLinkCell 11 | detail 12 | GeneratorAutoSetterRootListController 13 | icon 14 | icon.png 15 | isController 16 | 17 | label 18 | Generator Auto Setter 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /libdementia.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 0x7ff 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | #ifndef LIBDIMENTIO_H 16 | # define LIBDIMENTIO_H 17 | # include 18 | # include 19 | # define KADDR_FMT "0x%" PRIX64 20 | typedef uint64_t kaddr_t; 21 | typedef kern_return_t (*kread_func_t)(kaddr_t, void *, size_t), (*kwrite_func_t)(kaddr_t, const void *, size_t); 22 | 23 | void 24 | dimentio_term(void); 25 | 26 | kern_return_t 27 | dimentio_init(kaddr_t, kread_func_t, kwrite_func_t); 28 | 29 | kern_return_t 30 | dimentio(uint64_t *, bool, uint8_t[CC_SHA384_DIGEST_LENGTH], size_t *); 31 | 32 | kern_return_t 33 | dimentio_preinit(uint64_t *, bool, uint8_t[CC_SHA384_DIGEST_LENGTH], size_t *); 34 | #endif 35 | -------------------------------------------------------------------------------- /libdementia.tbd: -------------------------------------------------------------------------------- 1 | --- 2 | archs: [ arm64 ] 3 | platform: ios 4 | install-name: /usr/lib/libdementia.dylib 5 | current-version: 0.0 6 | compatibility-version: 0.0 7 | exports: 8 | - archs: [ arm64 ] 9 | symbols: [ 'radr://5614542', _dimentio, _dimentio_init, _dimentio_preinit, 10 | _dimentio_term ] 11 | ... 12 | -------------------------------------------------------------------------------- /postinst.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | if (getuid() != 0) { 8 | printf("Run this as root!\n"); 9 | return 1; 10 | } 11 | 12 | chown("/usr/bin/setgenerator", 0, 0); 13 | chmod("/usr/bin/setgenerator", 06755); 14 | 15 | execvp("setgenerator", (char *[]){"setgenerator", NULL}); 16 | perror("setgenerator"); 17 | return -1; 18 | } 19 | -------------------------------------------------------------------------------- /rcsetgenerator.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #define bundleID @"com.michael.generator" 4 | #define containerURL [NSURL URLWithString:@"file:///private/var/mobile"] 5 | 6 | int main() { 7 | id enabled = [[[NSUserDefaults alloc] _initWithSuiteName:bundleID container:containerURL] objectForKey:@"enabled"]; 8 | if (enabled != nil) { 9 | if ([enabled isKindOfClass:[NSNumber class]]) { 10 | if (![enabled boolValue]) { 11 | return 0; 12 | } 13 | } else { 14 | [[[NSUserDefaults alloc] _initWithSuiteName:bundleID container:containerURL] removeObjectForKey:@"enabled"]; 15 | } 16 | } 17 | execvp("setgenerator", (char *[]){"setgenerator", NULL}); 18 | perror("setgenerator"); 19 | return -1; 20 | } 21 | -------------------------------------------------------------------------------- /setgenerator.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "libdementia.h" 3 | 4 | #define bundleID @"com.michael.generator" 5 | #define containerURL [NSURL URLWithString:@"file:///private/var/mobile"] 6 | 7 | void usage() { 8 | printf("Usage:\tsetgenerator [generator]\n"); 9 | printf("\t-s\tShow current status.\n"); 10 | } 11 | 12 | bool vaildGenerator(const char *generator) { 13 | if (strlen(generator) != 18 || generator[0] != '0' || generator[1] != 'x') { 14 | return false; 15 | } 16 | for (int i = 2; i <= 17; i++) { 17 | if (!isxdigit(generator[i])) { 18 | return false; 19 | } 20 | } 21 | return true; 22 | } 23 | 24 | const char *getGenerator() { 25 | id generator = [[[NSUserDefaults alloc] _initWithSuiteName:bundleID container:containerURL] objectForKey:@"generator"]; 26 | if (generator != nil) { 27 | if ([generator isKindOfClass:[NSString class]]) { 28 | const char *value = [generator cStringUsingEncoding:NSUTF8StringEncoding]; 29 | if (vaildGenerator(value)) { 30 | return value; 31 | } 32 | } 33 | [[[NSUserDefaults alloc] _initWithSuiteName:bundleID container:containerURL] removeObjectForKey:@"generator"]; 34 | } 35 | return "0x1111111111111111"; 36 | } 37 | 38 | int main(int argc, char **argv) { 39 | if (getuid() && setuid(0)) { 40 | printf("Can't set uid as 0.\n"); 41 | return 2; 42 | } 43 | 44 | if (argc > 2) { 45 | usage(); 46 | return 3; 47 | } 48 | 49 | if (argc == 2) { 50 | if (strcmp(argv[1], "-s") == 0) { 51 | uint8_t nonce_d[CC_SHA384_DIGEST_LENGTH]; 52 | size_t i, nonce_d_sz; 53 | uint64_t nonce; 54 | if (dimentio_preinit(&nonce, false, nonce_d, &nonce_d_sz) == KERN_SUCCESS || (dimentio_init(0, NULL, NULL) == KERN_SUCCESS && dimentio(&nonce, false, nonce_d, &nonce_d_sz) == KERN_SUCCESS)) { 55 | printf("The currently generator is 0x%016" PRIX64 ".\n", nonce); 56 | if(nonce_d_sz != 0) { 57 | printf("nonce_d: "); 58 | for(i = 0; i < nonce_d_sz; ++i) { 59 | printf("%02" PRIX8, nonce_d[i]); 60 | } 61 | putchar('\n'); 62 | } 63 | dimentio_term(); 64 | } 65 | id enabled = [[[NSUserDefaults alloc] _initWithSuiteName:bundleID container:containerURL] objectForKey:@"enabled"]; 66 | if (enabled != nil) { 67 | if ([enabled isKindOfClass:[NSNumber class]]) { 68 | if (![enabled boolValue]) { 69 | printf("The program will NOT run automatically during the next jailbreak.\n"); 70 | goto next; 71 | } 72 | } else { 73 | [[[NSUserDefaults alloc] _initWithSuiteName:bundleID container:containerURL] removeObjectForKey:@"enabled"]; 74 | } 75 | } 76 | printf("The program will run automatically during the next jailbreak.\n"); 77 | next: 78 | printf("When next time the program is running, the generator will be set to %s.\n", getGenerator()); 79 | return 0; 80 | } else if (!vaildGenerator(argv[1])) { 81 | usage(); 82 | return 3; 83 | } else { 84 | [[[NSUserDefaults alloc] _initWithSuiteName:bundleID container:containerURL] setObject:[[NSString alloc] initWithUTF8String:argv[1]] forKey:@"generator"]; 85 | } 86 | } 87 | 88 | uint8_t nonce_d[CC_SHA384_DIGEST_LENGTH]; 89 | size_t i, nonce_d_sz; 90 | uint64_t nonce; 91 | sscanf(getGenerator(), "0x%016" PRIx64, &nonce); 92 | if (dimentio_preinit(&nonce, true, nonce_d, &nonce_d_sz) == KERN_SUCCESS || (dimentio_init(0, NULL, NULL) == KERN_SUCCESS && dimentio(&nonce, true, nonce_d, &nonce_d_sz) == KERN_SUCCESS)) { 93 | printf("Set generator to 0x%016" PRIX64 "\n", nonce); 94 | if(nonce_d_sz != 0) { 95 | printf("nonce_d: "); 96 | for(i = 0; i < nonce_d_sz; ++i) { 97 | printf("%02" PRIX8, nonce_d[i]); 98 | } 99 | putchar('\n'); 100 | } 101 | dimentio_term(); 102 | } 103 | return 0; 104 | } 105 | -------------------------------------------------------------------------------- /tfp0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | get-task-allow 6 | 7 | task_for_pid-allow 8 | 9 | platform-application 10 | 11 | com.apple.private.kernel.get-kext-info 12 | 13 | com.apple.private.security.no-container 14 | 15 | com.apple.security.iokit-user-client-class 16 | AppleMobileApNonceUserClient 17 | 18 | 19 | --------------------------------------------------------------------------------