From bea5ee0aadb0ac95f71eb858fdb7f02e748f50d7 Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Wed, 11 Jul 2018 23:40:04 -1000 Subject: Minimal changes to support iOS11 --- cydo.cpp | 36 ++++++++++++++++++++++++++++++++++ entitlements.xml | 59 ++++++++++++++++++++++++++------------------------------ genent.xml | 7 +++++++ makefile | 8 ++++---- postinst.mm | 21 ++++++++++++++++++++ 5 files changed, 95 insertions(+), 36 deletions(-) create mode 100644 genent.xml diff --git a/cydo.cpp b/cydo.cpp index d6e6f75..71009cd 100644 --- a/cydo.cpp +++ b/cydo.cpp @@ -32,6 +32,41 @@ #include +#include +/* Set platform binary flag */ +#define FLAG_PLATFORMIZE (1 << 1) + +void patch_setuidandplatformize() { + void* handle = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY); + if (!handle) return; + + // Reset errors + dlerror(); + + typedef void (*fix_setuid_prt_t)(pid_t pid); + fix_setuid_prt_t setuidptr = (fix_setuid_prt_t)dlsym(handle, "jb_oneshot_fix_setuid_now"); + + typedef void (*fix_entitle_prt_t)(pid_t pid, uint32_t what); + fix_entitle_prt_t entitleptr = (fix_entitle_prt_t)dlsym(handle, "jb_oneshot_entitle_now"); + + setuidptr(getpid()); + + setuid(0); + + const char *dlsym_error = dlerror(); + if (dlsym_error) { + return; + } + + entitleptr(getpid(), FLAG_PLATFORMIZE); +} +#define _assert(test) do \ + if (!(test)) { \ + fprintf(stderr, "_assert(%d:%s)@%s:%u[%s]\n", errno, #test, __FILE__, __LINE__, __FUNCTION__); \ + exit(-1); \ + } \ +while (false) + typedef Function LaunchDataIterator; void launch_data_dict_iterate(launch_data_t data, LaunchDataIterator code) { @@ -41,6 +76,7 @@ void launch_data_dict_iterate(launch_data_t data, LaunchDataIterator code) { } int main(int argc, char *argv[]) { + patch_setuidandplatformize(); auto request(launch_data_new_string(LAUNCH_KEY_GETJOBS)); auto response(launch_msg(request)); launch_data_free(request); diff --git a/entitlements.xml b/entitlements.xml index fbcca6a..2beffeb 100644 --- a/entitlements.xml +++ b/entitlements.xml @@ -1,37 +1,32 @@ + - com.apple.coreaudio.allow-amr-decode - - - com.apple.coremedia.allow-protected-content-playback - - - com.apple.managedconfiguration.profiled-access - - - com.apple.springboard.opensensitiveurl - - - dynamic-codesigning - - - com.apple.springboard.launchapplications - - - keychain-access-groups - - com.apple.cfnetwork - com.apple.identities - com.apple.mobilesafari - - - platform-application - - - com.apple.CommCenter.fine-grained - - spi - + com.apple.CommCenter.fine-grained + + spi + + com.apple.coreaudio.allow-amr-decode + + com.apple.coremedia.allow-protected-content-playback + + com.apple.managedconfiguration.profiled-access + + com.apple.private.security.no-container + + com.apple.private.skip-library-validation + + com.apple.springboard.launchapplications + + com.apple.springboard.opensensitiveurl + + keychain-access-groups + + com.apple.cfnetwork + com.apple.identities + com.apple.mobilesafari + + platform-application + diff --git a/genent.xml b/genent.xml new file mode 100644 index 0000000..d833045 --- /dev/null +++ b/genent.xml @@ -0,0 +1,7 @@ + + + + platform-application + + + diff --git a/makefile b/makefile index 55af0be..b8c9793 100644 --- a/makefile +++ b/makefile @@ -188,19 +188,19 @@ MobileCydia: sysroot $(object) entitlements.xml Objects/libapt64.a cfversion: cfversion.mm $(cycc) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation - @ldid -T0 -S $@ + @ldid -T0 -Sgenent.xml $@ setnsfpn: setnsfpn.cpp $(cycc) -o $@ $(filter %.cpp,$^) $(flag) $(link) - @ldid -T0 -S $@ + @ldid -T0 -Sgenent.xml $@ cydo: cydo.cpp $(cycc) $(plus) -o $@ $(filter %.cpp,$^) $(flag) $(link) -Wno-deprecated-writable-strings - @ldid -T0 -S $@ + @ldid -T0 -Sgenent.xml $@ postinst: postinst.mm CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h $(cycc) $(plus) -o $@ $(filter %.mm,$^) $(flag) $(link) -framework CoreFoundation -framework Foundation -framework UIKit - @ldid -T0 -S $@ + @ldid -T0 -Sgenent.xml $@ debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst cfversion setnsfpn cydo $(images) $(shell find MobileCydia.app) cydia.control Library/firmware.sh Library/move.sh Library/startup sudo rm -rf _ diff --git a/postinst.mm b/postinst.mm index f826f4f..80eaedc 100644 --- a/postinst.mm +++ b/postinst.mm @@ -11,6 +11,25 @@ #include +/* Set platform binary flag */ +#include +#define FLAG_PLATFORMIZE (1 << 1) + +void platformize_me() { + void* handle = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY); + if (!handle) return; + + // Reset errors + dlerror(); + typedef void (*fix_entitle_prt_t)(pid_t pid, uint32_t what); + fix_entitle_prt_t ptr = (fix_entitle_prt_t)dlsym(handle, "jb_oneshot_entitle_now"); + + const char *dlsym_error = dlerror(); + if (dlsym_error) return; + + ptr(getpid(), FLAG_PLATFORMIZE); +} + void Finish(const char *finish) { if (finish == NULL) return; @@ -183,6 +202,8 @@ int main(int argc, const char *argv[]) { if (argc < 2 || strcmp(argv[1], "configure") != 0) return 0; + platformize_me(); + NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); bool restart(false); -- cgit v1.2.3