심플스 - 프로그램과 책 이야기로 가득한 곳, (Simples.Kr)

  


   심플스 배너



커널 디버거 탐지 기법 우회

Windows Research 조회 수 3707 추천 수 0 2010.09.03 17:29:28
 
다음 코드 2줄로 우회가 가능합니다.

extern PBOOLEAN KdDebuggerEnabled; // 선언..
*KdDebuggerEnabled = FALSE; // 우회 코드

KdDebuggerEnabled 변수를 직접적으로 접근하지 않는 방식을 사용하여도 이 방법은 통합니다.
왜냐하면 결국엔 그 함수들은 저 전역변수를 참조하게 됩니다.
심지어 WinDbg 조차도 저렇게 값을 임의로 바꾸면 Attach가 안됩니다.

따라서 이러한 경우 커널 디버거는 우회가 되는데 WinDbg로 Attach 하여서 디버깅하는데 조금 문제가 생길것입니다.
따라서 디버거를 탐지하는 코드가 실행되는 경우에는 우선 저렇게 전역변수를 FALSE로 바꾸고
디버거 탐지코드가 실행되었다면 다시 KdDebuggerEnabled 커널 전역변수를 TRUE로 바꿔주면
WinDbg로 Attach 도 되고 디버깅이 가능해집니다.

커널 디버거를 탐지하는 대상 코드는 아래와 같고 이러한 코드는 이전에 말했듯이 내부적으로
위에 커널 전역변수를 사용하므로 우회가 됩니다.

bool __stdcall IsDebugPort(PVOID Object)
{
  void *pZwQueryInformationProcess; // eax@2
  bool result; // eax@4
  signed int bDebug; // [sp+10h] [bp-4h]@1
  int v4; // [sp+Ch] [bp-8h]@2
  UNICODE_STRING DestinationString; // [sp+4h] [bp-10h]@3

  bDebug = 0;
  if ( PsLookupProcessByProcessId(Object, &Object) >= 0
    && ((ObOpenObjectByPointer(Object, 0, 0, 0, 0, 0, &v4), ObfDereferenceObject(Object), pZwQueryInformationProcess = (void *)g_ZwQueryInformationProcess, g_ZwQueryInformationProcess)
     || (RtlInitUnicodeString(&DestinationString, L"ZwQueryInformationProcess"), pZwQueryInformationProcess = MmGetSystemRoutineAddress(&DestinationString), g_ZwQueryInformationProcess = (int)pZwQueryInformationProcess, pZwQueryInformationProcess)) )
  {
    ((int (__stdcall *)(int, signed int, signed int *, signed int, _DWORD))pZwQueryInformationProcess)(
      v4,
      7,
      &bDebug,
      4,
      0);                                                       // 이 함수에 두 번째 인자 ProcessDebugPort를 넘기고 있다.
                                                                // 즉, 이것은 디버그중인지 체크한다고 보면 될것이다.
    result = bDebug == -1;                                      // -1(0xFFFFFFFF) 일 경우 디버깅중인 상태입니다.
  }
  else
  {
    result = 0;
  }
  return result;
}
List of Articles
번호 제목 글쓴이 날짜 조회 수
142 Windows Research 디바이스이름으로부터 PDEVICE_OBJECT 얻기 file [레벨:6]lain 2010-09-04 3674
141 Windows Research 하드디스크에 존재하지 않는 드라이버 바이너리 가져오기 file [5] [레벨:6]lain 2010-09-03 3627
140 Windows Research DosPathNameToNtPathName file [레벨:6]lain 2010-09-03 2615
139 Windows Research ZwQueryInformationFile을 비동기 파일핸들로 호출 시 STAT... file [레벨:6]lain 2010-09-03 3481
» Windows Research 커널 디버거 탐지 기법 우회 [레벨:6]lain 2010-09-03 3707
137 Windows Research VMWare 탐지 기법 우회 [2] [레벨:6]lain 2010-09-03 5115
136 Windows Research 커널 모듈 리스트 가져오기 [3] [레벨:6]lain 2010-09-03 2627
135 Windows Research IDA에서 Microsoft 바이너리 파일을 리버싱 할 때 디버그 ... file [1] [레벨:6]lain 2010-09-03 3725
134 Windows Research IDA에 HexRay를 사용할 때의 주의점 [1] [레벨:6]lain 2010-09-03 3347
133 Windows Research 유저 레벨에서 API Hook 2부 file [2] [레벨:6]lain 2010-09-03 2336
132 Windows Research 유저 레벨에서 API Hook 1부 file [1] [레벨:6]lain 2010-09-03 2498
131 Windows Research 윈도우즈 버전이 Windows XP SP2인지 확인하는 다른 방법 [1] [레벨:6]lain 2010-09-03 2728
130 문서자료 Hexray - Failures and troubleshooting [레벨:6]lain 2010-09-03 2130
129 문서자료 Intel i80x86 CPU Architecture [레벨:6]lain 2010-09-03 1981
128 문서자료 Keybaord Scan Codes Demystified [레벨:6]lain 2010-09-03 2058
127 문서자료 Bona Fide OSDev Documents [레벨:6]lain 2010-09-03 1981
126 문서자료 the Operating System resource center [레벨:6]lain 2010-09-03 1543
125 문서자료 Win32 Assembly Tutorials [1] [레벨:6]lain 2010-09-03 1985
124 문서자료 Mozilla - Accessibility/AT-Windows-API [레벨:6]lain 2010-09-03 1984
123 문서자료 Intel® Threading Building Blocks: Documents [레벨:6]lain 2010-09-03 2600

  • 이용약관
  • 개인정보취급방침
  • 사이트맵