본문 바로가기

ios) 안티디버깅 - getppid() ios) 안티디버깅 - getppid 일반적인 앱은 launchd process에 의해 실행된다. launchd 프로세스는 user mode로 첫번째로 돌아가는 프로세스로 PID=1이다. 따라서 일반적인 앱의 ppid(parent process id)는 1로 조회된다면 정상이다. 반면 디버거에서 자식프로세스로 생성한 경우는 ppid는 디버거의 PID로 설정된다. 따라서 getppid() 함수 호출 결과가 launchd인 1이 아니라면 디버거에서 생성했다고 판단할 수 있다. func AmIBeingDebugged() -> Bool { return getppid() != 1 } [우회] 물론 getppid() 함수에 후킹 걸어서 항상 1이 반환되도록 하면 됨. 아니면 반환 결과를 보고 판단하는 함수를 패치해..
ios) 안티디버깅 - sysctl ios) 안티디버깅 - sysctl ptrace와 비슷한 맥락이다. 다만 이번에는 ptrace flag가 설정됐는지 여부를 확인하는 것. Is_debugger_present를 알고 있다면 동일하다고 생각하면 된다. 정보 : 디버거 아래에 자식으로 생성하던, 실행중인 프로세스에 attach를 했건 P_TRACED 플래그는 Set 된다. 아래 코드는 mobile-security-testing-guide의 ios-testing-guide에서 발췌함. #include #include #include #include #include static bool AmIBeingDebugged(void) // Returns true if the current process is being debugged (either //..
ios) ptrace관련 안티디버깅 정리 ios) ptrace관련 안티디버깅 정리 https://alexomara.com/blog/defeating-anti-debug-techniques-macos-ptrace-variants/ Defeating Anti-Debug Techniques: macOS ptrace variants | Alexander O'Mara Every reverse engineer who handles software for macOS knows about ptrace(PT_DENY_ATTACH, 0, 0, 0), the infamous kernel-enforced anti-tracing DRM feature added to OS X years back (somewhere around Leopard) and most-notab..