[00:01.820 --> 00:07.940] Okay. Hi there. Thanks a lot for sticking up with us. Today I'm going to speak around [00:07.940 --> 00:14.180] about driver jack, which is an unusual technique to load the driver on Windows 11, abusing [00:14.180 --> 00:23.120] NTFS features and CDFS bug, I'd say. So just before starting, a few words about me. I'm [00:23.120 --> 00:28.720] Alessandro Magnozzi. I work for BSI, British Standards Institute. I mainly do research, [00:28.720 --> 00:37.100] but a huge part of my daily business is consulting in adversary simulation, device security and [00:37.100 --> 00:44.400] AppSec. I go on Internet with the name klatsvirus. You can reach me out on GitHub or Twitter. [00:44.700 --> 00:53.540] Feel free to reach out. Now, just before starting, I'm going to just give a bit of information [00:53.540 --> 01:01.520] about this project. This project was started in 2022 with Jonas Lake from Secret Club. We [01:01.520 --> 01:06.700] started working on a POC to abuse ISOs to load malicious drivers on Windows. Then we [01:06.700 --> 01:11.300] completely forgot about that for at least one year because I was working on other stuff. [01:11.300 --> 01:16.460] And then in 2023 I had an engagement that supported the development of this technique [01:16.580 --> 01:23.520] a bit further. Now, the engagement was a bit like it was an OT engagement. It was a [01:23.540 --> 01:33.120] deployment and the main aim of the engagement was to deploy a kernel rootkit on an OT workstation. [01:33.460 --> 01:39.440] Now, regardless of the engagement, the engagement was pretty well and we found ourselves in [01:39.520 --> 01:47.240] a situation where we could tamper ISO files that were distributed to machines via an update [01:47.240 --> 01:55.040] catalog. So this gave us a motivation to read, resume the research that we were doing [01:55.040 --> 02:00.600] in 2022 and we tried to understand if we could develop it further. Now, we didn't know exactly [02:00.600 --> 02:07.240] what to expect from the malware that we were generating. We just know that we wanted something [02:07.240 --> 02:11.960] to backdoor an installer, present on an ISO and then we want to weaponize it in the best [02:11.960 --> 02:17.220] way possible. Of course, ISOs have been weaponized for years right now for their ability [02:17.220 --> 02:22.620] to bypass multi W but this was not really what we wanted to do. We didn't want to just [02:23.180 --> 02:29.860] provide an ISO to our customer. We had in the position of weaponizing an ISO. And then [02:29.860 --> 02:35.180] we just wanted to execute some code and like deploy some vectors around, I don't know if [02:35.180 --> 02:42.500] you, if you are aware, always aware about the, what Stuxnet was doing back in 2011 but [02:42.500 --> 02:47.700] we wanted to achieve something like backdooring DLL on different softwares to intercept [02:47.700 --> 02:53.200] communication, intercept code going and arriving from PLCs and doing stuff like that with [02:53.780 --> 03:03.580] using side loading or DLL proxying on certain specific DLL used by this kind of software. And [03:03.580 --> 03:07.780] the additional thing that we wanted to achieve was deploying a kernel driver on these [03:07.780 --> 03:15.920] boxes. Now the, we started and one example of the ISOs that we end up backdooring was step 7 [03:15.920 --> 03:21.160] installation media and the reason for this is that it's naturally deployed by using ISO [03:21.160 --> 03:29.920] files and it's pretty difficult to backdoor because step 7 utilized a bootstrap to launch [03:29.920 --> 03:35.980] the installer meaning that, meaning that it actually performs an integrity check on the [03:35.980 --> 03:41.200] content of the disk before actually launching the installer and it has two layer of checks so [03:41.200 --> 03:47.920] you need to, you need to, if you want to execute malicious code using the installer, you need to [03:47.920 --> 03:53.380] find a way to not tamper with any existing DLL and any existing executable on the disk. [03:55.480 --> 04:02.380] Talking about deploying the Windows root kit, a Windows root kit, usually when you need to [04:02.380 --> 04:06.700] deploy a root kit on Windows, a kernel root kit, a kernel driver on Windows, what you end up [04:06.700 --> 04:11.640] doing is you call create service, you create a service for the service driver and then you start [04:11.640 --> 04:16.700] the service with the driver. Of course one requirement for this is that the driver file that you [04:16.700 --> 04:24.620] are loading needs to be on disk. Now this can be done manually by manually placing a registry [04:24.620 --> 04:31.260] key in the file system and then calling antiload driver to load the driver. This is a bit more [04:31.260 --> 04:37.260] stealth way of loading a driver and it's in the name of this thing is Windows log event [04:37.260 --> 04:42.320] evasion because it doesn't generate the event that is usually created when you create a service and [04:42.320 --> 04:50.260] start the service. But of course there is something else that sticks up. So like there is every time [04:50.260 --> 04:55.860] you load the driver regardless if you are using the start service, the create service or you use [04:55.860 --> 05:04.520] directly the antiload driver function, you generate an event which is the load driver event that [05:04.520 --> 05:09.160] is a sysmon event and event six that provides all the information about the driver you [05:09.160 --> 05:17.240] loaded. So even if it's more stealthy, there is still this that appears as an event on the [05:17.240 --> 05:23.860] Windows log. So we wanted a technique that would help us bypass this event load driver as [05:23.860 --> 05:32.700] well. And so we ended up creating four libraries framework. I mean two of them are the core of [05:32.700 --> 05:39.880] this presentation which is IOCDFS lib and driver jack that will be abused to load a driver on [05:39.880 --> 05:44.480] Windows. The other two are collateral projects. They were not supposed to be part of the [05:44.480 --> 05:50.840] project. They just are RPC exec. I will just talk about it briefly. RPC execs is a less [05:50.840 --> 05:59.540] common way to execute on Windows on local or remote processes without requiring RX memory to [05:59.540 --> 06:05.040] be allocated in target process. And interleaver is a it became a sort of P manipulation [06:05.040 --> 06:12.060] library that we cannot share completely but I will share a simple block which is coupling P. You [06:12.060 --> 06:17.780] can find coupling P which is coupling preserve on my GitHub page. Now coupling P is a [06:17.780 --> 06:24.100] short version of interleaver. It doesn't manipulate completely the P file but it's an [06:24.100 --> 06:32.160] extension to what Nick Lenders implemented back in 2020. I don't remember exactly. So coupling [06:32.160 --> 06:41.880] is a framework that takes target DLL, clone the export at this table and include it in DLL that [06:41.880 --> 06:49.780] you developed. Now this is used usually for DLL side loading using the DLL main function as main [06:49.780 --> 06:55.300] entry point for the DLL. Now the problem is that this process is destructive. So if you have [06:55.300 --> 07:01.360] some exports in your payload DLL, these will be erased. So coupling P just solves the problem [07:01.360 --> 07:07.100] and it just preserves the existing export at this table and just add the forwards afterward. [07:07.100 --> 07:15.620] That's it. Not really a difficult project. RPC proxy invoke instead or RPC exec is a general [07:15.620 --> 07:24.020] library that we implemented to as I said is to execute code on local or remote processes. It's [07:24.480 --> 07:31.180] borrowed by browser exploitation. It abuses the NDR server call to execute arbitrary calls. It [07:31.180 --> 07:36.740] doesn't require RX memory and we also implement it in a way that it doesn't require a valid [07:36.740 --> 07:44.580] RPC binding handle for uh for execution. This is there is a reason for this. We wanted [07:44.580 --> 07:50.600] something that we could use to execute arbitrary calls in any server, even in any service, in [07:50.600 --> 07:57.440] any processes, even if it wasn't actually using RPC and we wanted to avoid maintaining like we [07:57.440 --> 08:03.380] wanted to be able to erase tracks if we wanted and using this technique we can load RPC, [08:03.380 --> 08:10.920] initialize it remotely, execute our stuff and then just get rid of RPCRT4 completely by freeing [08:10.920 --> 08:18.020] the library and no traces will remain in the service. The process. The code is there. There [08:18.020 --> 08:24.580] are also some demos around that you can check. It's just for functionality. The project code [08:24.580 --> 08:31.580] is implemented and it has some not limitation but is implemented nerfed meaning that it's not [08:31.580 --> 08:38.440] using for example code pattern search for uh for locating the required uh the required [08:38.440 --> 08:45.020] entry point in RPCRT4. RPCRT4 changes over time a lot so you need to adjust it to depending [08:45.020 --> 08:48.300] on your version, on your Windows version or you need to implement yourself the code that [08:48.300 --> 08:54.860] actually do the pattern searches. Previous research. So when it comes to the core of the [08:54.860 --> 09:01.120] research or loading a driver on Windows, you have a few ways to load a valid driver on a [09:01.580 --> 09:06.460] Windows to execute unsigned code on Windows. You can either, actually there are four. So the [09:06.460 --> 09:12.060] first one was implemented by Gabriel Landau not long ago uh by exploiting a new vulnerable [09:12.060 --> 09:16.160] class that is false file immutability. I didn't put it in the slides just because it wasn't [09:16.160 --> 09:20.020] available when I started doing this research but go check it out because it's an incredible [09:20.020 --> 09:26.180] research. But the standard way to load unsigned code on Windows are either you, it's not [09:26.180 --> 09:32.300] unsigned. You load signed code. So you have a kernel driver that you want to load. You join [09:32.300 --> 09:42.360] the Microsoft developer program. Microsoft sign your own driver and you're good to go. You [09:42.360 --> 09:51.180] can use a fake signature. So before 2015, Microsoft allowed kernel drivers signed with a [09:51.180 --> 09:58.040] valid code signing certificate and cross signed by an EVCA certificate to load on Windows. So [09:58.040 --> 10:04.780] if you have a certificate that was expired before or issued before 2015 and you have a leaked EVCA [10:04.780 --> 10:11.900] certificate, you can still use, you can still set up your own fake timestamp server and you can [10:11.900 --> 10:18.420] back sign one of these drivers and you can generate a signature that is expired. So signed [10:18.420 --> 10:26.380] certificate but still valid to load on Windows. The third and last technique was using a [10:26.380 --> 10:33.900] vulnerable driver. Now as you can understand, we didn't have any kernel driver on the [10:33.900 --> 10:39.720] developer program. We didn't have any EVCA certificate leaked and unknown that we could use so [10:39.720 --> 10:45.060] we went to the route of using a vulnerable driver to load our unsigned code. Now of course [10:46.360 --> 10:52.740] we then started the research we want for abusable vulnerable drivers and we found four of [10:52.740 --> 10:57.680] them, two of them we just report to the vendors because they were not useful to us. Two of [10:57.680 --> 11:04.140] them we kept them. Now usually when you want to load unsigned code on Windows, you search for [11:04.140 --> 11:07.820] of course there are a lot of vulnerabilities affecting vulnerable drivers. Buffer overflow, user [11:07.820 --> 11:13.840] after free, there are a lot. Not just this that I included here. But usually what you want is [11:13.840 --> 11:19.620] to have a stable physical memory read write, virtual memory read write or for example [11:20.380 --> 11:26.540] unprotected MSR access. MSR stands for model specific register. Now the first, this was abused [11:26.720 --> 11:34.980] a lot in 2018, 2020. So when you have and it appears when you have an unrestricted code called [11:34.980 --> 11:42.460] to WRMSR. So there is a specific model specific register on Windows which is the well actually [11:42.460 --> 11:48.340] another Windows. It's not specific to Windows. But it's the IA32L star that contains on [11:48.340 --> 11:57.100] Windows the pointer to the system call dispatch function. So on before KPTI was introduced [11:57.100 --> 12:04.560] this points to KI system call 64. After KPTI mitigation, this points to KI system call 64 [12:04.560 --> 12:10.480] shadow. But regardless, this points to a dispatch function that is responsible to switch to [12:14.560 --> 12:21.160] from user mode to kernel mode and execute and dispatch to the relevant system call handler on [12:21.160 --> 12:27.120] kernel side. Now if you have unrestricted call to and you can override this register, what you [12:27.120 --> 12:34.720] can do is you can weaponize it to point to your user defined handler. And this is abused in MSR [12:34.720 --> 12:43.540] by Xerox from back engineering. Magnificent tool. I have to be honest. And this literally [12:43.540 --> 12:51.940] implements its own dispatch function that swap to kernel mode using the swap JS instruction. [12:52.180 --> 13:01.000] Disables maps map and executes arbitrary code stored in a user mode buffer. Afterward it uses [13:01.000 --> 13:13.940] ROP to, sorry, it uses ROP to restore maps map and restore the IA L32 L star. Now this, the [13:13.940 --> 13:17.820] other, the other vulnerable pattern that we have is arbitrary physical memory access. Now [13:18.680 --> 13:24.660] usually when this, this presents itself in two forms, either a call, a restricted call to [13:24.660 --> 13:32.460] ZW map your section or that can map whatever physical address in a linear address or by using [13:32.460 --> 13:38.100] MMAP IO space. Now the vulnerable pattern that we found the most was this. It's abusable, [13:38.100 --> 13:44.320] it's less abusable than ZW map your section because these actually provide access that you [13:44.320 --> 13:49.800] can't specify the access right. So you can't specify read right instead of read. And this [13:49.800 --> 13:54.600] usually is used for privilege escalation. So if you have a pattern that like this, so you have [13:54.680 --> 14:00.880] a call to MMAP IO space, IO allocate MDL and then MM build MDL for non-page pool and then [14:00.880 --> 14:06.480] MMAP lock page specific, specify cache. You have a pattern where you can actually uh, [14:06.480 --> 14:13.500] allocate page memory, page pool memory, sorry, non-page pool memory in a user mode buffer and [14:13.500 --> 14:18.740] using a technique known as proc scanning, you can identify e-process structure in the non-page [14:18.740 --> 14:25.920] pool and swap tokens around to achieve uh, privilege escalation. And then there is the [14:25.920 --> 14:31.900] prints of all other vulnerabilities uh, arbitrary virtual read, arbitrary kernel virtual memory [14:31.900 --> 14:36.680] read write. This presents itself in a lot of different ways. It can be a mem move, a mem copy, [14:36.700 --> 14:43.600] a ZW write virtual memory. It can be a direct pointer assignment. Uh, it can be whatever. Now [14:43.600 --> 14:50.260] this is used for a lot of different stuff uh, let alone bypass DSC for example or just mapping [14:50.260 --> 14:55.580] arbitrary stuff in memory, in kernel memory and this is heavily abused by tools like KDMapper [14:55.580 --> 15:03.120] or KDU to load your driver in memory. Now of course Windows doesn't like this uh, so they [15:03.120 --> 15:08.600] started introducing a lot of different mitigations. Since 2018 there was the introduction [15:08.600 --> 15:16.060] of uh, KBDI after the Spectre meltdown uh, attack. Uh, then they started introducing VBS, [15:16.060 --> 15:21.860] virtualization based security and started enforcing HVCI. After the HVCI they introduced KDP [15:21.860 --> 15:28.400] which we will see. And then they implemented the Microsoft uh, driver block list and [15:28.400 --> 15:34.920] afterward they started introducing support first for kernel chat control enforcement technology [15:34.920 --> 15:43.400] that uh, neutralizes ROP based attack. And then in like weeks ago uh, they announced that [15:43.400 --> 15:49.780] Windows 11 24H2 will support uh, Intel DTRP, redirection protection that kills another [15:49.780 --> 15:59.540] back class that we will gonna see like now. So VBS is uh, is really tough for uh, for [15:59.540 --> 16:04.860] exploiting vulnerable drivers because HVCI want to prevent you from abusing a vulnerable [16:04.860 --> 16:13.420] driver to load your VTL zero rootkit in memory. Now, how it works? Well, you have now the [16:13.420 --> 16:22.540] Windows low is, is, is runs on top of the hypervisor and uh, it divides the trust level in [16:22.540 --> 16:29.840] two trust level, the VTL one and VTL zero. Now your own kernel runs in VTL zero. Now this is [16:29.840 --> 16:35.080] the guest uh, operating system, the guest OS and what it, what it, what it, what it does is [16:35.080 --> 16:41.980] that this uses a normal uh, page structured approach to, for address resolution to map a [16:41.980 --> 16:48.740] physical address into a linear address. So you have your CR3, you have your um, you have your [16:48.740 --> 16:55.220] uh, PML4 entry, then you have your uh, page directory pointer entry, then you have your page [16:55.220 --> 16:59.100] directory entry, the page table entry and then finally you have your physical address. This [16:59.100 --> 17:04.040] physical address though is a guest physical address. Meaning that there is another layer, [17:04.040 --> 17:11.280] second layer access resolution that is, translates a guest physical address into a real [17:11.280 --> 17:19.800] physical address that is managed entirely by, by the hypervisor. Uh, using extended page [17:19.800 --> 17:26.320] tables. Now what is the problem for us? Is that before this was introduced, page protection [17:26.320 --> 17:32.980] was kernel based. So when you had control of kernel, you could do literally anything. So if [17:32.980 --> 17:37.000] you had a virtual, if you had a virtual read write, you could literally locate the digi [17:37.000 --> 17:42.380] options for example, that is the global variable and like managing the driver signal [17:42.380 --> 17:47.200] reinforcement and you could just override it. You could nullify it, load your unsigned code [17:47.200 --> 17:53.320] and then restore it of course because even though it was possible to modify it, it was still [17:53.320 --> 18:02.020] protected by kernel patch guard. Um, KPP, kernel page, yeah, patch guard. Um, but now, now [18:02.020 --> 18:09.820] it's different because now the enforcement is done in a hypervisor level. Now HVCI does two [18:09.820 --> 18:16.660] things and in together with KDP, that's a lot of problems. Like HVCI enforces that any page [18:16.660 --> 18:24.740] is either writable or executable. Can be both. So this is designed to um, to avoid you from [18:24.740 --> 18:30.820] writing your own code in kernel memory and then execute it. So and now this protection is [18:30.820 --> 18:35.580] enforced on hypervisor level. Meaning that you, even if you have your fantastic read write [18:35.580 --> 18:40.700] primitive, uh, you can't change the protection of a page because even though you are [18:40.700 --> 18:45.900] changing the protection of the page on the first level address translation, this memory [18:45.900 --> 18:51.740] protection does not propagate to the second level address translation and it's there that the [18:51.740 --> 18:55.680] protection is enforced. So if you have read write, it's going to be read write even if you [18:55.680 --> 19:00.860] change the protection on VTL zero. And if it's read execute, it's going to be read execute [19:00.860 --> 19:06.500] even if you try to change the protection on VTL zero. And with KDP, you have another [19:06.500 --> 19:13.340] problem because certain area of memory, data section of memory are protected by this KDP [19:13.340 --> 19:19.480] that enforces that the page is read only. So for example, G option is protected that way. So [19:19.480 --> 19:23.880] now even if you have an arbitrary read write and the page should be read write, it's actually [19:23.880 --> 19:29.960] read only so even if you have it, you can't change G options to zero anymore. So what is the [19:29.960 --> 19:35.820] strategy around this? Well, luckily someone very smart, smarter than me of course, [19:35.820 --> 19:40.440] developed a technique which is called page remapping. And page remapping attack [19:40.440 --> 19:47.700] exploited, it's not a bug, it's like a limitation of KDP. KDP doesn't enforce how pages on the [19:47.700 --> 19:55.560] guest are translated to pages on the host system. Meaning that not enforcing that, what I can [19:55.560 --> 20:02.320] do, one possible thing I can do is I can copy over my, the content I want to modify to [20:02.320 --> 20:11.740] another page, I can modify the page structures on VTL zero to make it point to a read write page [20:11.740 --> 20:18.900] on the hypervisor level. And this will effectively make my page read write. And I can modify [20:18.900 --> 20:27.180] then the content. So Satoshi Sanda developed a proof of concept and used a null byte page to [20:27.700 --> 20:37.420] nullify DSC in exact this way. Now this is also usable for executing arbitrary code. And we [20:37.420 --> 20:43.960] have two main strategies for executing arbitrary code. Even if HBCI is enabled. So this [20:43.960 --> 20:55.100] depends a lot on the Intel CPU level. So if you have any CPU that is before Tiger Lake, before [20:55.100 --> 21:01.400] 11th generation, you can still use ROP because this kind of CPU does not support chat. So you [21:01.400 --> 21:05.880] can use kernel forge. Kernel forge is a technique implemented firstly by Crash and also [21:05.880 --> 21:16.020] discussed by Conor McGar in a blog post. And it uses a thread and a dummy event to modify the [21:16.020 --> 21:24.420] thread kernel stack at run time. Meaning that it will replace frame on kernel side of a [21:24.420 --> 21:30.960] thread to make it execute a ROP chain on return. Executing arbitrary code. And on, if you [21:30.960 --> 21:37.620] instead you have a CPU that is before 12th generation, you can use the page remapping attack [21:37.620 --> 21:44.700] as I said, uh, that abuses MULK. Now why before 12th generation? I can say, actually I [21:44.700 --> 21:50.060] should say a CPU before 12th generation and before Windows, and a version of Windows before [21:50.060 --> 22:00.260] 24H2. Because as I said, Windows 11 24H2 and supports Intel VTRP that is a killer exactly for [22:00.260 --> 22:05.700] this kind of attack, for page remapping attack. So it avoids any user from being able to [22:05.700 --> 22:14.980] redirect a page from VTL zero to remap to another page in the OS system. Now, and what about [22:14.980 --> 22:21.500] if we have something, what about if we have something, uh, more? Um, I actually, I'm [22:21.500 --> 22:26.480] actually exploring some other technique for trying to bypass HVCI but currently these are the [22:26.480 --> 22:32.440] only way. I thought that large pages could also be used for this kind of thing but apparently [22:32.440 --> 22:40.960] it's not going to, it's not really working. So, but we still, even if we can do stuff, we still [22:40.960 --> 22:48.940] need to load a vulnerable driver to execute any of these strategies. So if we want to load a [22:48.940 --> 22:52.860] vulnerable driver we need to be aware that there is something called driver block list that [22:52.860 --> 22:57.960] will probably prevent us from loading a known vulnerable driver on Windows. Now the [22:57.960 --> 23:03.220] driver block list is a black list and of course it has some problems that were identified by [23:03.220 --> 23:09.020] Will Dorman and Yarden Shafir, another researcher. The block list by itself is just a [23:09.020 --> 23:14.520] collection of hashes and file names and file version that are supposed to be not loaded on [23:14.520 --> 23:20.580] Windows and if the driver block is enabled it will prevent normal, uh, normal vulnerable [23:20.580 --> 23:29.000] drivers to be loaded but it has a measure flow. The coverage is ridiculous. So I, I made a [23:29.000 --> 23:34.040] bit of, a little script to check how many, uh, how many drivers were blocked from the load [23:34.040 --> 23:41.620] driver projects. Uh, this just check the, um, the ashes but it's, it's, it's really, it's [23:41.620 --> 23:46.580] really ridiculous. The coverage is really ridiculous. And also it can be disabled by admin. [23:47.460 --> 23:51.320] Uh, of course when we bypass the block list we need to be aware that there is also the [23:51.320 --> 23:55.980] serial, the serial. So even if a driver is not in the block list it doesn't mean that the [23:55.980 --> 24:00.800] certificate is still valid. So there are other, there are other, there are, there are other [24:00.800 --> 24:08.180] things that may prevent us from loading a, a vulnerable driver on Windows. And now to the [24:08.180 --> 24:12.620] meat of this presentation, what can we do to load a malicious, a vulnerable driver on [24:12.620 --> 24:17.860] Windows using this like unusual technique. So let's talk about, a bit about the anti-object [24:17.860 --> 24:23.640] manager. So the anti-object manager is a subsystem on Windows that provide access to [24:23.640 --> 24:30.620] resources, uh, using a name value approach. It's not entirely correct but it's the most, [24:30.620 --> 24:36.960] it's the most accurate, the simplification. Uh, it provides access to these objects using a [24:36.960 --> 24:45.280] unified API. And uh, it like every object is, is, is uh, it can be indexed by using a name. [24:45.280 --> 24:52.240] Can be recovered using a name. And these names are uh, categorized in uh, in categories [24:52.240 --> 24:58.500] that we call namespaces. Now, uh, you probably already seen the uh, object manager in [24:58.500 --> 25:03.680] WinObject, sees internals. And you can see a graphical representation of the object [25:03.680 --> 25:10.360] manager. So you have all these objects with the type associated. And uh, you have the name [25:10.360 --> 25:17.260] categorized in namespaces. Now usually uh, when you, this is actually used um, this [25:17.260 --> 25:21.900] categorization is used because any namespace has a certain accessibility. So if I want for [25:21.900 --> 25:29.640] example to make uh, an object available in, to the Win32 layer, I usually use a sim link that [25:29.640 --> 25:36.500] connect the global, which is the global um, namespace to the specific object I want to, I [25:36.500 --> 25:43.040] want to connect it with. And this is what you usually do even with drivers uh, for example. [25:44.520 --> 25:52.420] Now, the empty object manager uh, is in uh, of course uh, provides access to object to other [25:52.420 --> 25:58.240] subsystem like the IOManager, the process manager, the memory manager, et cetera. And [25:58.240 --> 26:06.300] whenever, whenever an object of type file is uh, is accessed by the IOManager, the IOManager [26:06.300 --> 26:12.540] will immediately check the file object and will dispatch it to the relevant driver that is [26:12.540 --> 26:20.540] meant to handle that specific file object. Now, the NTFS driver manage the NTFS file system. [26:21.060 --> 26:27.060] What kind of file system is the NTFS file system? So the NTFS uh, NTFS is a complex file [26:27.060 --> 26:32.300] system. Uh, it was always designed by Microsoft for extensibility and to support different [26:32.300 --> 26:38.220] kind of other file systems like FAT32 et cetera. And the main thing that I want you to [26:38.220 --> 26:43.640] memorize for now is that every file on Windows is a set of attributes of course and every file [26:43.640 --> 26:48.220] has at least one stream associated. So every file on Windows is actually, can actually be [26:48.220 --> 26:57.080] referred to as a triple. It's a triple, triple, triple. So um, so and um, and usually you [26:57.080 --> 27:02.100] have, oh, I don't know what I'm seeing. So usually you have the file name, the stream type uh, [27:02.100 --> 27:05.740] the stream name and the stream type. Every file has at least one stream. So if you [27:05.740 --> 27:10.920] create a file with just the file name, you are immediately, it means that the other, the [27:10.920 --> 27:16.040] stream name and the stream type are defaulting back to something. For files is the data [27:16.040 --> 27:21.860] stream and for directories you have the index allocation stream. But they are usually [27:21.860 --> 27:28.040] always a triple. Uh, now another thing I want you to memorize is the concept of reparse [27:28.040 --> 27:33.880] points. Because this was meant for extensibility, uh, NTFS supports a lot of type of reparse [27:33.880 --> 27:39.380] point. The main and common, the most common reparse points that you will see in NTFS are [27:39.380 --> 27:46.740] three. Although there are like 20 or 30 different reparse tags. So reparse types. So [27:46.740 --> 27:51.160] reparse point types. So the main, the most common are junction points that points [27:51.160 --> 27:56.220] directory, that links directory to directories. Uh, mount points that links directories to [27:56.220 --> 28:02.340] drives to, to mounted drives and symbolic links that link files to other files. So this is [28:02.340 --> 28:07.940] not to be confused with link file. Link file are regular files. They have a data stream and [28:07.940 --> 28:13.360] they are just regular files. They need to be parsed to access to another location on the [28:13.360 --> 28:21.160] file system. Uh, indeed symbolic links are an NTFS features. Meaning that they are just, [28:21.160 --> 28:27.400] they are just literally link on NTFS. They link directly on NTFS uh, to another file. And [28:27.400 --> 28:32.860] usually a reparse point is always a reparse tag which in this case is symbolic link and [28:32.860 --> 28:43.100] reparse data that will actually point to the real file that it's pointed to. Now about CDFS. CDFS [28:43.100 --> 28:50.120] is a way more um, is a way simpler file system. It's, it just, it just comprises uh, root [28:50.120 --> 28:55.480] directory and then it has directory and then it has directory entries and file entries that [28:55.480 --> 29:02.280] are associated and are always parsed from the root directory. Is um, is an implementation of [29:02.280 --> 29:14.620] the ISO 9667s and 960 and um, the important thing is that the CDFS file system, the CDFS file [29:14.620 --> 29:21.720] system uh, is also, also apply, applies to optical disk as much as applies to ISO files. So ISO [29:21.720 --> 29:27.500] files are a virtual implementation of the CDFS file system. Now just to give a bit of [29:27.500 --> 29:32.920] difference to the NTFS, of course CDFS does not support a reparse point, does not support a lot [29:32.920 --> 29:37.280] of things that are supported by NTFS but also it has a completely different threat model. So [29:37.280 --> 29:44.960] NTFS supports rich permissions. So it has an ACL and the ACL is associated with different ACL [29:44.960 --> 29:50.560] entries, access control entries which define what, what can be done on each file by each user [29:50.560 --> 29:57.360] in the system. For CD file system, this is not a problem because the content on a CD is supposed [29:57.360 --> 30:02.960] to be, is supposed to be immutable. So everyone has access to a file system. If you mount a [30:02.960 --> 30:09.800] drive, anyone, an admin, a regular user, anyone has access to the mounted files. To the files on [30:09.800 --> 30:18.560] the mounted drive. And yeah, as I said before, the CDFS driver as much as NTFS driver [30:18.560 --> 30:25.840] communicates with the IOM manager, the IOM manager has a request to access a file and after [30:25.840 --> 30:32.820] passing through the filter manager, it provides access to the required NTFS or CDFS driver [30:34.020 --> 30:40.260] accordingly to what is the device driver associated with the file object. Now when you load [30:40.260 --> 30:47.080] an ISO on Windows, what it, what it, the CDFS driver will automatically load the content of this [30:47.080 --> 30:54.480] ISO file using the CD common read. Now one thing that I want to stress out here is that an ISO [30:54.480 --> 31:02.180] file in comparison with a CD, with an optical CD, an ISO file is mapped in physical memory [31:02.180 --> 31:09.800] somewhere. So somewhere this ISO file is mapped in memory. So this creates some problems and we'll [31:09.800 --> 31:15.860] see what exactly. So when you try to access a file, what you end up doing is you end up [31:15.860 --> 31:24.740] calling the NTCC copy read. Now this points to a file object. We will describe the file object [31:25.320 --> 31:32.420] and just exploring a bit with where this file object were located, we started noticing that the [31:32.420 --> 31:39.260] physical address associated with this file object were always the same. So if you remap one of [31:39.260 --> 31:45.700] this file object in a read write page and you override the content of this file object, the file [31:45.700 --> 31:53.660] object will be, will flush the content of the modified file back to the physical memory where the [31:53.660 --> 32:02.120] ISO was loaded. This means that it's not read only at all. And so we developed this IOCDFS lib [32:02.120 --> 32:10.980] that you can use to just modify any content on any ISO file that was mounted in the system. I [32:11.400 --> 32:18.340] want to, I want to specify this doesn't work for CD, real CD drive. It just works for ISO files [32:18.340 --> 32:25.660] and the reason is potentially that it's because they are mapped on physical memory when they are [32:25.660 --> 32:33.400] loaded the first time. Of course for caching. Indeed they are more, it's easier to get a file on [32:33.740 --> 32:41.200] an ISO in comparison with a CD. Now I'm not going to go through this, but there are some [32:41.200 --> 32:48.380] limitation on what you can change on the file. So if you overwrite over the file sides, the [32:48.380 --> 32:54.140] real file sides, not the file sides on disk, but the virtual sides, it's the change is not [32:54.140 --> 32:59.580] going to, it's not going to appear. So you can, you can, you can change less, but you can [32:59.580 --> 33:06.180] change more. And if you write, you try to write over the file on, over the file sides on disk, [33:06.180 --> 33:12.940] you end up actually breaking some stuff. So your program will crash probably. And you're [33:12.940 --> 33:16.780] going to have problems. So these are the margin tolerance where, where you can actually [33:16.780 --> 33:24.420] replace the file. Now, but this is cool, but it's abusable. Now yeah, it's abusable. There are [33:24.420 --> 33:29.840] some use case scenario where we can actually abuse it uh, for a lot of different means. But [33:29.840 --> 33:35.420] one of the means is hide the fact that we have a driver on an ISO. For example, we can load [33:35.420 --> 33:44.680] an encrypted blob on an ISO and then we can just modify it after the ISO was emulated. So we [33:44.680 --> 33:50.100] found another thing that we could abuse and this is um, I don't know how much it's, this is [33:50.100 --> 33:58.420] known, but like if we had a file on disk and we try to link, we try to use the same name to, to [33:58.420 --> 34:03.960] create a link, of course the file is going to say, no, I'm not going to use this name because [34:03.960 --> 34:11.720] it's already here. But for some reason, if we specify the link name with a stream name [34:11.720 --> 34:17.120] associated to it, it will create a reparse point for the file. So this will create a reparse [34:17.120 --> 34:23.380] point for the file that will overshadow the data stream that is present on the file on disk. Now [34:23.380 --> 34:29.180] this means that at this, at this time, after I created the reparse point, the file, the original [34:29.180 --> 34:35.620] file, the original ATXT is still there, but it's not going to be, no one is going to be able to [34:35.620 --> 34:42.400] find it unless I delete the reparse point. And this is abusable. Why? Because well, I can [34:42.400 --> 34:49.480] create an ISO and I can use this as trusted installer, I need to elevate my privilege to [34:49.480 --> 34:56.440] trusted installer, and I can use this to redirect the, a file, a driver file on C, Windows [34:56.440 --> 35:05.740] system 32 to something that is on the ISO, for example. But this has a problem, the driver, of [35:05.740 --> 35:10.060] course the driver file, the driver location, the image loaded is going to be, is going to show [35:10.060 --> 35:18.040] that I'm loading something bad. So I be a bit more smart, a bit smarter, I create another ISO and [35:18.040 --> 35:27.700] this point I will use a current directory structure. So now I, and I, I place W, of course I [35:27.700 --> 35:34.880] can place whatever driver I want here, here for example there is WinIO. And I do the same [35:34.880 --> 35:41.840] thing, but still, I have a problem, because when I load the driver, it still say, okay, this [35:41.840 --> 35:47.240] sounds correct, but there is still, I mean, it's still saying, listen, you are loading from an [35:47.240 --> 35:52.560] ISO file. You're not loading from the system blue directory, you're loading from just an [35:52.560 --> 36:00.680] external drive. You're trying to fool me, you didn't manage to though. Then, this is just to [36:00.680 --> 36:06.020] show that the file is still there. So if I, if you delete the reparse point, the original file is [36:06.020 --> 36:13.340] still there. Okay, just to, just to prove the point. But then we notice another thing. So a [36:13.340 --> 36:18.860] direct NTFS link is not enough to bypass, to fool the, the load driver event. But then we [36:18.860 --> 36:24.300] notice another thing. If we go to the empty object manager, we notice that every driver is [36:24.300 --> 36:31.220] actually loaded, not using C Windows system 32, but is loaded using system root. System 32 [36:31.220 --> 36:39.600] driver and the name of the driver. What is this system 32? The system 32 is a symbolic link, and [36:39.600 --> 36:45.660] not an, not an NTFS symbolic link, it's an NT symbolic link, uh, that is pointing to the device [36:45.660 --> 36:52.720] that I use for booting. In my case, it's device RDS volume 3. But it's pointed to by the boot [36:52.720 --> 36:59.300] device, right? But this means, and if I inspect the boot device, I notice that I can actually [36:59.300 --> 37:06.360] delete this symlink. So this is actually a permanent symlink, meaning that it's been [37:06.360 --> 37:12.400] artificially created to have a ref count of one, but I can make it, I can, as system, I can make [37:12.400 --> 37:18.400] it temporary, load, like artificially lowering the ref count to zero again, and then I can [37:18.400 --> 37:23.880] delete it. So what can I, what can I do with this? I, I can obtain system privileges, I can [37:23.880 --> 37:30.200] back up the original boot device, I can replace the boot device symlink with the ISO, and [37:30.200 --> 37:36.220] then I can restart the service and see what happens. And what happens is that it works. But [37:36.220 --> 37:43.520] the driver load event still shows that I'm loading from an ISO. So still I wasn't able to [37:43.520 --> 37:53.870] fool it. And another problem is that if I inspect the driver in system informer or a [37:53.870 --> 37:59.230] similar tool, I've noticed that the driver is showing, for example, a missing description. [37:59.230 --> 38:07.330] It's showing stuff that indicates that I loaded another driver. What if we swap the drive [38:07.870 --> 38:12.850] letters? What if I do a drive swap for, this is something that nobody will ever think of [38:12.850 --> 38:18.330] doing, and there is a reason for that. Because if you try to swap the drive letters, your [38:18.330 --> 38:23.430] program, your, your system will probably crash at a certain point. There is nothing, but if [38:23.430 --> 38:30.450] you do it for just a second and you keep everything consistent so you don't just remove [38:30.450 --> 38:36.750] the letters, but you swap into other letters, it actually might work. So the, I'm not [38:36.750 --> 38:41.610] showing the screen shot because I'm showing you a video afterward, but the, the technique [38:41.610 --> 38:48.530] is this. We mount an ISO with an encrypted blob, we just respect the directory structure, we [38:48.530 --> 38:52.970] change the boot device to CD-ROM, we swap drive letters, we load the driver, we restore [38:52.970 --> 38:57.990] immediately the drive letters, we restore the boot device, and then we can at that point, we [38:57.990 --> 39:03.770] can use, we can abuse the driver that has loaded in memory even if we unmount the ISO file. [39:06.570 --> 39:12.650] Now what about using other techniques? Well, I, I can use other techniques uh to, to load [39:12.650 --> 39:18.690] the malicious driver uh but in this case, for example, I can use uh all the partition that [39:18.690 --> 39:25.410] is assigned to the transactional file system. It's not supposed to be accessible by any [39:25.410 --> 39:32.290] user. It's not supposed to be writable, but we discovered that if you access this kind of [39:32.290 --> 39:37.590] location with the additional, with, with the, with uh, with the required permissions, in [39:37.590 --> 39:43.090] this case, backup intent, say restore, say backup privilege, a maximum file, maximum [39:43.090 --> 39:49.630] allowed as uh, as uh, as access right, you can actually override this. You can actually [39:49.630 --> 39:54.970] access these locations and you can actually write files on them. So, and this is a proof, of [39:54.970 --> 40:00.670] course, where I actually am writing, I'm writing on uh the transactional file system uh [40:00.670 --> 40:07.210] locations. Is there any benefit? I don't see any benefit in doing it. Uh, it can just give [40:07.210 --> 40:12.750] you an additional way of exploiting the same vulnerability in, in other ways, not using an [40:12.750 --> 40:20.210] ISO. So, let's demo it. So, Windows 11, HVCI is enabled. Uh, I have a simple load of a [40:20.210 --> 40:35.280] driver and I hope, uh, I hope it actually, because this doesn't actually, oops, oops, I did [40:35.360 --> 40:45.280] a mistake. Okay. So, it doesn't show, I don't know how to make play. Uh, it doesn't show the [40:45.280 --> 40:57.420] right, uh huh. Okay. That seems it works. Yeah. So, okay, here we are seeing that we are [40:57.420 --> 41:05.860] targeting the AALP SSI GPO is uh an Intel driver. And we are loading our driver. We are [41:05.860 --> 41:10.740] switching everything and we're loading the driver. Now, the driver has been loaded. The name is [41:10.740 --> 41:15.920] that and if you can see, honestly, I would, I would challenge to spot the difference. The [41:15.920 --> 41:21.860] description is the right one. But, and if you try to point to the what, what file was loaded, it [41:21.860 --> 41:29.220] will actually open the right directory. But indeed, we loaded another. You can, you can [41:29.220 --> 41:39.400] actually spot it from the sides. From the sides. It's 28 kilobyte which is the size of WinIO. And [41:39.400 --> 41:44.180] you can see also from the hash, that is the same hash of WinIO, which is a vulnerable driver [41:44.180 --> 41:49.680] that is not currently blocked by Microsoft block list. We can do another attempt, this time on [41:49.680 --> 41:57.440] Windows. I don't know if there is anything I'm showing. Yeah. I'm, I'm proving that it's WinIO [41:57.440 --> 42:07.320] here. So you will see that there is the WinIO handle uh showing up in devices and when I, we [42:07.320 --> 42:18.240] get there, bit of faith. So we have WinIO loaded. Now, when I unload the driver, that is not [42:18.240 --> 42:29.820] unloadable usually, WinIO disappears. So it was WinIO all along. But it doesn't show up [42:29.820 --> 42:35.840] anywhere practically. And we fooled the driver loader into thinking that we actually loaded a [42:35.840 --> 42:46.440] driver on C Windows system 32 as, as, as it was normal. Now, on Windows 10 or when HDCI is not [42:46.440 --> 42:54.280] enabled, we can just strictly integrate it with KDU for example. Same technique, same driver as base [42:54.280 --> 43:12.100] for exploitation. I still need to, no. Come on. Yes. So still driver jack is executing, arrives. It [43:12.100 --> 43:18.800] overwrites the content in memory because the driver is encrypted as I said on the ISO. And then [43:18.800 --> 43:24.320] it just loads the drive and straight executes KDU. The vulnerable driver was already loaded [43:24.320 --> 43:29.620] because we loaded to the driver, with the driver jack technique. The name is WinIO and we can [43:29.620 --> 43:38.840] execute our unsigned code on Windows. Now, of course, if you want to execute with HDCI enabled, [43:38.840 --> 43:44.700] you need to use one of the other thing that I showed before. CandleForge, uh, Malk, or [43:44.700 --> 43:53.440] unless, if, if, or, or you can use, or you can just disable HDCI altogether. So, the full chain [43:53.440 --> 44:01.680] that we used was, we weaponized the step 7 installation media. Um, in, in this way initially, we [44:01.680 --> 44:08.220] used the trial process immediately because as I said, uh, the set up of the step 7 [44:08.220 --> 44:14.800] installation media uses multiple process to install. So we could blend in with an additional [44:14.800 --> 44:21.200] process. We rewrite and execute an additional file so we, there was no malware on the ISO except [44:21.200 --> 44:27.260] of a minimal DLL used for site loading. And then what we do is we use driver jack, we, we [44:27.260 --> 44:33.760] execute, uh, we install the full candle rootkit. Uh, we were targeting Windows 10. HVCI was not [44:33.860 --> 44:38.700] a problem in this case. And, and then we just keep going with additional, with additional [44:38.700 --> 44:48.760] compromise step. So, portability, we have integration with KDU, uh, if HVCI is disabled. If it's [44:48.760 --> 44:53.940] enabled and you have, uh, inter-K chat not supported, you can use CandleForge as I said. If [44:53.940 --> 45:02.980] it's, um, if HVCI is, HVCI is, HVCI is, oh my gosh, is, is hypervisor protected coding, [45:02.980 --> 45:08.360] enforce code, code integrity is enabled and you don't have Intel DT but you have inter-K chat [45:08.360 --> 45:17.180] can use mark. Otherwise, well, the, the best chance so far, uh, is to just, uh, disable code [45:17.180 --> 45:24.380] integrity and ask for a reboot. Um, because there is no currently, there is not currently a [45:24.380 --> 45:29.580] technique. As I said, I, I mistakenly believe that you could actually abuse large pages for [45:29.580 --> 45:35.380] it. I'm still trying to check it if, if it's possible, but it doesn't look like it's working [45:35.380 --> 45:43.440] fine. And as key takeaways, I mean, you can download the box, uh, the, the, for driver jack [45:43.440 --> 45:50.200] is, is already, is already public. You can, you can go and take a look. Um, for like [45:50.200 --> 45:56.820] detection, as detection advice, I would always try to detect if, uh, someone is escalating [45:56.820 --> 46:02.200] privileges to system or trusted installer using no means. Uh, monitor for drive letter change [46:02.200 --> 46:09.820] to just prevent this trick from, uh, bypassing detection. Uh, of course, monitor for changes [46:09.820 --> 46:15.600] in the anti-object manager, especially for global links. Uh, keep your hardware up to date is [46:15.600 --> 46:21.700] very important because as we've seen, the more we go to modern CPUs, et cetera, the, the [46:21.700 --> 46:27.860] more difficulties to exploit this kind of bugs. And then, and then there is the, one of the [46:27.860 --> 46:32.440] detection opportunity, which is the probably best, is when there is a drove, a driver load [46:32.440 --> 46:38.740] event, implement an hash cross check. So there is an hash present on the driver load event. [46:38.780 --> 46:43.260] The only thing you need to do is going on the file list, on the file path that is, was, that [46:43.260 --> 46:49.540] was loaded, perform, like calculate the check at run time and then compare the, the hashes. [46:49.540 --> 46:54.740] The hashes is, are not possible to fool. So, uh, if the hashes are not matching, it means [46:54.740 --> 47:00.520] that something happened that was bad. So another driver was loaded in place of the original [47:00.520 --> 47:06.140] one. And that's it. Thanks a lot for, for attending.