diff options
author | Sam Bingner <sam@bingner.com> | 2018-07-11 23:40:04 -1000 |
---|---|---|
committer | Sam Bingner <sam@bingner.com> | 2019-05-27 14:13:40 -1000 |
commit | 8409d378c8b5c4bac7e59354b22bd03583db2378 (patch) | |
tree | 39ad72f11f3928609f7c75b6359e35451d357299 /cydo.cpp | |
parent | 837b7c8801dabaec33c55494047540b6ac6ef22d (diff) |
Minimal changes to support iOS11
Diffstat (limited to 'cydo.cpp')
-rw-r--r-- | cydo.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -37,6 +37,35 @@ struct timeval _ltv; bool _itv; +#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); +} + typedef Function<void, const char *, launch_data_t> 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); |