iOS programs prevent dynamic debugging and code injection

Source: Internet
Author: User

http://ruixiazun.blog.163.com/blog/static/9068791820141173588694/

iphone real run environment is not sys/ptrace.h thrown. The Ptrace method is not thrown and can be obtained by Dlopen.
Dlopen: When the PATH parameter is 0, he will automatically find $LD _library_path, $DYLD _library_path, $DYLD _fallback_library_path and the dynamic link library in the current working directory.

#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);
}

int main (int argc, Charchar *argv[])
{
#ifndef DEBUG
Disable_gdb ();
#endif
@autoreleasepool {
Return Uiapplicationmain (argc, argv, Nil, Nsstringfromclass ([Wqmainpageappdelegate class]));
}
}

iOS programs prevent dynamic debugging and code injection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.