본문으로 바로가기

Hardware BreakPoint 기반 안티 디버깅 - GetThreadContext API 이용
디버깅을 할 때 특정 상황(메모리 접근에 의한 브레이크포인트나, 소프트웨어 브레이크 포인트 탐지 우회를 위한)에서 하드웨어 브레이크 포인트를 사용하게 되며, 하드웨어 브레이크 포인트를 사용하기 위해 Debug Register를 사용하게 되는데, Debug Register를 체크하여 안티 디버깅을 수행할 수 있음
GetThreadContext API를 이용하여 Debug Register의 값을 체크

 

Debug Register

Dr0 ~ Dr3 : Hardware BP를 설정할 선형 주소
Dr4 ~ Dr5 : Reserved(예약됨)
Dr6 Debug Status
Dr7 : Debug Control

 

소스 코드

 

안티 디버깅 우회 방법
1. Hardware Break Point를 체크하는 부분의 코드 수정
2. Hardware Break Point를 사용하지 않고 디버거에서 지원하는 Software Break Point나 Memory Break Point 등을 이용

 

Reference
PDF 문서 : IA-32 Manual
Wikipedia : 
http://en.wikipedia.org/wiki/X86_debug_register