Skip to content

Instantly share code, notes, and snippets.

@m1guelpf
Created March 26, 2025 00:13
Show Gist options
  • Save m1guelpf/f119fb32ec0d6853c46a043db8c43614 to your computer and use it in GitHub Desktop.
Save m1guelpf/f119fb32ec0d6853c46a043db8c43614 to your computer and use it in GitHub Desktop.
Disallow debugging an iOS app on production
#if !DEBUG && (defined(__arm64__) || defined(__aarch64__))
void __attribute__((constructor)) security_setup(void) {
long PTRACE_SYSCALL = 26;
long PT_DENY_ATTACH = 31;
asm volatile(
"mov x0, %1\n"
"mov x1, #0\n"
"mov x2, #0\n"
"mov x3, #0\n"
"mov x16, %0\n"
"svc #0x80\n"
:
: "r" (PTRACE_SYSCALL), "r" (PT_DENY_ATTACH)
: "x0", "x1", "x2", "x3", "x16"
);
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment