From 0fdf39fe22f2cc0de19f2012bb47925c3df80ddd Mon Sep 17 00:00:00 2001 From: Mineek Date: Mon, 8 Jan 2024 15:41:39 +0100 Subject: [PATCH] fix ios 16.1.2-, amongst other things. --- .github/workflows/build.yml | 36 ++++++++++++++++++ .../SpringBoardShim/SpringBoardHook/Tweak.x | 3 +- .../springboardhooksigned.dylib | Bin 113309 -> 112637 bytes usprebooter/fun/offsets.h | 5 +++ usprebooter/fun/offsets.m | 12 +++++- usprebooter/fun/vnode.h | 1 + usprebooter/fun/vnode.m | 34 ++++++++++++++++- usprebooter/overwriter.m | 11 +++++- 8 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..90cba85 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: Build Serotonin + +on: + push: + branches: [ main ] + workflow_dispatch: + +jobs: + build: + runs-on: macos-13 + + steps: + - uses: actions/checkout@v3 + + - name: Switch to Xcode 15 + run: sudo xcode-select -s /Applications/Xcode_15.0.app + + - name: Install theos + run: bash -c "$(curl -fsSL https://raw.githubusercontent.com/roothide/theos/master/bin/install-theos)" + + - name: Download ct_bypass to /usr/local/bin + run: | + curl -L -o /usr/local/bin/ct_bypass https://cdn.mineek.dev/serotonin/action_deps/ct_bypass + chmod +x /usr/local/bin/ct_bypass + + - name: Install ldid + run: brew install ldid-procursus + + - name: Compile IPA + run: make + + - name: Upload IPA + uses: actions/upload-artifact@v2 + with: + name: Serotonin.tipa + path: Serotonin.tipa diff --git a/RootHelperSample/launchdshim/SpringBoardShim/SpringBoardHook/Tweak.x b/RootHelperSample/launchdshim/SpringBoardShim/SpringBoardHook/Tweak.x index 19e9ee6..14b63bf 100644 --- a/RootHelperSample/launchdshim/SpringBoardShim/SpringBoardHook/Tweak.x +++ b/RootHelperSample/launchdshim/SpringBoardShim/SpringBoardHook/Tweak.x @@ -136,8 +136,8 @@ bool OpenedTweaks = false; bool os_variant_has_internal_content(const char* subsystem); %hookf(bool, os_variant_has_internal_content, const char* subsystem) { if (OpenedTweaks == false) { + spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"daemon",@"-f"], nil, nil); if (isarm64e()) { - spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"daemon",@"-f"], nil, nil); dlopen(jbroot(@"/basebin/bootstrap.dylib").UTF8String, RTLD_GLOBAL | RTLD_NOW); } else { NSLog(@"[mineek's supporttweak] loading actual tweaks"); @@ -164,7 +164,6 @@ bool os_variant_has_internal_content(const char* subsystem); } } } - spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"daemon",@"-f"], nil, nil); } OpenedTweaks = true; return true; diff --git a/RootHelperSample/launchdshim/SpringBoardShim/SpringBoardHook/springboardhooksigned.dylib b/RootHelperSample/launchdshim/SpringBoardShim/SpringBoardHook/springboardhooksigned.dylib index 3bdf556c21d42813f1957df4c45ffa8f510a687c..daecbcf920391b8b2f0462d4903cc6d258431386 100755 GIT binary patch delta 7040 zcmbtZ2~<pdt+)~&Rl^p)JwRGdk&}g z*B1y8rI4Wd03tZ7Z&`D1>9fp)WCJ~1jg01!AL8k@?-GqUW`61F&IRN4N-1}ZO*=8jd zuAHyf3_ae2IJGj2jP1@5~InGD`1=lx2HVWI|p*1S&Zut*H^Cc zRuhK2*xlSv!!TK&oSSNhj&n=qGOqTYFC|@>w?>XOwmLQa_f}=@e&EDxCFe4Xii?FDN~lbU8CRP#vcL5jI`@e)yx$1w zE7^>zRgTYnA`kB`=VnzD2u+*ExbnE&6(ev8cdjBhZagSS>wAhA*I1IPfRwbLzjrcn zwK^B}D`;C1IKN62R&xpP-o(wVObPS{b!ler&2pUioh$7aSu{K`OK zu1ASBtOGb3HnwFHclD}J_ipE+e(73KV(f7N5a~j#H}!=4pRECa#VZX0}#V~ zY92n+?n91%y-`g*Y_xAJ%qQBb>+)gMGVZ>4iGMOwK<0AC5OmH7c_L+;)sl-{++oXD zZzTkKG6X8c`>dW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>;M1XC zKukc^uLFB6Dp;`r@26Ojml>Cr55awFZ*@Z^v|en&HP|d6|gc zaOCnN(lNa}DaSM3npd~lg|6kz8PJdkFaU5I=Kr-p|c~yvId9bS5&yuK<%F& zdpH`f&pAkceB|pcd(m)OQP7J9kNS_HU+_qhp*((6Kmtqa)_Kzevu4G7tal^5#2zC6*!O=|j3 zuetHg){~8wN<+s#ewuqacxL2Vtt%g?7r*zw)jntGTjUq_sW+3ax31Zg{?o*ehPHm1 zH@wdEJdk(E=}6~aj*E}dPJ3g`!GzXRsYjQ)yNx(`C9Y4p@!x;iC!rS19ctIdta9AA5x^aqkZSk%z8|CbYw^G3V0MV)CnbGGuebIIWaVfQZG ze%}=Kk=I-HD+4DQzF1#5e@I>AZd%}_{YTr+!wXllIYyY|a>Cqkg>$ym(kSz;zkc%b zses6>-IvY$Xz#=QV+R#+wQJ6HExF~`W-jsYoIW9K>sKdy((ing_J!fU15%74}{Xu`{%hPWgyPWiG z3;yrOm;Wnw!#`IJt*tznarEO_t(&-W|NFOhmygQL~ z-Xpb!yP;_#clLeq+kt<5-ny>w-H+=_XZQrfPS5(_Sjl@kt1o<(Q&4J84yr#>d^h}2 VgvXTf-TeAgu6TZ3)G>OV|3B9$_x%6> diff --git a/usprebooter/fun/offsets.h b/usprebooter/fun/offsets.h index 354fb5c..23ebe14 100644 --- a/usprebooter/fun/offsets.h +++ b/usprebooter/fun/offsets.h @@ -48,6 +48,8 @@ extern uint32_t off_fp_glob; extern uint32_t off_fg_data; extern uint32_t off_fg_flag; extern uint32_t off_vnode_v_ncchildren_tqh_first; +extern uint32_t off_vnode_v_ncchildren_tqh_last; +extern uint32_t off_vnode_v_nclinks_lh_first; extern uint32_t off_vnode_v_iocount; extern uint32_t off_vnode_v_usecount; extern uint32_t off_vnode_v_flag; @@ -70,7 +72,10 @@ extern uint32_t off_mount_mnt_fsgroup; extern uint32_t off_mount_mnt_devvp; extern uint32_t off_mount_mnt_flag; extern uint32_t off_specinfo_si_flags; +extern uint32_t off_namecache_nc_dvp; extern uint32_t off_namecache_nc_vp; +extern uint32_t off_namecache_nc_hashval; +extern uint32_t off_namecache_nc_name; extern uint32_t off_namecache_nc_child_tqe_prev; extern uint32_t off_ipc_space_is_table; extern uint32_t off_ubc_info_cs_blobs; diff --git a/usprebooter/fun/offsets.m b/usprebooter/fun/offsets.m index e57948c..6e8f4c9 100644 --- a/usprebooter/fun/offsets.m +++ b/usprebooter/fun/offsets.m @@ -49,6 +49,8 @@ uint32_t off_fg_data = 0; uint32_t off_fg_flag = 0; uint32_t off_vnode_v_ncchildren_tqh_first = 0; +uint32_t off_vnode_v_ncchildren_tqh_last = 0; +uint32_t off_vnode_v_nclinks_lh_first = 0; uint32_t off_vnode_v_iocount = 0; uint32_t off_vnode_v_usecount = 0; uint32_t off_vnode_v_flag = 0; @@ -68,10 +70,14 @@ uint32_t off_mount_mnt_devvp = 0; uint32_t off_mount_mnt_flag = 0; uint32_t off_specinfo_si_flags = 0; +uint32_t off_namecache_nc_dvp = 0; uint32_t off_namecache_nc_vp = 0; +uint32_t off_namecache_nc_hashval = 0; +uint32_t off_namecache_nc_name = 0; uint32_t off_namecache_nc_child_tqe_prev = 0; #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) +#define SYSTEM_VERSION_LOWER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) void _offsets_init(void) { if(SYSTEM_VERSION_EQUAL_TO(@"16.1.2")||SYSTEM_VERSION_EQUAL_TO(@"16.2")||SYSTEM_VERSION_EQUAL_TO(@"16.3")||SYSTEM_VERSION_EQUAL_TO(@"16.3.1")) { @@ -136,6 +142,8 @@ void _offsets_init(void) { //https://github.com/apple-oss-distributions/xnu/blob/xnu-8792.41.9/bsd/sys/vnode_internal.h#L158 off_vnode_v_ncchildren_tqh_first = 0x30; + off_vnode_v_ncchildren_tqh_last = 0x38; + off_vnode_v_nclinks_lh_first = 0x40; off_vnode_v_iocount = 0x64; off_vnode_v_usecount = 0x60; off_vnode_v_flag = 0x54; @@ -161,7 +169,10 @@ void _offsets_init(void) { off_specinfo_si_flags = 0x10; //https://github.com/apple-oss-distributions/xnu/blob/xnu-8792.41.9/bsd/sys/namei.h#L243 + off_namecache_nc_dvp = 0x40; off_namecache_nc_vp = 0x48; + off_namecache_nc_hashval = 0x50; + off_namecache_nc_name = 0x58; off_namecache_nc_child_tqe_prev = 0x10; } else if (SYSTEM_VERSION_EQUAL_TO(@"16.7.2")||SYSTEM_VERSION_EQUAL_TO(@"16.7.1")||SYSTEM_VERSION_EQUAL_TO(@"16.7")||SYSTEM_VERSION_EQUAL_TO(@"16.6.1")||SYSTEM_VERSION_EQUAL_TO(@"16.6")||SYSTEM_VERSION_EQUAL_TO(@"16.4")||SYSTEM_VERSION_EQUAL_TO(@"16.4.1")||SYSTEM_VERSION_EQUAL_TO(@"16.5") || SYSTEM_VERSION_EQUAL_TO(@"16.5.1")) { @@ -253,7 +264,6 @@ void _offsets_init(void) { //https://github.com/apple-oss-distributions/xnu/blob/xnu-8792.41.9/bsd/sys/namei.h#L243 off_namecache_nc_vp = 0x48; off_namecache_nc_child_tqe_prev = 0x0; - }else { NSLog(@"[-] No matching offsets."); exit(EXIT_FAILURE); diff --git a/usprebooter/fun/vnode.h b/usprebooter/fun/vnode.h index b295680..a8f1daf 100644 --- a/usprebooter/fun/vnode.h +++ b/usprebooter/fun/vnode.h @@ -116,4 +116,5 @@ uint64_t funVnodeOverwriteFileUnlimitSize(char* to, char* from); void ChangeDirFor(int pid, const char *where); // change directory for something with chroot +uint64_t SwitchSysBin160(char* to, char* from, uint64_t* orig_to_vnode, uint64_t* orig_nc_vp); // overwrite v_name to swap files int SwitchSysBin(uint64_t vnode, char* what, char* with); // overwrite v_name to swap files diff --git a/usprebooter/fun/vnode.m b/usprebooter/fun/vnode.m index 6145fb6..fcf6b44 100644 --- a/usprebooter/fun/vnode.m +++ b/usprebooter/fun/vnode.m @@ -589,6 +589,38 @@ int SwitchSysBin(uint64_t vnode, char* what, char* with) } vp_namecache = kread64(vp_namecache + off_namecache_nc_child_tqe_prev); } - return 0; } + +uint64_t SwitchSysBin160(char* to, char* from, uint64_t* orig_to_vnode, uint64_t* orig_nc_vp) +{ + uint64_t to_vnode = getVnodeAtPath(to); + if(to_vnode == -1) { + NSString *to_dir = [[NSString stringWithUTF8String:to] stringByDeletingLastPathComponent]; + NSString *to_file = [[NSString stringWithUTF8String:to] lastPathComponent]; + uint64_t to_dir_vnode = getVnodeAtPathByChdir(to_dir.UTF8String); + to_vnode = findChildVnodeByVnode(to_dir_vnode, to_file.UTF8String); + if(to_vnode == 0) { + printf("[-] Couldn't find file (to): %s", to); + return -1; + } + } + + uint64_t from_vnode = getVnodeAtPath(from); + if(from_vnode == -1) { + NSString *from_dir = [[NSString stringWithUTF8String:from] stringByDeletingLastPathComponent]; + NSString *from_file = [[NSString stringWithUTF8String:from] lastPathComponent]; + uint64_t from_dir_vnode = getVnodeAtPathByChdir(from_dir.UTF8String); + from_vnode = findChildVnodeByVnode(from_dir_vnode, from_file.UTF8String); + if(from_vnode == 0) { + printf("[-] Couldn't find file (from): %s", from); + return -1; + } + } + + uint64_t to_vnode_nc = kread64(to_vnode + off_vnode_v_nclinks_lh_first); + *orig_nc_vp = kread64(to_vnode_nc + off_namecache_nc_vp); + *orig_to_vnode = to_vnode; + kwrite64(to_vnode_nc + off_namecache_nc_vp, from_vnode); + return 0; +} \ No newline at end of file diff --git a/usprebooter/overwriter.m b/usprebooter/overwriter.m index cf83daf..39f888d 100644 --- a/usprebooter/overwriter.m +++ b/usprebooter/overwriter.m @@ -2,6 +2,7 @@ @import Foundation; @import MachO; +#include #import #import "vm_unaligned_copy_switch_race.h" #import "overwriter.h" @@ -14,11 +15,19 @@ return jbroot(@"lunchd"); } +#define SYSTEM_VERSION_LOWER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) + bool overwrite_patchedlaunchd_kfd(void) { // ayo whats this – bomberfish // SwitchSysBin(getVnodeAtPathByChdir("/System/Library/CoreServices/SpringBoard.app"), "SpringBoard", "/var/jb/SprangBoard"); printf("[i] performing launchd hax\n"); - SwitchSysBin(getVnodeAtPathByChdir("/sbin"), "launchd", getLunchd().UTF8String); + if (SYSTEM_VERSION_LOWER_THAN(@"16.2")) { + uint64_t orig_nc_vp = 0; + uint64_t orig_to_vnode = 0; + SwitchSysBin160("/sbin/launchd", getLunchd().UTF8String, &orig_to_vnode, &orig_nc_vp); + } else { + SwitchSysBin(getVnodeAtPathByChdir("/sbin"), "launchd", getLunchd().UTF8String); + } printf("[i] launchd haxed\n"); return true; }