From 8409d378c8b5c4bac7e59354b22bd03583db2378 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 | 30 ++++++++++++++++++++++++++++ entitlements.xml | 59 ++++++++++++++++++++++++++------------------------------ genent.xml | 7 +++++++ makefile | 8 ++++---- postinst.mm | 21 ++++++++++++++++++++ 5 files changed, 89 insertions(+), 36 deletions(-) create mode 100644 genent.xml diff --git a/cydo.cpp b/cydo.cpp index 2b76ac4..810e6eb 100644 --- a/cydo.cpp +++ b/cydo.cpp @@ -37,6 +37,35 @@ struct timeval _ltv; bool _itv; +#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); +} + typedef Function LaunchDataIterator; void launch_data_dict_iterate(launch_data_t data, LaunchDataIterator code) { @@ -46,6 +75,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 d503c39..46c8e06 100644 --- a/makefile +++ b/makefile @@ -292,19 +292,19 @@ MobileCydia: $(object) entitlements.xml $(lapt) 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/stringWith.mm CyteKit/stringWith.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 3cd8cdf..1b24c6d 100644 --- a/postinst.mm +++ b/postinst.mm @@ -9,6 +9,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; @@ -181,6 +200,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