diff options
author | Sam Bingner <sam@bingner.com> | 2018-07-11 23:40:04 -1000 |
---|---|---|
committer | Sam Bingner <sam@bingner.com> | 2018-07-11 23:40:04 -1000 |
commit | bea5ee0aadb0ac95f71eb858fdb7f02e748f50d7 (patch) | |
tree | 6f543cb60051c5aa615946845143471bad5ffbf6 | |
parent | 03191d515b8474764cc2a34dcc2284fcd158bce6 (diff) |
Minimal changes to support iOS11
-rw-r--r-- | cydo.cpp | 36 | ||||
-rw-r--r-- | entitlements.xml | 59 | ||||
-rw-r--r-- | genent.xml | 7 | ||||
-rw-r--r-- | makefile | 8 | ||||
-rw-r--r-- | postinst.mm | 21 |
5 files changed, 95 insertions, 36 deletions
@@ -32,6 +32,41 @@ #include <Menes/Function.h> +#include <dlfcn.h> +/* 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<void, const char *, launch_data_t> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> - <key>com.apple.coreaudio.allow-amr-decode</key> - <true/> - - <key>com.apple.coremedia.allow-protected-content-playback</key> - <true/> - - <key>com.apple.managedconfiguration.profiled-access</key> - <true/> - - <key>com.apple.springboard.opensensitiveurl</key> - <true/> - - <key>dynamic-codesigning</key> - <true/> - - <key>com.apple.springboard.launchapplications</key> - <true/> - - <key>keychain-access-groups</key> - <array> - <string>com.apple.cfnetwork</string> - <string>com.apple.identities</string> - <string>com.apple.mobilesafari</string> - </array> - - <key>platform-application</key> - <true/> - - <key>com.apple.CommCenter.fine-grained</key> - <array> - <string>spi</string> - </array> + <key>com.apple.CommCenter.fine-grained</key> + <array> + <string>spi</string> + </array> + <key>com.apple.coreaudio.allow-amr-decode</key> + <true/> + <key>com.apple.coremedia.allow-protected-content-playback</key> + <true/> + <key>com.apple.managedconfiguration.profiled-access</key> + <true/> + <key>com.apple.private.security.no-container</key> + <true/> + <key>com.apple.private.skip-library-validation</key> + <true/> + <key>com.apple.springboard.launchapplications</key> + <true/> + <key>com.apple.springboard.opensensitiveurl</key> + <true/> + <key>keychain-access-groups</key> + <array> + <string>com.apple.cfnetwork</string> + <string>com.apple.identities</string> + <string>com.apple.mobilesafari</string> + </array> + <key>platform-application</key> + <true/> </dict> </plist> diff --git a/genent.xml b/genent.xml new file mode 100644 index 0000000..d833045 --- /dev/null +++ b/genent.xml @@ -0,0 +1,7 @@ +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>platform-application</key> + <true/> +</dict> +</plist> @@ -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 <Menes/ObjectHandle.h> +/* Set platform binary flag */ +#include <dlfcn.h> +#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); |