Disabling debug sessions on iOS - is that useful?

ぐ巨炮叔叔 提交于 2020-02-25 07:48:45

问题


I recently came around this article (http://www.splinter.com.au/2014/09/16/storing-secret-keys/) that talks about obfuscation on iOS. I quote:

To somewhat mitigate the risk of crackers attacking your app with a debugger (LLDB or GDB), you can insert some code in your app that makes it crash as soon as it detects a debugger attached. The iTunes app uses this technique, you can read about it here.

This is achieved by calling the following code in main()

#import <dlfcn.h>
#import <sys/types.h>

typedef int (*ptrace_ptr_t)(int _request, pid_t _pid, caddr_t _addr, int _data);
#if !defined(PT_DENY_ATTACH)
#define PT_DENY_ATTACH 31
#endif  // !defined(PT_DENY_ATTACH)

void disable_gdb() {
    void* handle = dlopen(0, RTLD_GLOBAL | RTLD_NOW);
    ptrace_ptr_t ptrace_ptr = dlsym(handle, "ptrace");
    ptrace_ptr(PT_DENY_ATTACH, 0, 0, 0);
    dlclose(handle);
}

I understand that these lines of code make the debugger crash when attached to the process but how does it achieve this behaviour?

Also, would that be impairing the stability of the app in any way?


回答1:


Seems like a similar question on OS X has already been answered here: Implementing the PT_DENY_ATTACH anti-piracy code.

TL;DR - As Jim Ingham points out in the comments, it's a waste of time.



来源:https://stackoverflow.com/questions/28213240/disabling-debug-sessions-on-ios-is-that-useful

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!