본문 바로가기

reversing

IsDebuggerPresent() 우회

Anti-Debugging 기법 중 가장 기초적인 방법으로 IsDebuggerPresent 기법이 있다.

 

IsDebuggerPresent() 함수는 호출된 프로세스가 유저 모드 디버거에 의해 호출되었는지를 확인하는 Windows API이다.

 

<windows.h> 헤더 파일을 인클루드하면 바로 호출할 수 있다.

 

 

 

예제 소스코드는 다음과 같다.

 

 

#define _WIN32_WINNT 0x0500

 

#include <stdio.h>
#include <Windows.h>

 

int main() {
    while (1) {
        Sleep(1000);
        if (IsDebuggerPresent() == 1) {
            printf("디버깅 당함 \n");
        }
        else {
            printf("정상\n");
        }
    }
    return 0;
}

 

 

기본적인 Anti-Debugging 기법이니 만큼 우회도 간단하다.

 

 

IsDebuggerPresent() 함수는 디버깅을 당하면 1을 리턴한다. 현재 EAX 값이 1로 리턴된 것을 볼 수 있다.

 

우회에는 여러 가지 방법이 있다. 간단하게 우회할 수 있으므로 자세한 설명은 생략하도록 하겠다.

 

1. mov eax, 0 추가

 

2. IsDebuggerPresent() 함수를 NOP으로 덮음

 

3. eax 값 0으로 변경

 

 

'reversing' 카테고리의 다른 글

assembly jump instruction  (0) 2016.01.19
프롤로그(prolog), 에필로그(epilog)  (0) 2016.01.03
Intel Architecture 32bit Register  (0) 2015.12.19
함수 호출 규약(Calling Convention)  (0) 2015.12.19
바이트 오더링(Byte Ordering)  (0) 2015.11.10