Exploit database

GH-ec3b6c72a1c8674f5449c2d8911bec19

ull0a/msrmapper

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-8061

3 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files19
ull0a/msrmapperRevision 786498c8676f

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

client/PdbResolver.cpp

C++ · 3,893 bytes
// client/PdbResolver.cpp
#include "PdbResolver.h"
#include <dbghelp.h>
#include <cstdio>
#include <filesystem>
#include <string>
#include <unordered_map>

#pragma comment(lib, "Dbghelp.lib")

static HANDLE   g_process = nullptr;
static bool     g_initialized = false;

static std::unordered_map<std::wstring, DWORD64> g_loadedModules;

bool PdbResolver::Initialize(const std::wstring& cacheDir) {
    if (g_initialized) return true;

    g_process = GetCurrentProcess();
    std::filesystem::create_directories(cacheDir);

    std::wstring symbolPath = L"cache*" + cacheDir +
                              L";SRV*http://msdl.microsoft.com/download/symbols";

    if (!SymInitializeW(g_process, symbolPath.c_str(), FALSE)) {
        printf("[!] SymInitializeW fallo: %lu\n", GetLastError());
        return false;
    }

    SymSetOptions(SYMOPT_EXACT_SYMBOLS | SYMOPT_DEBUG);

    g_initialized = true;
    printf("[+] PdbResolver inicializado (cache: %ls)\n", cacheDir.c_str());
    return true;
}

void PdbResolver::Shutdown() {
    if (g_initialized && g_process) {
        for (auto& kv : g_loadedModules) {
            SymUnloadModule64(g_process, kv.second);
        }
        g_loadedModules.clear();
        SymCleanup(g_process);
        g_process = nullptr;
        g_initialized = false;
    }
}

std::optional<uint32_t> PdbResolver::ResolveRva(
    const std::wstring& pePath,
    const std::string& symbolName)
{
    if (!g_initialized) return std::nullopt;

    // 1. Obtener info del PDB desde el PE
    SYMSRV_INDEX_INFOW info{};
    info.sizeofstruct = sizeof(SYMSRV_INDEX_INFOW);
    if (!SymSrvGetFileIndexInfoW(pePath.c_str(), &info, 0)) {
        printf("[!] SymSrvGetFileIndexInfoW fallo: %lu\n", GetLastError());
        return std::nullopt;
    }

    // 2. Localizar PDB (cache local o descarga)
    wchar_t pdbPathBuffer[4096] = {};
    void* id = nullptr;
    DWORD idType = 0;
    if (info.guid == GUID{}) { id = &info.sig;  idType = SSRVOPT_DWORDPTR; }
    else                     { id = &info.guid; idType = SSRVOPT_GUIDPTR;  }

    if (!SymFindFileInPathW(g_process, nullptr, info.pdbfile,
                            id, info.age, 0, idType,
                            pdbPathBuffer, nullptr, nullptr)) {
        printf("[!] SymFindFileInPathW fallo: %lu\n", GetLastError());
        return std::nullopt;
    }

    std::wstring pdbPath(pdbPathBuffer);

    // 3. Reutilizar si ya esta cargado
    DWORD64 modBase = 0;
    auto it = g_loadedModules.find(pdbPath);
    if (it != g_loadedModules.end()) {
        modBase = it->second;
    } else {
        DWORD fileSize = static_cast<DWORD>(std::filesystem::file_size(pdbPath));

        DWORD64 baseAddr = 0x40000;

        modBase = SymLoadModuleExW(
            g_process,
            nullptr,
            pdbPath.c_str(),
            nullptr,
            baseAddr,
            fileSize,
            nullptr,
            0
        );

        if (modBase == 0) {
            printf("[!] SymLoadModuleExW fallo: %lu\n", GetLastError());
            return std::nullopt;
        }

        g_loadedModules[pdbPath] = modBase;
    }

    char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME + 1] = {};
    auto sym = reinterpret_cast<SYMBOL_INFO*>(buffer);
    sym->SizeOfStruct = sizeof(SYMBOL_INFO);
    sym->MaxNameLen   = MAX_SYM_NAME;

    BOOL ok = SymFromName(g_process, symbolName.c_str(), sym);
    if (!ok || sym->Address == 0) {
        printf("[!] SymFromName(%s) fallo: %lu\n",
               symbolName.c_str(), GetLastError());
        return std::nullopt;
    }

    uint32_t rva = static_cast<uint32_t>(sym->Address - modBase);
    printf("[+] %s -> RVA 0x%X\n", symbolName.c_str(), rva);

    // NO descargamos el modulo: se reutiliza en futuras llamadas.
    return rva;
}