본문으로 바로가기

[D+11] 안티 디버깅

category 해킹&보안/리버싱 2017. 4. 17. 19:06
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

5. 안티 디버깅


1) Anti-Debugging


▣ 안티 디버깅이란?

- 고급 리버싱 과정

- 각종 안티 디버깅 기법들의 동작 원리 파악 후 회피

- 지금까지 배운 내용을 총 동원

- 디버거와 OS에 강한 의존성

- 지속적인 최신 기술 습득

- 안티디버깅의 최종목표는 디버깅을 못하게가 아닌 최대한 지연시키는 것임.

- 디버깅 중일때랑 아닐때 실행결과를 다르게함 (안티디버깅인지 모르게)


안티 디버깅 분류

- API Based Detection : OS에서 함수를 제공해줌. 고로 분석하기도 제일 쉬움.

☞ FindWindow, IsDebuggedPresent(PEB 구조체) 등..

- Process and Thread Block Detection : PEB 구조체를 통해서 정보를 얻어옴.

- Hardware and Register Based Detection : Breakpoint 탐지 또는 가상 머신에서 실행시킬때 탐지

- Exception Based Detection : OllyDbg의 0xCC Detection

- Timing Based Detection : 시간 이용(시간 체크 함수 2개 사이의 시간 차이를 살핌)


IsDebuggerPresent() -- API

- OS로부터 직접 정보를 얻어옴.

#include <stdio.h>
#include <windows.h>
#define _WIN32_WINNT 0x501

//BOOL WINAPI IsDebuggerPresent(void);
int main()
{
	printf("==== IsDebuggerPresent Exam ====\n");

	if (IsDebuggerPresent())
	{
		printf("Debugging detected!!\n");
		system("pause");
		exit(0);
	}
	else
	{
		printf("Normal execution\n");
	}
	return 0;
}


FindWindow() -- API

- 실행중인 창 (간접적, 환경적 요소)

#include <stdio.h>

//HWND FindWindow(LPCTSTR  lpClassName, //클래스명(프로세스가 가진 고유이름)
//				 LPCTSTR lpWindowName); // 캡션명은 바뀜.
int main()
{
	printf("==== FindWindow Exam ====\n");

	if (FindWindow("notepad", 0))
	{
		printf("Debugging detected!!\n");
		system("pause");
		exit(0);
	}
	else
	{
		printf("Normal execution\n");
	}
	return 0;
}


TimeCheck - RDTSC -- API

- 어셈 명령어임.

- ReaD Time Stamp Counter의 줄임.

- Time Stamp Counter : 상대시간. CPU 내에 들어있는 값으로 CPU 켜면 0부터 올라감.

☞    RDTSC

 인증

 RDTSC

 검증

 핵심코드










i2sec 대구지점 23기 수료생.

'해킹&보안 > 리버싱' 카테고리의 다른 글

[D+13] DLL Injection (2)  (0) 2017.04.20
[D+12] DLL Injection (1)  (0) 2017.04.18
[D+10] 패킹&언패킹 (2)  (0) 2017.04.12
[D+9] 패킹&언패킹 (1)  (0) 2017.04.11
[D+8] PE 구조  (0) 2017.04.10