简体   繁体   中英

Disabling debug sessions on iOS - is that useful?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM