
Manual kernel driver mapper for Windows x64 that abuses CVE-2025-8061 in Lenovo's LnvMSRIO.sys to perform a BYOVD attack, mapping PE64 drivers into ring 0.
BYOVD Manual Mapper for Windows x64 · CVE-2025-8061
MSRMapper is a manual kernel driver mapper for Windows x64 that abuses CVE-2025-8061 in the vulnerable Lenovo driver LnvMSRIO.sys to perform a BYOVD (Bring Your Own Vulnerable Driver) attack.
The project maps a PE64 driver directly into kernel memory without using sc create or a service, and executes its DriverEntry in ring 0. The whole process relies on:
LnvMSRIO.sys.SuperfetchPfnQuery class of NtQuerySystemInformation.LSTAR hijacking to execute ring-0 shellcode.NtAddAtom hooking to call kernel functions such as ExAllocatePoolWithTag, RtlCopyMemory, and DriverEntry.Status: Tested on Windows 10 22H2 (OS Build 19045.6466). The driver is mapped successfully and
DriverEntryreturnsSTATUS_SUCCESS(0x0).
ExAllocatePoolWithTag.KiSystemCall64, NtAddAtom, etc.) by downloading PDBs from the Microsoft Symbol Server.NtQuerySystemInformation class 0x4F), without needing a custom page-table walker.LSTAR, FMASK) and physical memory read/write through LnvMSRIO.sys.LSTAR.MmGetPhysicalAddress to obtain the PA of NtAddAtom.swapgs; sysret.NtAddAtom hook (12-byte ) to call arbitrary kernel functions.\\.\WinMsrDev (service exposed by LnvMSRIO.sys).ntoskrnl base via EnumDeviceDrivers and validates it with LSTAR.PdbResolver to resolve kernel symbol RVAs.NtAddAtomLSTAR is hijacked.swapgs; iretq gadget into LSTAR.PrepareStack and enables AC=1 in user mode via EnableACUserMode.syscall, the CPU jumps to the gadget, runs the shellcode, calls MmGetPhysicalAddress(NtAddAtom), and stores the PA in a user buffer.LSTAR and returns to user mode with swapgs; sysret.ExAllocatePoolWithTag (invoked through the temporary NtAddAtom hook).RtlCopyMemory.DriverEntry with DriverObject = NULL and RegistryPath = NULL.NtAddAtom..asm files.LnvMSRIO.sys (CVE-2025-8061) installed and the WinMsrDev service running.C:\Symbols.This project uses CMake. To build from the command line:
Generate the Visual Studio 2022 solution:
cmake -B build -G "Visual Studio 17 2022" -A x64
Build in Release mode:
cmake --build build --config Release
The output binaries will be in build/bin/Release/ (or a similar path depending on the CMake configuration).
Alternatively, you can open the generated build/KernelLoader.sln in Visual Studio 2022 and build from there.
Make sure ShellcodeAsm.asm and EnableAC.asm are compiled with MASM. The provided CMakeLists.txt handles this automatically.
If you need to adjust the build configuration, edit CMakeLists.txt.
Install and start the LnvMSRIO.sys service:
sc create WinMsrDev type= kernel binPath= C:\path\to\LnvMSRIO.sys
sc start WinMsrDev
Run KernelLoader.exe as Administrator:
KernelLoader.exe
To see the mapped driver's DbgPrint output, use DebugView (Sysinternals) as Administrator with:
Capture → Capture KernelOptions → Enable Verbose Kernel OutputHKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Debug Print Filter
DWORD named Default with value .DBGHELP: ... - unmatched message that appears in some PdbResolver logs is cosmetic. The PDB is loaded at an artificial virtual base and SymFromName still works correctly. It does not affect symbol resolution.EnumDeviceDrivers may return an incorrect base. This project calculates the real base with LSTAR - KiSystemCall64.NtAddAtom hook is temporary and restored after each call. Still, use this only in controlled environments.SMEP/SMAP are enabled. They are temporarily disabled via CR4 and restored before returning to user mode.jmp raxEnumDeviceDrivers may return an incorrect base; the real kernel base is calculated with LSTAR - KiSystemCall64.0xFFFFFFFF