
RTCore64.sys developed by MSI and distributed with hardware monitoring and overclocking utilities like MSI Afterburner. In this blog, I will be covering CVE-2019-16098. Which is mainly a R/W primitive leading to a EoP.

Eecommended reading link (same as this but you do you) : here
Poc link : here Driver link : here
A driver developed by MSI and distributed with hardware monitoring and overclocking utilities like MSI Afterburner became a common use for BYOVD primitives.
In this blog, I will be covering CVE-2019-16098. Which is mainly a R/W primitive leading to an EoP. for my case.
dt nt!_EPROCESS and check for your own offsets.I would recommend taking a look at these resources here :
I also won't be reinventing the wheel, since these guys also did it before and idafchev has a more detailed writeup for understanding it. So these are recommended reads.
The advisory says enough (here) :
The driver in Micro-Star MSI Afterburner 4.6.2.15658 (aka RTCore64.sys and RTCore32.sys) allows any authenticated user to read and write to arbitrary memory, I/O ports, and MSRs. This can be exploited for privilege escalation, code execution under high privileges, and information disclosure. These signed drivers can also be used to bypass the Microsoft driver-signing policy to deploy malicious code.

it takes user input through IOCTL codes of size 0x30, then passes the struct fields directly to MmMapIoSpace as a physical address and size with no validation.
One thing I realized about this driver before we start is that it takes input as structs in a very organized way, but at the same time, if you try to write random buffer, it will not BSOD, that's because of 2 main reasons :
So while constructing the exploit, it won't be really a mess dealing with BSODs, rather I will start with creating the exploit directly later in this blog.
For now though, let's start by opening the driver in IDA (or whatever utility you feel the most comfortable with) and let's take a look at this driver :

Immediately, we can see the driver symbolic name, which we will be able to use to create a HANDLE to the driver. Recall that to communicate with the driver, we need mainly 2 things after reversing the driver.
So far, 1 half is done.
Since the driver is small, we can easily look through each function quickly and find that one of them has alot of branches (in other words, a possible IOCTL function).
To confirm though, we need to look for the IofCompleteRequest method if it exists at the end of a function. If it does, you are most likely dealing with the function handling I/O requests.
For our case, you can go to the imports section in IDA found usually at the top as shown :

Then we search (via CTRL+F) for "IofCompleteRequest" :

Pressing on it, we see the following :

As shown in the image, if we double click on that function, we will see the function where it's called in.
Looking into that function more, we eventually confirm that it is indeed the IoDispatch function :
Scrolling up in the decompiled code :

We see alot of switch statements and 2 IOCTL codes.
We have now found the I/O function we need.
I will be renaming it to "IoDispatch" to easily spot it in case we do anything later.
Now, since this is a public CVE, we can see that the main vulnerability resides at 2 IOCTL codes.
One of them being the read primitive and the other being the write primitive. To easily spot them in IDA, I would recommend decompiling first then looking into each switch statement, since in the disassembly, it doesn't tell us which branch uses which IOCTL code like other drivers.
Looking into the "0x80002048" code (which is the read primitive), we see the following :
Let's break this down :
If we were to visualize this in order, we would have something like this :
r10+0x8
r10+0x14
r10+0x18
r10+0x1c
All this while noting that the size should be 0x30 bytes (48 bytes).
So if we create a struct for our input, this is how it's supposed to look like :