Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to prevent dynamic debugging of iOS

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to prevent dynamic debugging iOS, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!

Prevent GDB and lldb from condescending. Keyword ptrace

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

Sysctl checks whether it is debugged or not

Int isDebuggerPerforming () {struct kinfo_proc infos_process; size_t size_info_proc = sizeof (infos_process); pid_t pid_process = getpid (); / / pid of the current process / / int mib [] = {CTL_KERN, / / Kernel infos KERN_PROC, / / Search in process table KERN_PROC_PID, / / the process with pid = pid_process} / / pid_process / Retrieve infos for current process in infos_process int ret = sysctl (mib, 4, & infos_process, & size_info_proc, NULL, 0); if (ret) return 0; / / sysctl failed / / struct extern_proc process = infos_process.kp_proc; int flags_process = process.p_flag; return (flags_process & P_TRACED)! = 0 / / value of the debug flag}

Compile with xcode and add this field to Other Linker Flags.

-Wl,-sectcreate,__RESTRICT,__restrict,/dev/null above is all the contents of the article "how to prevent dynamic debugging in iOS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report