WEBVTT

00:01.820 --> 00:02.420
Okay.

00:02.420 --> 00:03.380
Hi there.

00:03.380 --> 00:05.780
Thanks a lot for sticking up with us.

00:06.080 --> 00:19.840
Today I'm going to speak around about driver jack, which is an unusual technique to load the driver on Windows 11, abusing NTFS features and CDFS bug, I'd say.

00:20.420 --> 00:23.000
So just before starting, a few words about me.

00:23.000 --> 00:23.980
I'm Alessandro Magnozzi.

00:23.980 --> 00:26.580
I work for BSI, British Standards Institute.

00:26.820 --> 00:38.080
I mainly do research, but a huge part of my daily business is consulting in adversary simulation, device security and AppSec.

00:38.080 --> 00:40.860
I go on Internet with the name klatsvirus.

00:40.860 --> 00:44.400
You can reach me out on GitHub or Twitter.

00:44.700 --> 00:46.660
Feel free to reach out.

00:47.480 --> 00:54.240
Now, just before starting, I'm going to just give a bit of information about this project.

00:54.240 --> 01:00.820
This project was started in 2022 with Jonas Lake from Secret Club.

01:01.260 --> 01:06.320
We started working on a POC to abuse ISOs to load malicious drivers on Windows.

01:06.380 --> 01:11.300
Then we completely forgot about that for at least one year because I was working on other stuff.

01:11.300 --> 01:17.480
And then in 2023 I had an engagement that supported the development of this technique a bit further.

01:18.360 --> 01:23.520
Now, the engagement was a bit like it was an OT engagement.

01:23.520 --> 01:33.120
It was a deployment and the main aim of the engagement was to deploy a kernel rootkit on an OT workstation.

01:33.460 --> 01:48.060
Now, regardless of the engagement, the engagement was pretty well and we found ourselves in a situation where we could tamper ISO files that were distributed to machines via an update catalog.

01:48.700 --> 01:59.420
So this gave us a motivation to read, resume the research that we were doing in 2022 and we tried to understand if we could develop it further.

01:59.420 --> 02:04.360
Now, we didn't know exactly what to expect from the malware that we were generating.

02:04.820 --> 02:12.680
We just know that we wanted something to backdoor an installer, present on an ISO and then we want to weaponize it in the best way possible.

02:12.680 --> 02:21.440
Of course, ISOs have been weaponized for years right now for their ability to bypass multi W but this was not really what we wanted to do.

02:21.440 --> 02:25.220
We didn't want to just provide an ISO to our customer.

02:25.220 --> 02:28.980
We had in the position of weaponizing an ISO.

02:29.520 --> 02:48.680
And then we just wanted to execute some code and like deploy some vectors around, I don't know if you, if you are aware, always aware about the, what Stuxnet was doing back in 2011 but we wanted to achieve something like backdooring DLL on different softwares to intercept communication,

02:48.680 --> 03:02.900
intercept code going and arriving from PLCs and doing stuff like that with using side loading or DLL proxying on certain specific DLL used by this kind of software.

03:03.460 --> 03:08.840
And the additional thing that we wanted to achieve was deploying a kernel driver on these boxes.

03:08.900 --> 03:32.120
Now the, we started and one example of the ISOs that we end up backdooring was step 7 installation media and the reason for this is that it's naturally deployed by using ISO files and it's pretty difficult to backdoor because step 7 utilized a bootstrap to launch the installer meaning that,

03:32.120 --> 03:53.380
meaning that it actually performs an integrity check on the content of the disk before actually launching the installer and it has two layer of checks so you need to, you need to, if you want to execute malicious code using the installer, you need to find a way to not tamper with any existing DLL and any existing executable on the disk.

03:55.480 --> 04:13.480
Talking about deploying the Windows root kit, a Windows root kit, usually when you need to deploy a root kit on Windows, a kernel root kit, a kernel driver on Windows, what you end up doing is you call create service, you create a service for the service driver and then you start the service with the driver.

04:13.480 --> 04:18.540
Of course one requirement for this is that the driver file that you are loading needs to be on disk.

04:19.540 --> 04:30.420
Now this can be done manually by manually placing a registry key in the file system and then calling antiload driver to load the driver.

04:30.420 --> 04:43.620
This is a bit more stealth way of loading a driver and it's in the name of this thing is Windows log event evasion because it doesn't generate the event that is usually created when you create a service and start the service.

04:43.840 --> 04:48.340
But of course there is something else that sticks up.

04:48.340 --> 05:09.600
So like there is every time you load the driver regardless if you are using the start service, the create service or you use directly the antiload driver function, you generate an event which is the load driver event that is a sysmon event and event six that provides all the information about the driver you loaded.

05:09.600 --> 05:18.280
So even if it's more stealthy, there is still this that appears as an event on the Windows log.

05:18.500 --> 05:24.560
So we wanted a technique that would help us bypass this event load driver as well.

05:25.300 --> 05:30.560
And so we ended up creating four libraries framework.

05:30.560 --> 05:40.220
I mean two of them are the core of this presentation which is IOCDFS lib and driver jack that will be abused to load a driver on Windows.

05:40.220 --> 05:42.700
The other two are collateral projects.

05:42.980 --> 05:45.060
They were not supposed to be part of the project.

05:45.060 --> 05:47.060
They just are RPC exec.

05:47.060 --> 05:49.460
I will just talk about it briefly.

05:49.460 --> 06:01.380
RPC execs is a less common way to execute on Windows on local or remote processes without requiring RX memory to be allocated in target process.

06:01.380 --> 06:11.980
And interleaver is a it became a sort of P manipulation library that we cannot share completely but I will share a simple block which is coupling P.

06:11.980 --> 06:16.740
You can find coupling P which is coupling preserve on my GitHub page.

06:16.740 --> 06:19.320
Now coupling P is a short version of interleaver.

06:19.320 --> 06:29.100
It doesn't manipulate completely the P file but it's an extension to what Nick Lenders implemented back in 2020.

06:29.660 --> 06:31.400
I don't remember exactly.

06:31.660 --> 06:43.300
So coupling is a framework that takes target DLL, clone the export at this table and include it in DLL that you developed.

06:43.320 --> 06:51.240
Now this is used usually for DLL side loading using the DLL main function as main entry point for the DLL.

06:51.240 --> 06:54.100
Now the problem is that this process is destructive.

06:54.140 --> 06:59.180
So if you have some exports in your payload DLL, these will be erased.

06:59.180 --> 07:07.100
So coupling P just solves the problem and it just preserves the existing export at this table and just add the forwards afterward.

07:07.100 --> 07:08.020
That's it.

07:08.020 --> 07:11.160
Not really a difficult project.

07:11.800 --> 07:22.620
RPC proxy invoke instead or RPC exec is a general library that we implemented to as I said is to execute code on local or remote processes.

07:23.340 --> 07:26.320
It's borrowed by browser exploitation.

07:26.320 --> 07:30.960
It abuses the NDR server call to execute arbitrary calls.

07:31.060 --> 07:41.480
It doesn't require RX memory and we also implement it in a way that it doesn't require a valid RPC binding handle for uh for execution.

07:41.480 --> 07:44.160
This is there is a reason for this.

07:44.160 --> 08:03.380
We wanted something that we could use to execute arbitrary calls in any server, even in any service, in any processes, even if it wasn't actually using RPC and we wanted to avoid maintaining like we wanted to be able to erase tracks if we wanted and using this technique we can load RPC,

08:03.380 --> 08:14.160
initialize it remotely, execute our stuff and then just get rid of RPCRT4 completely by freeing the library and no traces will remain in the service.

08:14.700 --> 08:15.840
The process.

08:16.420 --> 08:17.920
The code is there.

08:17.920 --> 08:21.940
There are also some demos around that you can check.

08:21.940 --> 08:23.300
It's just for functionality.

08:23.300 --> 08:40.100
The project code is implemented and it has some not limitation but is implemented nerfed meaning that it's not using for example code pattern search for uh for locating the required uh the required entry point in RPCRT4.

08:40.260 --> 08:50.620
RPCRT4 changes over time a lot so you need to adjust it to depending on your version, on your Windows version or you need to implement yourself the code that actually do the pattern searches.

08:51.120 --> 08:52.240
Previous research.

08:52.240 --> 09:03.740
So when it comes to the core of the research or loading a driver on Windows, you have a few ways to load a valid driver on a Windows to execute unsigned code on Windows.

09:03.740 --> 09:06.240
You can either, actually there are four.

09:06.240 --> 09:14.060
So the first one was implemented by Gabriel Landau not long ago uh by exploiting a new vulnerable class that is false file immutability.

09:14.060 --> 09:20.980
I didn't put it in the slides just because it wasn't available when I started doing this research but go check it out because it's an incredible research.

09:21.380 --> 09:26.760
But the standard way to load unsigned code on Windows are either you, it's not unsigned.

09:26.760 --> 09:28.280
You load signed code.

09:28.280 --> 09:31.360
So you have a kernel driver that you want to load.

09:31.360 --> 09:38.280
You join the Microsoft developer program.

09:38.420 --> 09:42.180
Microsoft sign your own driver and you're good to go.

09:42.180 --> 09:44.160
You can use a fake signature.

09:44.160 --> 09:57.940
So before 2015, Microsoft allowed kernel drivers signed with a valid code signing certificate and cross signed by an EVCA certificate to load on Windows.

09:57.940 --> 10:18.060
So if you have a certificate that was expired before or issued before 2015 and you have a leaked EVCA certificate, you can still use, you can still set up your own fake timestamp server and you can back sign one of these drivers and you can generate a signature that is expired.

10:18.060 --> 10:21.980
So signed certificate but still valid to load on Windows.

10:22.360 --> 10:27.000
The third and last technique was using a vulnerable driver.

10:27.000 --> 10:34.480
Now as you can understand, we didn't have any kernel driver on the developer program.

10:34.480 --> 10:44.440
We didn't have any EVCA certificate leaked and unknown that we could use so we went to the route of using a vulnerable driver to load our unsigned code.

10:44.440 --> 10:57.340
Now of course we then started the research we want for abusable vulnerable drivers and we found four of them, two of them we just report to the vendors because they were not useful to us.

10:57.340 --> 10:59.480
Two of them we kept them.

11:00.100 --> 11:06.960
Now usually when you want to load unsigned code on Windows, you search for of course there are a lot of vulnerabilities affecting vulnerable drivers.

11:06.960 --> 11:08.900
Buffer overflow, user after free, there are a lot.

11:08.900 --> 11:12.400
Not just this that I included here.

11:12.400 --> 11:22.480
But usually what you want is to have a stable physical memory read write, virtual memory read write or for example unprotected MSR access.

11:22.480 --> 11:25.140
MSR stands for model specific register.

11:25.140 --> 11:29.840
Now the first, this was abused a lot in 2018, 2020.

11:30.460 --> 11:37.940
So when you have and it appears when you have an unrestricted code called to WRMSR.

11:38.260 --> 11:43.160
So there is a specific model specific register on Windows which is the well actually another Windows.

11:43.160 --> 11:44.200
It's not specific to Windows.

11:44.200 --> 11:54.640
But it's the IA32L star that contains on Windows the pointer to the system call dispatch function.

11:54.680 --> 11:59.960
So on before KPTI was introduced this points to KI system call 64.

11:59.960 --> 12:05.920
After KPTI mitigation, this points to KI system call 64 shadow.

12:05.920 --> 12:10.480
But regardless, this points to a dispatch function that is responsible to switch to

12:14.560 --> 12:22.180
from user mode to kernel mode and execute and dispatch to the relevant system call handler on kernel side.

12:22.180 --> 12:32.680
Now if you have unrestricted call to and you can override this register, what you can do is you can weaponize it to point to your user defined handler.

12:33.340 --> 12:38.060
And this is abused in MSR by Xerox from back engineering.

12:38.840 --> 12:40.540
Magnificent tool.

12:40.540 --> 12:41.980
I have to be honest.

12:42.260 --> 12:51.940
And this literally implements its own dispatch function that swap to kernel mode using the swap JS instruction.

12:52.180 --> 12:58.820
Disables maps map and executes arbitrary code stored in a user mode buffer.

12:59.680 --> 13:10.500
Afterward it uses ROP to, sorry, it uses ROP to restore maps map and restore the IA L32 L star.

13:11.500 --> 13:17.760
Now this, the other, the other vulnerable pattern that we have is arbitrary physical memory access.

13:17.760 --> 13:34.280
Now usually when this, this presents itself in two forms, either a call, a restricted call to ZW map your section or that can map whatever physical address in a linear address or by using MMAP IO space.

13:34.280 --> 13:37.160
Now the vulnerable pattern that we found the most was this.

13:37.160 --> 13:46.220
It's abusable, it's less abusable than ZW map your section because these actually provide access that you can't specify the access right.

13:46.220 --> 13:49.480
So you can't specify read right instead of read.

13:49.480 --> 13:52.080
And this usually is used for privilege escalation.

13:52.080 --> 14:03.780
So if you have a pattern that like this, so you have a call to MMAP IO space, IO allocate MDL and then MM build MDL for non-page pool and then MMAP lock page specific, specify cache.

14:03.780 --> 14:22.720
You have a pattern where you can actually uh, allocate page memory, page pool memory, sorry, non-page pool memory in a user mode buffer and using a technique known as proc scanning, you can identify e-process structure in the non-page pool and swap tokens around to achieve uh,

14:22.720 --> 14:24.060
privilege escalation.

14:24.700 --> 14:32.460
And then there is the prints of all other vulnerabilities uh, arbitrary virtual read, arbitrary kernel virtual memory read write.

14:32.460 --> 14:34.820
This presents itself in a lot of different ways.

14:34.820 --> 14:38.760
It can be a mem move, a mem copy, a ZW write virtual memory.

14:38.760 --> 14:41.640
It can be a direct pointer assignment.

14:41.640 --> 14:43.160
Uh, it can be whatever.

14:43.280 --> 14:59.180
Now this is used for a lot of different stuff uh, let alone bypass DSC for example or just mapping arbitrary stuff in memory, in kernel memory and this is heavily abused by tools like KDMapper or KDU to load your driver in memory.

15:00.040 --> 15:06.120
Now of course Windows doesn't like this uh, so they started introducing a lot of different mitigations.

15:06.140 --> 15:13.280
Since 2018 there was the introduction of uh, KBDI after the Spectre meltdown uh, attack.

15:13.280 --> 15:19.540
Uh, then they started introducing VBS, virtualization based security and started enforcing HVCI.

15:19.540 --> 15:23.520
After the HVCI they introduced KDP which we will see.

15:23.520 --> 15:39.320
And then they implemented the Microsoft uh, driver block list and afterward they started introducing support first for kernel chat control enforcement technology that uh, neutralizes ROP based attack.

15:39.320 --> 15:53.940
And then in like weeks ago uh, they announced that Windows 11 24H2 will support uh, Intel DTRP, redirection protection that kills another back class that we will gonna see like now.

15:53.940 --> 16:09.660
So VBS is uh, is really tough for uh, for exploiting vulnerable drivers because HVCI want to prevent you from abusing a vulnerable driver to load your VTL zero rootkit in memory.

16:09.660 --> 16:11.320
Now, how it works?

16:11.320 --> 16:25.140
Well, you have now the Windows low is, is, is runs on top of the hypervisor and uh, it divides the trust level in two trust level, the VTL one and VTL zero.

16:25.140 --> 16:29.120
Now your own kernel runs in VTL zero.

16:29.120 --> 16:43.780
Now this is the guest uh, operating system, the guest OS and what it, what it, what it, what it does is that this uses a normal uh, page structured approach to, for address resolution to map a physical address into a linear address.

16:43.780 --> 16:58.940
So you have your CR3, you have your um, you have your uh , PML4 entry, then you have your uh, page directory pointer entry, then you have your page directory entry, the page table entry and then finally you have your physical address.

16:58.940 --> 17:02.480
This physical address though is a guest physical address.

17:02.480 --> 17:16.980
Meaning that there is another layer, second layer access resolution that is, translates a guest physical address into a real physical address that is managed entirely by, by the hypervisor.

17:17.240 --> 17:20.440
Uh, using extended page tables.

17:20.440 --> 17:22.660
Now what is the problem for us?

17:22.660 --> 17:27.940
Is that before this was introduced, page protection was kernel based.

17:27.940 --> 17:32.720
So when you had control of kernel, you could do literally anything.

17:32.720 --> 17:44.800
So if you had a virtual, if you had a virtual read write, you could literally locate the digi options for example, that is the global variable and like managing the driver signal reinforcement and you could just override it.

17:44.800 --> 17:55.200
You could nullify it, load your unsigned code and then restore it of course because even though it was possible to modify it, it was still protected by kernel patch guard.

17:55.820 --> 18:00.160
Um, KPP, kernel page, yeah, patch guard.

18:00.260 --> 18:07.480
Um, but now, now it's different because now the enforcement is done in a hypervisor level.

18:07.480 --> 18:14.700
Now HVCI does two things and in together with KDP, that's a lot of problems.

18:14.700 --> 18:19.340
Like HVCI enforces that any page is either writable or executable.

18:19.340 --> 18:20.380
Can be both.

18:20.380 --> 18:28.880
So this is designed to um, to avoid you from writing your own code in kernel memory and then execute it.

18:28.880 --> 18:32.240
So and now this protection is enforced on hypervisor level.

18:32.240 --> 18:53.160
Meaning that you, even if you have your fantastic read write primitive, uh, you can't change the protection of a page because even though you are changing the protection of the page on the first level address translation, this memory protection does not propagate to the second level address translation and it's there that the protection is enforced.

18:53.160 --> 18:58.200
So if you have read write, it's going to be read write even if you change the protection on VTL zero.

18:58.200 --> 19:03.860
And if it's read execute, it's going to be read execute even if you try to change the protection on VTL zero.

19:04.560 --> 19:16.400
And with KDP, you have another problem because certain area of memory, data section of memory are protected by this KDP that enforces that the page is read only.

19:16.780 --> 19:19.220
So for example, G option is protected that way.

19:19.360 --> 19:28.240
So now even if you have an arbitrary read write and the page should be read write, it's actually read only so even if you have it, you can't change G options to zero anymore.

19:29.100 --> 19:31.200
So what is the strategy around this?

19:31.200 --> 19:38.820
Well, luckily someone very smart, smarter than me of course, developed a technique which is called page remapping.

19:39.000 --> 19:44.260
And page remapping attack exploited, it's not a bug, it's like a limitation of KDP.

19:44.260 --> 19:52.220
KDP doesn't enforce how pages on the guest are translated to pages on the host system.

19:52.300 --> 20:14.300
Meaning that not enforcing that, what I can do, one possible thing I can do is I can copy over my, the content I want to modify to another page, I can modify the page structures on VTL zero to make it point to a read write page on the hypervisor level.

20:14.300 --> 20:17.960
And this will effectively make my page read write.

20:18.180 --> 20:19.960
And I can modify then the content.

20:19.960 --> 20:30.860
So Satoshi Sanda developed a proof of concept and used a null byte page to nullify DSC in exact this way.

20:30.860 --> 20:34.580
Now this is also usable for executing arbitrary code.

20:36.880 --> 20:40.680
And we have two main strategies for executing arbitrary code.

20:40.680 --> 20:43.020
Even if HBCI is enabled.

20:43.100 --> 20:51.180
So this depends a lot on the Intel CPU level.

20:51.200 --> 21:01.300
So if you have any CPU that is before Tiger Lake, before 11th generation, you can still use ROP because this kind of CPU does not support chat.

21:01.300 --> 21:02.360
So you can use kernel forge.

21:02.360 --> 21:11.340
Kernel forge is a technique implemented firstly by Crash and also discussed by Conor McGar in a blog post.

21:11.340 --> 21:20.400
And it uses a thread and a dummy event to modify the thread kernel stack at run time.

21:20.400 --> 21:27.940
Meaning that it will replace frame on kernel side of a thread to make it execute a ROP chain on return.

21:28.360 --> 21:30.000
Executing arbitrary code.

21:30.000 --> 21:40.820
And on, if you instead you have a CPU that is before 12th generation, you can use the page remapping attack as I said, uh, that abuses MULK.

21:40.820 --> 21:43.400
Now why before 12th generation?

21:43.400 --> 21:51.620
I can say, actually I should say a CPU before 12th generation and before Windows, and a version of Windows before 24H2.

21:51.620 --> 22:02.620
Because as I said, Windows 11 24H2 and supports Intel VTRP that is a killer exactly for this kind of attack, for page remapping attack.

22:03.000 --> 22:12.120
So it avoids any user from being able to redirect a page from VTL zero to remap to another page in the OS system.

22:13.700 --> 22:19.760
Now, and what about if we have something, what about if we have something, uh, more?

22:19.820 --> 22:27.160
Um, I actually, I'm actually exploring some other technique for trying to bypass HVCI but currently these are the only way.

22:27.160 --> 22:34.700
I thought that large pages could also be used for this kind of thing but apparently it's not going to, it's not really working.

22:35.560 --> 22:45.920
So, but we still, even if we can do stuff, we still need to load a vulnerable driver to execute any of these strategies.

22:45.920 --> 22:57.140
So if we want to load a vulnerable driver we need to be aware that there is something called driver block list that will probably prevent us from loading a known vulnerable driver on Windows.

22:57.280 --> 23:05.740
Now the driver block list is a black list and of course it has some problems that were identified by Will Dorman and Yarden Shafir, another researcher.

23:05.860 --> 23:24.220
The block list by itself is just a collection of hashes and file names and file version that are supposed to be not loaded on Windows and if the driver block is enabled it will prevent normal, uh, normal vulnerable drivers to be loaded but it has a measure flow.

23:24.220 --> 23:26.920
The coverage is ridiculous.

23:26.920 --> 23:35.220
So I, I made a bit of, a little script to check how many, uh, how many drivers were blocked from the load driver projects.

23:35.820 --> 23:42.460
Uh, this just check the, um, the ashes but it's, it's, it's really, it's really ridiculous.

23:42.460 --> 23:43.920
The coverage is really ridiculous.

23:44.360 --> 23:46.580
And also it can be disabled by admin.

23:47.460 --> 23:52.440
Uh, of course when we bypass the block list we need to be aware that there is also the serial, the serial.

23:52.440 --> 23:57.240
So even if a driver is not in the block list it doesn't mean that the certificate is still valid.

23:57.240 --> 24:05.560
So there are other, there are other, there are, there are other things that may prevent us from loading a, a vulnerable driver on Windows.

24:07.060 --> 24:15.840
And now to the meat of this presentation, what can we do to load a malicious, a vulnerable driver on Windows using this like unusual technique.

24:15.840 --> 24:18.240
So let's talk about, a bit about the anti-object manager.

24:18.240 --> 24:28.000
So the anti-object manager is a subsystem on Windows that provide access to resources, uh, using a name value approach.

24:28.000 --> 24:33.920
It's not entirely correct but it's the most, it's the most accurate, the simplification.

24:34.040 --> 24:37.700
Uh, it provides access to these objects using a unified API.

24:38.220 --> 24:45.160
And uh, it like every object is, is, is uh, it can be indexed by using a name.

24:45.160 --> 24:47.200
Can be recovered using a name.

24:47.200 --> 24:53.920
And these names are uh, categorized in uh, in categories that we call namespaces.

24:54.020 --> 25:00.820
Now, uh, you probably already seen the uh, object manager in WinObject, sees internals.

25:00.820 --> 25:04.200
And you can see a graphical representation of the object manager.

25:04.200 --> 25:07.440
So you have all these objects with the type associated.

25:08.140 --> 25:12.700
And uh, you have the name categorized in namespaces.

25:12.700 --> 25:21.060
Now usually uh, when you, this is actually used um, this categorization is used because any namespace has a certain accessibility.

25:21.060 --> 25:37.920
So if I want for example to make uh, an object available in, to the Win32 layer, I usually use a sim link that connect the global, which is the global um, namespace to the specific object I want to, I want to connect it with.

25:38.400 --> 25:43.040
And this is what you usually do even with drivers uh, for example.

25:44.520 --> 25:57.860
Now, the empty object manager uh, is in uh, of course uh, provides access to object to other subsystem like the IOManager, the process manager, the memory manager, et cetera.

25:57.860 --> 26:15.680
And whenever, whenever an object of type file is uh, is accessed by the IOManager, the IOManager will immediately check the file object and will dispatch it to the relevant driver that is meant to handle that specific file object.

26:15.680 --> 26:20.540
Now, the NTFS driver manage the NTFS file system.

26:21.060 --> 26:23.860
What kind of file system is the NTFS file system?

26:23.860 --> 26:27.720
So the NTFS uh, NTFS is a complex file system.

26:27.720 --> 26:35.120
Uh, it was always designed by Microsoft for extensibility and to support different kind of other file systems like FAT32 et cetera.

26:35.120 --> 26:45.660
And the main thing that I want you to memorize for now is that every file on Windows is a set of attributes of course and every file has at least one stream associated.

26:45.660 --> 26:49.940
So every file on Windows is actually, can actually be referred to as a triple.

26:49.940 --> 26:52.380
It's a triple, triple, triple.

26:52.660 --> 26:59.500
So um, so and um, and usually you have, oh, I don't know what I'm seeing.

26:59.500 --> 27:03.440
So usually you have the file name, the stream type uh, the stream name and the stream type.

27:03.440 --> 27:05.300
Every file has at least one stream.

27:05.300 --> 27:14.460
So if you create a file with just the file name, you are immediately, it means that the other, the stream name and the stream type are defaulting back to something.

27:14.460 --> 27:20.480
For files is the data stream and for directories you have the index allocation stream.

27:20.920 --> 27:23.440
But they are usually always a triple.

27:24.080 --> 27:28.500
Uh, now another thing I want you to memorize is the concept of reparse points.

27:28.500 --> 27:34.220
Because this was meant for extensibility, uh, NTFS supports a lot of type of reparse point.

27:34.220 --> 27:40.160
The main and common, the most common reparse points that you will see in NTFS are three.

27:40.160 --> 27:45.060
Although there are like 20 or 30 different reparse tags.

27:45.300 --> 27:46.720
So reparse types.

27:46.720 --> 27:48.020
So reparse point types.

27:48.140 --> 27:54.120
So the main, the most common are junction points that points directory, that links directory to directories.

27:54.120 --> 28:01.700
Uh, mount points that links directories to drives to, to mounted drives and symbolic links that link files to other files.

28:01.700 --> 28:04.260
So this is not to be confused with link file.

28:04.260 --> 28:05.900
Link file are regular files.

28:05.900 --> 28:09.860
They have a data stream and they are just regular files.

28:09.860 --> 28:14.480
They need to be parsed to access to another location on the file system.

28:14.980 --> 28:18.600
Uh, indeed symbolic links are an NTFS features.

28:18.600 --> 28:23.880
Meaning that they are just, they are just literally link on NTFS.

28:23.880 --> 28:27.220
They link directly on NTFS uh, to another file.

28:27.220 --> 28:38.620
And usually a reparse point is always a reparse tag which in this case is symbolic link and reparse data that will actually point to the real file that it's pointed to.

28:40.060 --> 28:42.720
Now about CDFS.

28:42.720 --> 28:47.680
CDFS is a way more um, is a way simpler file system.

28:47.680 --> 28:59.440
It's, it just, it just comprises uh, root directory and then it has directory and then it has directory entries and file entries that are associated and are always parsed from the root directory.

28:59.720 --> 29:21.040
Is um, is an implementation of the ISO 9667s and 960 and um, the important thing is that the CDFS file system, the CDFS file system uh, is also, also apply, applies to optical disk as much as applies to ISO files.

29:21.040 --> 29:25.560
So ISO files are a virtual implementation of the CDFS file system.

29:25.560 --> 29:37.240
Now just to give a bit of difference to the NTFS, of course CDFS does not support a reparse point, does not support a lot of things that are supported by NTFS but also it has a completely different threat model.

29:37.240 --> 29:40.360
So NTFS supports rich permissions.

29:40.360 --> 29:51.740
So it has an ACL and the ACL is associated with different ACL entries, access control entries which define what, what can be done on each file by each user in the system.

29:51.800 --> 29:59.200
For CD file system, this is not a problem because the content on a CD is supposed to be, is supposed to be immutable.

29:59.340 --> 30:01.800
So everyone has access to a file system.

30:01.800 --> 30:09.140
If you mount a drive , anyone, an admin, a regular user, anyone has access to the mounted files.

30:09.140 --> 30:10.860
To the files on the mounted drive.

30:13.320 --> 30:38.320
And yeah, as I said before, the CDFS driver as much as NTFS driver communicates with the IOM manager, the IOM manager has a request to access a file and after passing through the filter manager, it provides access to the required NTFS or CDFS driver accordingly to what is the device driver associated with the file object.

30:39.120 --> 30:50.180
Now when you load an ISO on Windows, what it, what it, the CDFS driver will automatically load the content of this ISO file using the CD common read.

30:50.940 --> 31:03.160
Now one thing that I want to stress out here is that an ISO file in comparison with a CD, with an optical CD, an ISO file is mapped in physical memory somewhere.

31:03.360 --> 31:06.360
So somewhere this ISO file is mapped in memory.

31:06.780 --> 31:11.420
So this creates some problems and we'll see what exactly.

31:11.420 --> 31:18.900
So when you try to access a file, what you end up doing is you end up calling the NTCC copy read.

31:20.460 --> 31:23.080
Now this points to a file object.

31:23.080 --> 31:37.640
We will describe the file object and just exploring a bit with where this file object were located, we started noticing that the physical address associated with this file object were always the same.

31:37.640 --> 31:55.160
So if you remap one of this file object in a read write page and you override the content of this file object, the file object will be, will flush the content of the modified file back to the physical memory where the ISO was loaded.

31:55.160 --> 31:58.260
This means that it's not read only at all.

31:58.880 --> 32:10.980
And so we developed this IOCDFS lib that you can use to just modify any content on any ISO file that was mounted in the system.

32:10.980 --> 32:17.020
I want to, I want to specify this doesn't work for CD, real CD drive.

32:17.020 --> 32:27.200
It just works for ISO files and the reason is potentially that it's because they are mapped on physical memory when they are loaded the first time.

32:27.680 --> 32:28.960
Of course for caching.

32:28.960 --> 32:37.320
Indeed they are more, it's easier to get a file on an ISO in comparison with a CD.

32:38.040 --> 32:43.920
Now I'm not going to go through this, but there are some limitation on what you can change on the file.

32:43.920 --> 32:56.340
So if you overwrite over the file sides, the real file sides, not the file sides on disk, but the virtual sides, it's the change is not going to, it's not going to appear.

32:56.340 --> 33:00.580
So you can, you can, you can change less, but you can change more.

33:00.920 --> 33:08.780
And if you write, you try to write over the file on, over the file sides on disk, you end up actually breaking some stuff.

33:08.780 --> 33:11.060
So your program will crash probably.

33:12.300 --> 33:13.720
And you're going to have problems.

33:13.720 --> 33:17.940
So these are the margin tolerance where, where you can actually replace the file.

33:19.600 --> 33:22.660
Now, but this is cool, but it's abusable.

33:22.900 --> 33:24.180
Now yeah, it's abusable.

33:24.180 --> 33:29.660
There are some use case scenario where we can actually abuse it uh, for a lot of different means.

33:29.680 --> 33:34.180
But one of the means is hide the fact that we have a driver on an ISO.

33:34.180 --> 33:41.000
For example, we can load an encrypted blob on an ISO and then we can just modify it after the ISO was emulated.

33:42.280 --> 34:05.040
So we found another thing that we could abuse and this is um, I don't know how much it's, this is known, but like if we had a file on disk and we try to link, we try to use the same name to, to create a link, of course the file is going to say, no, I'm not going to use this name because it's already here.

34:05.040 --> 34:15.500
But for some reason, if we specify the link name with a stream name associated to it, it will create a reparse point for the file.

34:15.500 --> 34:23.260
So this will create a reparse point for the file that will overshadow the data stream that is present on the file on disk.

34:23.260 --> 34:38.940
Now this means that at this, at this time, after I created the reparse point, the file, the original file, the original ATXT is still there, but it's not going to be, no one is going to be able to find it unless I delete the reparse point.

34:39.620 --> 34:40.800
And this is abusable.

34:40.800 --> 34:41.160
Why?

34:41.160 --> 35:01.780
Because well, I can create an ISO and I can use this as trusted installer, I need to elevate my privilege to trusted installer, and I can use this to redirect the, a file, a driver file on C, Windows system 32 to something that is on the ISO, for example.

35:03.060 --> 35:12.040
But this has a problem, the driver, of course the driver file, the driver location, the image loaded is going to be, is going to show that I'm loading something bad.

35:12.720 --> 35:23.920
So I be a bit more smart, a bit smarter, I create another ISO and this point I will use a current directory structure.

35:24.100 --> 35:32.040
So now I, and I, I place W, of course I can place whatever driver I want here, here for example there is WinIO.

35:33.180 --> 35:48.100
And I do the same thing, but still, I have a problem, because when I load the driver, it still say, okay, this sounds correct, but there is still, I mean, it's still saying, listen, you are loading from an ISO file.

35:48.260 --> 35:53.760
You're not loading from the system blue directory, you're loading from just an external drive.

35:53.920 --> 35:56.640
You're trying to fool me, you didn't manage to though.

35:58.820 --> 36:02.780
Then, this is just to show that the file is still there.

36:02.780 --> 36:06.600
So if I, if you delete the reparse point, the original file is still there.

36:06.600 --> 36:08.760
Okay, just to, just to prove the point.

36:10.060 --> 36:12.160
But then we notice another thing.

36:12.180 --> 36:18.080
So a direct NTFS link is not enough to bypass, to fool the, the load driver event.

36:18.280 --> 36:19.540
But then we notice another thing.

36:19.540 --> 36:30.480
If we go to the empty object manager, we notice that every driver is actually loaded, not using C Windows system 32, but is loaded using system root.

36:30.480 --> 36:33.920
System 32 driver and the name of the driver.

36:34.200 --> 36:36.360
What is this system 32?

36:36.420 --> 36:47.560
The system 32 is a symbolic link, and not an, not an NTFS symbolic link, it's an NT symbolic link, uh, that is pointing to the device that I use for booting.

36:47.560 --> 36:50.180
In my case, it's device RDS volume 3.

36:50.180 --> 36:54.400
But it's pointed to by the boot device, right?

36:54.560 --> 37:01.620
But this means, and if I inspect the boot device, I notice that I can actually delete this symlink.

37:02.160 --> 37:19.660
So this is actually a permanent symlink, meaning that it's been artificially created to have a ref count of one, but I can make it, I can, as system, I can make it temporary, load, like artificially lowering the ref count to zero again, and then I can delete it.

37:19.660 --> 37:21.360
So what can I, what can I do with this?

37:21.360 --> 37:32.980
I, I can obtain system privileges, I can back up the original boot device, I can replace the boot device symlink with the ISO, and then I can restart the service and see what happens.

37:32.980 --> 37:35.200
And what happens is that it works.

37:35.780 --> 37:41.820
But the driver load event still shows that I'm loading from an ISO.

37:41.820 --> 37:44.480
So still I wasn't able to fool it.

37:47.590 --> 37:58.870
And another problem is that if I inspect the driver in system informer or a similar tool, I've noticed that the driver is showing, for example, a missing description.

37:58.930 --> 38:03.470
It's showing stuff that indicates that I loaded another driver.

38:04.750 --> 38:07.330
What if we swap the drive letters?

38:07.870 --> 38:14.790
What if I do a drive swap for, this is something that nobody will ever think of doing, and there is a reason for that.

38:14.830 --> 38:22.270
Because if you try to swap the drive letters, your program, your, your system will probably crash at a certain point.

38:22.270 --> 38:34.850
There is nothing, but if you do it for just a second and you keep everything consistent so you don't just remove the letters, but you swap into other letters, it actually might work.

38:35.050 --> 38:42.610
So the, I'm not showing the screen shot because I'm showing you a video afterward, but the, the technique is this.

38:42.610 --> 38:57.830
We mount an ISO with an encrypted blob, we just respect the directory structure, we change the boot device to CD-ROM, we swap drive letters, we load the driver, we restore immediately the drive letters, we restore the boot device, and then we can at that point,

38:57.830 --> 39:03.770
we can use, we can abuse the driver that has loaded in memory even if we unmount the ISO file.

39:06.570 --> 39:09.070
Now what about using other techniques?

39:09.070 --> 39:22.330
Well, I, I can use other techniques uh to, to load the malicious driver uh but in this case, for example, I can use uh all the partition that is assigned to the transactional file system.

39:22.870 --> 39:26.270
It's not supposed to be accessible by any user.

39:26.390 --> 39:44.330
It's not supposed to be writable, but we discovered that if you access this kind of location with the additional, with, with the, with uh, with the required permissions, in this case, backup intent, say restore, say backup privilege, a maximum file, maximum allowed as uh,

39:44.330 --> 39:49.130
as uh, as access right, you can actually override this.

39:49.130 --> 39:53.010
You can actually access these locations and you can actually write files on them.

39:53.010 --> 40:01.670
So, and this is a proof, of course, where I actually am writing, I'm writing on uh the transactional file system uh locations.

40:01.930 --> 40:03.370
Is there any benefit?

40:03.370 --> 40:05.590
I don't see any benefit in doing it.

40:05.590 --> 40:13.470
Uh, it can just give you an additional way of exploiting the same vulnerability in, in other ways, not using an ISO.

40:14.370 --> 40:15.790
So, let's demo it.

40:15.790 --> 40:18.450
So, Windows 11, HVCI is enabled.

40:18.450 --> 40:36.200
Uh, I have a simple load of a driver and I hope, uh, I hope it actually, because this doesn't actually, oops, oops, I did a mistake.

40:36.940 --> 40:37.400
Okay.

40:37.860 --> 40:41.680
So, it doesn't show, I don't know how to make play.

40:44.320 --> 40:49.200
Uh, it doesn't show the right, uh huh.

40:50.260 --> 40:51.180
Okay.

40:51.520 --> 40:52.840
That seems it works.

40:54.640 --> 40:55.500
Yeah.

40:55.500 --> 41:02.640
So, okay, here we are seeing that we are targeting the AALP SSI GPO is uh an Intel driver.

41:03.440 --> 41:05.760
And we are loading our driver.

41:05.760 --> 41:08.320
We are switching everything and we're loading the driver.

41:08.320 --> 41:10.300
Now, the driver has been loaded.

41:10.300 --> 41:15.820
The name is that and if you can see, honestly, I would, I would challenge to spot the difference.

41:15.840 --> 41:17.800
The description is the right one.

41:17.800 --> 41:24.940
But, and if you try to point to the what, what file was loaded, it will actually open the right directory.

41:25.280 --> 41:28.420
But indeed, we loaded another.

41:28.620 --> 41:32.680
You can, you can actually spot it from the sides.

41:32.680 --> 41:33.500
From the sides.

41:33.500 --> 41:36.640
It's 28 kilobyte which is the size of WinIO.

41:38.920 --> 41:47.420
And you can see also from the hash, that is the same hash of WinIO, which is a vulnerable driver that is not currently blocked by Microsoft block list.

41:47.420 --> 41:50.700
We can do another attempt, this time on Windows.

41:50.720 --> 41:53.420
I don't know if there is anything I'm showing.

41:55.000 --> 41:55.800
Yeah.

41:55.800 --> 41:58.800
I'm, I'm proving that it's WinIO here.

41:59.000 --> 42:10.260
So you will see that there is the WinIO handle uh showing up in devices and when I, we get there, bit of faith.

42:12.020 --> 42:14.540
So we have WinIO loaded.

42:14.540 --> 42:23.400
Now, when I unload the driver, that is not unloadable usually, WinIO disappears.

42:24.060 --> 42:26.860
So it was WinIO all along.

42:27.180 --> 42:31.240
But it doesn't show up anywhere practically.

42:31.240 --> 42:41.740
And we fooled the driver loader into thinking that we actually loaded a driver on C Windows system 32 as, as, as it was normal.

42:42.020 --> 42:51.240
Now, on Windows 10 or when HDCI is not enabled, we can just strictly integrate it with KDU for example.

42:51.240 --> 42:56.500
Same technique, same driver as base for exploitation.

42:57.320 --> 43:00.360
I still need to, no.

43:01.260 --> 43:03.220
Come on.

43:04.820 --> 43:06.000
Yes.

43:06.700 --> 43:11.920
So still driver jack is executing, arrives.

43:11.920 --> 43:17.000
It overwrites the content in memory because the driver is encrypted as I said on the ISO.

43:18.420 --> 43:22.880
And then it just loads the drive and straight executes KDU.

43:22.880 --> 43:27.800
The vulnerable driver was already loaded because we loaded to the driver, with the driver jack technique.

43:28.160 --> 43:32.900
The name is WinIO and we can execute our unsigned code on Windows.

43:34.560 --> 43:41.620
Now, of course, if you want to execute with HDCI enabled, you need to use one of the other thing that I showed before.

43:41.620 --> 43:51.720
CandleForge, uh, Malk, or unless, if, if, or, or you can use, or you can just disable HDCI altogether.

43:51.720 --> 43:58.360
So, the full chain that we used was, we weaponized the step 7 installation media.

43:58.500 --> 44:13.000
Um, in, in this way initially, we used the trial process immediately because as I said, uh, the set up of the step 7 installation media uses multiple process to install.

44:13.080 --> 44:15.900
So we could blend in with an additional process.

44:16.000 --> 44:24.280
We rewrite and execute an additional file so we, there was no malware on the ISO except of a minimal DLL used for site loading.

44:24.280 --> 44:30.500
And then what we do is we use driver jack, we, we execute, uh, we install the full candle rootkit.

44:30.520 --> 44:32.740
Uh, we were targeting Windows 10.

44:32.760 --> 44:35.380
HVCI was not a problem in this case.

44:35.500 --> 44:40.100
And, and then we just keep going with additional, with additional compromise step.

44:41.100 --> 44:48.260
So, portability, we have integration with KDU, uh, if HVCI is disabled.

44:48.260 --> 44:53.720
If it's enabled and you have, uh, inter-K chat not supported, you can use CandleForge as I said.

44:53.720 --> 45:09.560
If it's, um, if HVCI is, HVCI is, HVCI is, oh my gosh, is, is hypervisor protected coding, enforce code, code integrity is enabled and you don't have Intel DT but you have inter-K chat can use mark.

45:09.700 --> 45:18.860
Otherwise, well, the, the best chance so far, uh, is to just, uh, disable code integrity and ask for a reboot.

45:19.260 --> 45:24.680
Um, because there is no currently, there is not currently a technique .

45:24.680 --> 45:29.980
As I said, I, I mistakenly believe that you could actually abuse large pages for it.

45:29.980 --> 45:36.180
I'm still trying to check it if, if it's possible, but it doesn't look like it's working fine.

45:37.380 --> 45:45.760
And as key takeaways, I mean, you can download the box, uh, the, the, for driver jack is, is already, is already public.

45:45.760 --> 45:47.720
You can, you can go and take a look.

45:48.120 --> 46:00.640
Um, for like detection, as detection advice, I would always try to detect if, uh, someone is escalating privileges to system or trusted installer using no means.

46:00.660 --> 46:07.580
Uh, monitor for drive letter change to just prevent this trick from, uh, bypassing detection.

46:07.600 --> 46:13.180
Uh, of course, monitor for changes in the anti-object manager, especially for global links.

46:13.540 --> 46:24.100
Uh, keep your hardware up to date is very important because as we've seen, the more we go to modern CPUs, et cetera, the, the more difficulties to exploit this kind of bugs.

46:24.240 --> 46:35.660
And then, and then there is the, one of the detection opportunity, which is the probably best, is when there is a drove, a driver load event, implement an hash cross check.

46:35.660 --> 46:38.740
So there is an hash present on the driver load event.

46:38.780 --> 46:49.540
The only thing you need to do is going on the file list, on the file path that is, was, that was loaded, perform, like calculate the check at run time and then compare the, the hashes.

46:49.540 --> 46:51.840
The hashes is, are not possible to fool.

46:51.840 --> 46:57.560
So, uh, if the hashes are not matching, it means that something happened that was bad.

46:57.560 --> 47:01.320
So another driver was loaded in place of the original one.

47:02.300 --> 47:03.900
And that's it.

47:03.900 --> 47:06.140
Thanks a lot for, for attending.

