IsDebuggerPresent
Kernel32 IsDebuggerPresent 함수는 윈도우 95에서 소개되었습니다. 디버거가 실행중이면 TRUE 값을 반환합니다. 내부적으로 PEB->BeingDebugged 플래그에 의해 값을 반환합니다.
예제코드는 다음과 같습니다.
call IsDebuggerPresent
test al, al
jne being_debugged
일부 패커들은 커널32 IsDebuggerPresent() 함수를 사용하는 것을 피하며 직접 PEB구조체를 확인합니다.
예제 코드는 다음과 같습니다.
mov eax, fs:[30h] ;PEB
;check BeingDebugged
cmp b [eax+2], 0
jne being_debugged
이러한 방법을 해결하는 방법은 PEB->BeingDebugged 플래그 값을 FALSE로 설정하기만 하면 됩니다. 디버깅할 때 일반적으로 IsDebuggerPresent() 함수의 처음 instruction에 브레이크포인트를 설정한다. 몇몇의 언패커들은 반드시 브레이크 포인트를 확인합니다.
예제 코드는 다음과 같습니다.
push offset l1
call GetModuleHandleA
push offset l2
push eax
call GetProcAddress
cmp b [eax], 0cch
je being_debugged
...
l1: db "kernel32", 0
l2: db "IsDebuggerPresent", 0
일부 패커들은 함수의 첫 번째 바이트는 0x64라는 것을 확인합니다.(앞글자 "FS:")
예제 코드는 다음과 같습니다.
push offset l1
call GetModuleHandleA
push offset l2
push eax
call GetProcAddress
cmp b [eax], 64h
jne being_debugged
...
l1: db "kernel32", 0
l2: db "IsDebuggerPresent", 0



최근 덧글