Created
December 25, 2016 17:13
-
-
Save mattlawer/d391c5137f987d109c54b58a7ce36a04 to your computer and use it in GitHub Desktop.
Disable GDB with Swift 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func disable_gdb() { | |
let PT_DENY_ATTACH: CInt = 31 | |
let handle = dlopen("/usr/lib/libc.dylib", RTLD_NOW) | |
let sym = dlsym(handle, "ptrace") | |
typealias PtraceAlias = @convention(c) (CInt, pid_t, CInt, CInt) -> CInt | |
let ptrace = unsafeBitCast(sym, to: PtraceAlias.self) | |
_ = ptrace(PT_DENY_ATTACH, 0, 0, 0) | |
dlclose(handle) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment