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

  


   심플스 배너



이미 알고 계신분들이 많으시겠지만 Windows XP SP2이상부터 MS 핫패칭 기능이 들어가 있습니다.
따라서 이에 대해 특정 함수에 대한 기계어 코드를 검사함으로써 Windows XP SP2이상인지 확인 할 수 있습니다.

다음은 해당 코드입니다.

#include <Windows.h>

BOOL IsWindowsXpSp2AndLater()
{
    HMODULE hModule;
    UCHAR *pBitBltAddress;

    hModule = ::LoadLibrary(_T("GDI32.DLL"));
    if (hModule == NULL)
    {
        return FALSE;
    }
    pBitBltAddress = (UCHAR *)::GetProcAddress(hModule, "BitBlt");
    if (pBitBltAddress == NULL)
    {
        return FALSE;
    }
    //
    // MS HotPatching이 Windows XP SP2 이상부터 적용되었으므로 이에 대한 기계어 코드를 확인합니다.
    //
    if (((*(pBitBltAddress - 5)) == 0x90) && // nop
        ((*(pBitBltAddress - 4)) == 0x90) && // nop
        ((*(pBitBltAddress - 3)) == 0x90) && // nop
        ((*(pBitBltAddress - 2)) == 0x90) && // nop
        ((*(pBitBltAddress - 1)) == 0x90) && // nop
        ((*pBitBltAddress) == 0x8B) && ((*(pBitBltAddress + 1)) == 0xFF) // mov edi, edi
        )
    {
        return TRUE;
    }
    return FALSE;
}

int _tmain(int argc, _TCHAR* argv[])
{
    if (IsWindowsXpSp2AndLater() == TRUE)
    {
        printf("버전이 Windows XP SP2 이상입니다. ( 또는 Windows 2003 Server 이상 )\n");
    }
    else
    {
        printf("버전이 Windows XP SP2 아래에 운영체제입니다.\n");
    }
    return 0;
}

해당 함수가 이미 훅킹을 당했을 경우 코드에 변조가 있을 수 있으므로 주의해야합니다.

profile

esniper

2010.09.05 21:13:35

GDI32.DLL에서 체크하는 방식이네요~

취약점이 있는 버전을 사용중인지 체크도 가능하겠군요.

List of Articles
번호 제목 글쓴이 날짜 조회 수
6 Windows Research 커널 모듈 리스트 가져오기 [3] lain 2010-09-03 5234
5 Windows Research IDA에서 Microsoft 바이너리 파일을 리버싱 할 때 디버그 심... file [1] lain 2010-09-03 6486
4 Windows Research IDA에 HexRay를 사용할 때의 주의점 [1] lain 2010-09-03 5857
3 Windows Research 유저 레벨에서 API Hook 2부 file [2] lain 2010-09-03 4710
2 Windows Research 유저 레벨에서 API Hook 1부 file [1] lain 2010-09-03 5854
» Windows Research 윈도우즈 버전이 Windows XP SP2인지 확인하는 다른 방법 [1] lain 2010-09-03 4991

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