Skip to content

Commit

Permalink
feat: Rootless progress, not working
Browse files Browse the repository at this point in the history
  • Loading branch information
hrtowii committed Jul 27, 2024
1 parent b040975 commit 5da9a05
Show file tree
Hide file tree
Showing 21 changed files with 1,197 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ ChOma_host
*.dylib
RootHelperSample/launchdshim/launchdhook/jitter/jitter
Bootstrap/jb
.stamp
Binary file modified Bootstrap/jb.zip
Binary file not shown.
30 changes: 21 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ all: Serotonin.tipa
shims:
echo "[*] Building cfprefsdshim"
$(MAKE) -C $(CFPREFSD_SHIM)
$(LDID) -S$(CFPREFSD_SHIM)ent.plist $(CFPREFSD_SHIM).theos/obj/debug/cfprefsdshim
$(CTBYPASS) -i $(CFPREFSD_SHIM).theos/obj/debug/cfprefsdshim -r -o $(CFPREFSD_SHIM)cfprefsdshimsignedinjected
$(LDID) -S$(CFPREFSD_SHIM)ent.plist $(CFPREFSD_SHIM).theos/obj/cfprefsdshim
$(CTBYPASS) -i $(CFPREFSD_SHIM).theos/obj/cfprefsdshim -r -o $(CFPREFSD_SHIM)cfprefsdshimsignedinjected

makebootstrap:
echo "[*] Making libiosexechook / libts2jailbreakenv"
$(MAKE) -C RootHelperSample/launchdshim/libiosexechook
# $(LDID) -SRootHelperSample/launchdshim/launchdentitlements.plist RootHelperSample/launchdshim/libiosexechook/.theos/obj/libiosexechook.dylib
$(CTBYPASS) -i RootHelperSample/launchdshim/libiosexechook/.theos/obj/libiosexechook.dylib -r -o Bootstrap/jb/usr/lib/libTS2JailbreakEnv.dylib
zip -vr9 -q Bootstrap/jb.zip Bootstrap/jb -x "*.DS_Store"

Serotonin.tipa: $(wildcard **/*.c **/*.m **/*.swift **/*.plist **/*.xml)
echo "[*] Building ChOma for host"
Expand All @@ -30,24 +37,28 @@ Serotonin.tipa: $(wildcard **/*.c **/*.m **/*.swift **/*.plist **/*.xml)
$(MAKE) -C RootHelperSample/launchdshim/launchdhook

echo "[*] Signing launchd hook"
$(CTBYPASS) -i RootHelperSample/launchdshim/launchdhook/.theos/obj/debug/launchdhook.dylib -r -o RootHelperSample/launchdshim/launchdhook/launchdhooksigned.dylib
$(CTBYPASS) -i RootHelperSample/launchdshim/launchdhook/.theos/obj/launchdhook.dylib -r -o RootHelperSample/launchdshim/launchdhook/launchdhooksigned.dylib

echo "[*] Building general hook"
$(MAKE) -C RootHelperSample/launchdshim/generalhook

echo "[*] Signing general hook"
$(CTBYPASS) -i RootHelperSample/launchdshim/generalhook/.theos/obj/debug/generalhook.dylib -r -o RootHelperSample/launchdshim/generalhook/generalhook.dylib
$(CTBYPASS) -i RootHelperSample/launchdshim/generalhook/.theos/obj/generalhook.dylib -r -o RootHelperSample/launchdshim/generalhook/generalhook.dylib

echo "[*] Building xpcproxyhook"
$(MAKE) -C RootHelperSample/launchdshim/xpcproxyhook

echo "[*] Signing xpcproxyhook"
$(LDID) -SRootHelperSample/launchdshim/xpcproxyhook/.theos/obj/debug/xpcproxyhook.dylib
$(CTBYPASS) -i RootHelperSample/launchdshim/xpcproxyhook/.theos/obj/debug/xpcproxyhook.dylib -r -o RootHelperSample/launchdshim/xpcproxyhook/xpcproxyhook.dylib
$(LDID) -SRootHelperSample/launchdshim/xpcproxyhook/.theos/obj/xpcproxyhook.dylib
$(CTBYPASS) -i RootHelperSample/launchdshim/xpcproxyhook/.theos/obj/xpcproxyhook.dylib -r -o RootHelperSample/launchdshim/xpcproxyhook/xpcproxyhook.dylib

echo "[*] Building jitter"
$(MAKE) -C RootHelperSample/launchdshim/launchdhook/jitter
$(CTBYPASS) -i RootHelperSample/launchdshim/launchdhook/jitter/.theos/obj/debug/jitter -r -o RootHelperSample/launchdshim/launchdhook/jitter/jitter
$(CTBYPASS) -i RootHelperSample/launchdshim/launchdhook/jitter/.theos/obj/jitter -r -o RootHelperSample/launchdshim/launchdhook/jitter/jitter

echo "[*] Building rootlesshooks"
$(MAKE) -C RootHelperSample/launchdshim/rootlesshooks/
$(CTBYPASS) -i RootHelperSample/launchdshim/rootlesshooks/.theos/obj/rootlesshooks.dylib -r -o RootHelperSample/launchdshim/rootlesshooks/rootlesshooks.dylib

# jank workaround at best, can someone else please fix this weird file dependency? – bomberfish
echo "[*] Copying fastPathSign"
Expand All @@ -63,11 +74,12 @@ Serotonin.tipa: $(wildcard **/*.c **/*.m **/*.swift **/*.plist **/*.xml)
mkdir Payload
cp -a build/Build/Products/Release-iphoneos/Serotonin.app Payload
rm -rf Payload/Serotonin.app/Frameworks
cp RootHelperSample/.theos/obj/debug/arm64/serotoninroothelper Payload/Serotonin.app/serotoninroothelper
cp RootHelperSample/.theos/obj/serotoninroothelper Payload/Serotonin.app/serotoninroothelper
install -m755 RootHelperSample/launchdshim/launchdhook/launchdhooksigned.dylib Payload/Serotonin.app/launchdhooksigned.dylib
install -m755 RootHelperSample/launchdshim/generalhook/generalhook.dylib Payload/Serotonin.app/generalhooksigned.dylib
install -m755 RootHelperSample/launchdshim/xpcproxyhook/xpcproxyhook.dylib Payload/Serotonin.app/xpcproxyhooksigned.dylib
install -m755 RootHelperSample/launchdshim/launchdhook/jitter/jitter Payload/Serotonin.app/jitterd
install -m755 RootHelperSample/launchdshim/rootlesshooks/rootlesshooks.dylib Payload/Serotonin.app/rootlesshooks.dylib
cp usprebooter/unzip Payload/Serotonin.app/unzip
cp Bootstrap/jb.zip Payload/Serotonin.app/jb.zip
$(LDID) -S./RootHelperSample/entitlements.plist -Cadhoc Payload/Serotonin.app/{fastPathSign,ldid,serotoninroothelper}
Expand Down Expand Up @@ -105,6 +117,6 @@ apple-include:
gsed -i -E s/'__API_UNAVAILABLE\(.*\)'// apple-include/IOKit/IOKitLib.h

clean:
rm -rf Payload build RootHelperSample/.theos RootHelperSample/launchdshim/cfprefsdshim/.theos RootHelperSample/launchdshim/generalhook/.theos RootHelperSample/launchdshim/launchdhook/.theos RootHelperSample/launchdshim/xpcproxyhook/.theos RootHelperSample/build apple-include FUCK.tipa Serotonin.tipa
rm -rf Payload build RootHelperSample/.theos RootHelperSample/launchdshim/cfprefsdshim/.theos RootHelperSample/launchdshim/generalhook/.theos RootHelperSample/launchdshim/launchdhook/.theos RootHelperSample/launchdshim/launchdhook/jitter/.theos RootHelperSample/launchdshim/xpcproxyhook/.theos RootHelperSample/build apple-include FUCK.tipa Serotonin.tipa

.PHONY: all clean Serotonin.tipa
2 changes: 1 addition & 1 deletion RootHelperSample/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TARGET := iphone:clang:16.5:14.0
ARCHS = arm64

FINALPACKAGE = 1
include $(THEOS)/makefiles/common.mk

TOOL_NAME = serotoninroothelper
Expand Down
4 changes: 2 additions & 2 deletions RootHelperSample/launchdshim/cfprefsdshim/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TARGET := iphone:clang:latest
ARCHS = arm64

FINALPACKAGE = 1
include $(THEOS)/makefiles/common.mk

TOOL_NAME = cfprefsdshim
Expand All @@ -12,6 +12,6 @@ $(TOOL_NAME)_CODESIGN_FLAGS = -Sent.plist
# EDIT substrate.h similarly to libhooker's tbd in vendor/lib!!! to /var/jb/usr/lib/libhooker.dylib
# old: //install-name: /Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate

after-package:: ct_bypass -i .theos/obj/debug/cfprefsdshim -o cfprefsd
after-package:: ct_bypass -i .theos/obj/cfprefsdshim -o cfprefsd

include $(THEOS_MAKE_PATH)/tool.mk
Binary file not shown.
3 changes: 2 additions & 1 deletion RootHelperSample/launchdshim/generalhook/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
TARGET := iphone:clang:latest:15.0
ARCHS = arm64
THEOS_PACKAGE_SCHEME = rootless
FINALPACKAGE = 1
include $(THEOS)/makefiles/common.mk

LIBRARY_NAME = generalhook
Expand All @@ -12,5 +13,5 @@ $(LIBRARY_NAME)_LDFLAGS = -L./ -lbsm
#launchdhook_EXTRA_FRAMEWORKS += IOMobileFramebuffer IOSurface
after-package::
echo "[*] Signing general hook"
ct_bypass -i .theos/obj/debug/generalhook.dylib -o generalhooksigned.dylib
ct_bypass -i .theos/obj/generalhook.dylib -o generalhooksigned.dylib
include $(THEOS_MAKE_PATH)/library.mk
15 changes: 15 additions & 0 deletions RootHelperSample/launchdshim/generalhook/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ - (BOOL)isLoaded {

@end

static char gExecutablePath[PATH_MAX];
static int load_executable_path(void)
{
char executablePath[PATH_MAX];
uint32_t bufsize = PATH_MAX;
if (_NSGetExecutablePath(executablePath, &bufsize) == 0) {
if (realpath(executablePath, gExecutablePath) != NULL) return 0;
}
return -1;
}

static void overwriteMainCFBundle() {
// Overwrite CFBundleGetMainBundle
uint32_t *pc = (uint32_t *)CFBundleGetMainBundle;
Expand Down Expand Up @@ -212,6 +223,10 @@ void applySandboxExtensions(void)
NSLog(@"generalhook - loading tweaks for pid %d", getpid());
const char* oldJBROOT = getenv("JBROOT");
setenv("JBROOT", jbroot("/"), 1);
if (!strcmp(gExecutablePath, "/System/Library/CoreServices/SpringBoard.app/SpringBoard") ||
!strcmp(gExecutablePath, "/usr/libexec/lsd")) {
dlopen(jbroot("/rootlesshooks.dylib"), RTLD_NOW);
}
dlopen(jbroot("/usr/lib/TweakLoader.dylib"), RTLD_NOW);
if(oldJBROOT) setenv("JBROOT", oldJBROOT, 1); else unsetenv("JBROOT");
}
14 changes: 7 additions & 7 deletions RootHelperSample/launchdshim/launchdhook/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
TARGET := iphone:clang:latest:15.0
FINALPACKAGE = 1
ARCHS = arm64
THEOS_PACKAGE_SCHEME = rootless
include $(THEOS)/makefiles/common.mk

LIBRARY_NAME = launchdhook
FINALPACKAGE=1
launchdhook_FILES = $(wildcard *.m) $(wildcard *.c) $(wildcard verbose/*.m) $(wildcard jbserver/*.c) $(wildcard jbserver/*.m) $(wildcard fun/*.m) $(wildcard fun/kpf/*.c) $(wildcard fun/kpf/*.m) ../../jbroot.m
launchdhook_CFLAGS = -fobjc-arc -isystem "../../../usprebooter/Private Headers I stole from the macOS SDK" -Wno-error -O3
launchdhook_CODESIGN_FLAGS = -S../launchdentitlements.plist
launchdhook_LDFLAGS = -F./Frameworks -L./ -lbsm -lhooker -framework IOKit
launchdhook_EXTRA_FRAMEWORKS += IOMobileFramebuffer IOSurface
$(LIBRARY_NAME)_FILES = $(wildcard *.m) $(wildcard *.c) $(wildcard verbose/*.m) $(wildcard jbserver/*.c) $(wildcard jbserver/*.m) $(wildcard fun/*.m) $(wildcard fun/kpf/*.c) $(wildcard fun/kpf/*.m) ../../jbroot.m
$(LIBRARY_NAME)_CFLAGS = -fobjc-arc -isystem "../../../usprebooter/Private Headers I stole from the macOS SDK" -Wno-error -O3
$(LIBRARY_NAME)_CODESIGN_FLAGS = -S../launchdentitlements.plist
$(LIBRARY_NAME)_LDFLAGS = -F./Frameworks -L./ -lbsm -lhooker -framework IOKit
$(LIBRARY_NAME)_EXTRA_FRAMEWORKS += IOMobileFramebuffer IOSurface
after-package::
echo "[*] Signing launchd hook"
ct_bypass -i .theos/obj/debug/launchdhook.dylib -o launchdhooksigned.dylib
ct_bypass -i .theos/obj/launchdhook.dylib -o launchdhooksigned.dylib
include $(THEOS_MAKE_PATH)/library.mk
4 changes: 2 additions & 2 deletions RootHelperSample/launchdshim/launchdhook/jitter/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TARGET := iphone:clang:latest
ARCHS = arm64

FINALPACKAGE = 1
include $(THEOS)/makefiles/common.mk

TOOL_NAME = jitter
Expand All @@ -10,6 +10,6 @@ jitter_CFLAGS = -fobjc-arc -isystem -Wno-error -O3
jitter_LDFLAGS = -L./ -lbsm
jitter_CODESIGN_FLAGS = -Sent.plist

after-package:: ct_bypass -i .theos/obj/debug/jitter -o jitter
after-package:: ct_bypass -i .theos/obj/jitter -o jitter

include $(THEOS_MAKE_PATH)/tool.mk
11 changes: 9 additions & 2 deletions RootHelperSample/launchdshim/launchdhook/jitter/jitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#include "../fun/memoryControl.h"
#include "../jbserver/bsm/audit.h"
#include "../jbserver/xpc_private.h"

#include <spawn.h>
#define PT_DETACH 11 /* stop tracing a process */
#define PT_ATTACHEXC 14 /* attach to running process with signal exception */
#define MEMORYSTATUS_CMD_SET_JETSAM_HIGH_WATER_MARK 5
#define JBD_MSG_PROC_SET_DEBUGGED 23

bool shouldUiCache = false;
int ptrace(int request, pid_t pid, caddr_t addr, int data);
// void JBLogError(const char *format, ...);
// void JBLogDebug(const char *format, ...);
Expand Down Expand Up @@ -124,6 +124,13 @@ int main(int argc, char* argv[])
dispatch_resume(sourceSystemWide);

dispatch_main();
if (shouldUiCache == false) {
pid_t pid;
extern char **environ;
char *argv[] = {"/var/jb/usr/bin/uicache", "-a", NULL};
posix_spawn(&pid, argv[0], NULL, NULL, argv, environ);
shouldUiCache = true;
}
return 0;
}
}
16 changes: 16 additions & 0 deletions RootHelperSample/launchdshim/libiosexechook/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
TARGET := iphone:clang:latest:15.0
FINALPACKAGE = 1
ARCHS = arm64
THEOS_PACKAGE_SCHEME = rootless
include $(THEOS)/makefiles/common.mk

LIBRARY_NAME = libiosexechook
$(LIBRARY_NAME)_FILES = $(wildcard *.m) $(wildcard *.c)
$(LIBRARY_NAME)_CFLAGS = -fobjc-arc -isystem "../../../usprebooter/Private Headers I stole from the macOS SDK" -Wno-error -Wno-int-conversion -Wno-incompatible-function-pointer-types -O3
$(LIBRARY_NAME)_LDFLAGS = -F./Frameworks -L./ -lbsm -lhooker
after-package::
echo "[*] Signing libiosexechook"
ct_bypass -i .theos/obj/libiosexechook.dylib -r -o libiosexechook.dylib
include $(THEOS_MAKE_PATH)/library.mk
# Bootstrap/jb/usr/lib/libTS2JailbreakEnv.dylib
# Use the built dylib here and put it as libts2jailbreakenv.dylib in bootstrap/jb/usr/lib/libTS2JailbreakEnv.dylib
Loading

0 comments on commit 5da9a05

Please sign in to comment.