whale icon indicating copy to clipboard operation
whale copied to clipboard

iOS - crash after hook

Open suale-dev opened this issue 4 years ago • 2 comments

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. Screen Shot 2019-07-18 at 10 14 01 PM

iOS 12 - iPhone 6 & iPhone 7.

suale-dev avatar Jul 18 '19 15:07 suale-dev

Whale的WInlineHook调用原过程基本会崩溃,老bug了,可能是恢复现场那段shellcode写的有问题,不会汇编也咱也没法修,我都是下源码加个Cyida Hook库替换着凑合用的(Android)

fettdrac avatar Aug 13 '19 02:08 fettdrac

等待大佬新内核突破写权限

liumengdeqq avatar Oct 16 '19 08:10 liumengdeqq