whale
whale copied to clipboard
iOS - crash after hook
I built the lib for ios in debug mode. And build a demo iOS app with objective-c Below is my function to test hook:
char *(*Origin_getenv)(const char *); char *Hooked_getenv(const char *name) { if (!strcmp(name, "lody")) { return strdup("are you ok?"); } char *(*O)(const char *) = Origin_getenv; return O(name); }
int testHook() { void *handle = dlopen("libc.dylib", RTLD_NOW); assert(handle != nullptr); void *symbol = dlsym(handle, "getenv"); assert(symbol != nullptr); WInlineHookFunction( symbol, reinterpret_cast<void *>(Hooked_getenv), reinterpret_cast<void **>(&Origin_getenv) ); const char *val = getenv("lody"); if (val != nullptr) { std::cout << val; } return 0; }
After call testHook function, hooked function work, but the app is crashed later.
iOS 12 - iPhone 6 & iPhone 7.
Whale的WInlineHook调用原过程基本会崩溃,老bug了,可能是恢复现场那段shellcode写的有问题,不会汇编也咱也没法修,我都是下源码加个Cyida Hook库替换着凑合用的(Android)
等待大佬新内核突破写权限