WEBVTT

00:00.000 --> 00:07.660
It is my absolute pleasure to introduce these two first time DEF CON speakers, Alejandro and Boya.

00:08.200 --> 00:15.680
The title of their talk is Kill Chain Reloaded, Abusing Legacy Pass for Stealth Persistence.

00:15.680 --> 00:17.620
With that, take it away, guys.

00:24.050 --> 00:25.430
Hello, everyone.

00:25.450 --> 00:28.470
First of all, thank you for inviting us to DEF CON.

00:28.470 --> 00:30.930
It's an honor for us to be here.

00:30.930 --> 00:34.810
Our English is not perfect, but we will try to explain everything as clear as possible.

00:34.890 --> 00:37.750
We ask for your patience and please don't be too hard with us.

00:39.170 --> 00:41.690
This is my colleague, Alejandro Hernando.

00:41.690 --> 00:45.950
We both work in the hacking department at Accenture Spain in red team and research.

00:46.270 --> 00:49.190
We love breaking things and finding more abilities.

00:49.870 --> 00:54.950
Here is your social media just in case you want to contact us or ask anything about this talk.

00:57.110 --> 00:58.430
I am Borja Martinez.

00:58.430 --> 01:01.250
I also work in the hacking department at Accenture Spain.

01:01.250 --> 01:06.090
Sometimes I participate in Capture the Flag competition as a member of the team.

01:06.770 --> 01:08.390
But now we are retired.

01:08.930 --> 01:14.130
Here is my social network for any questions or doubts you may have after the presentation.

01:16.330 --> 01:17.230
Okay.

01:17.810 --> 01:22.530
In this part we will focus on how we do threat hunting to find vulnerable artifacts.

01:22.870 --> 01:25.430
Our methodology to look for these drivers.

01:25.670 --> 01:28.590
Specific software and drivers we use in our research.

01:29.310 --> 01:34.570
Vulnerabilities we found in UFI software to develop advanced boot kits and new persistent techniques.

01:34.610 --> 01:39.470
Finally how we use these vulnerable drivers to get persistent in real red team exercises.

01:42.380 --> 01:42.900
Okay.

01:42.900 --> 01:47.980
Before we go deeper we're going to explain why I think this topic is especially important today.

01:48.340 --> 01:53.900
In recent years we have seen that threats which look almost theoretical are now completely real.

01:54.020 --> 02:00.960
Boot kits like Black Lotus for example have managed to run malware on Windows 11 system with secure boot enabled.

02:01.480 --> 02:06.080
So system with all security enabled can still be fully compromised.

02:06.300 --> 02:10.560
And we are not talking about all APTS from 10 years ago.

02:10.580 --> 02:14.720
That is the reality we find when researching low level security.

02:16.660 --> 02:20.740
One common mistake is to think that if you have secure boot enabled you are protected.

02:20.880 --> 02:22.360
But it isn't that simple.

02:22.360 --> 02:28.100
Secure boot works with a list of trusted binaries and another list called DBX for revoked binaries.

02:28.420 --> 02:34.080
If a vulnerable binary is in the DBX secure boot will allow it anyway even if it's compromised.

02:34.120 --> 02:36.940
Also many vendors don't update that quickly.

02:37.900 --> 02:43.280
There are cases where it takes months to revoke binaries with critical vulnerabilities like Black Lotus.

02:45.720 --> 02:49.200
But not everything is caught by attackers.

02:49.200 --> 02:51.440
Sometimes there are failures from inside.

02:51.460 --> 02:55.380
In July 2024 a crash type update broke computers all over the world.

02:55.560 --> 03:02.460
The faulty agents could abuse this especially in corporate environment as airport, banks, hospital or were affected.

03:02.860 --> 03:08.020
And this was without malware, without exploit, only about binary running a critical part of the system.

03:08.340 --> 03:13.580
We mention this because boot kits won the single level of control but with a malicious and persistent goal.

03:13.800 --> 03:17.620
It's a good example of how one single binary can break everything.

03:20.180 --> 03:25.780
Here is a quick table with some of the most well known boot kits used in real operations.

03:25.840 --> 03:27.440
Many link to APTS.

03:27.720 --> 03:33.200
Most of them load before the operating system so no EDR, antivirus or side channel solution can see them.

03:33.340 --> 03:36.240
They control the system from the moment you turn it on.

03:38.900 --> 03:39.660
Okay.

03:40.060 --> 03:42.760
We have been researching all this for a long time.

03:42.760 --> 03:49.100
We want persistent, we have used vulnerable software, signed files in trusting drivers.

03:49.220 --> 03:52.740
And change everything to execution and total control.

03:52.740 --> 03:58.040
We will show how we did threat hunting for signed artifacts that lets us do this in real scenarios.

04:01.560 --> 04:08.980
You will see how we use virus total, retro hunt and the Microsoft catalog to find components with useful functions.

04:09.360 --> 04:12.540
Physical memory access, can I rewrite and so on.

04:12.680 --> 04:20.700
We will also explain how we exploit these pieces to inject code into UFI, manipulate the whole process and keep persistent without leaving traces.

04:20.820 --> 04:26.000
And the most important thing is how to use all this in real extreme exercises without raising alert.

04:27.060 --> 04:27.920
Okay.

04:28.020 --> 04:28.980
Demo time.

04:41.320 --> 04:42.080
Okay.

04:42.280 --> 04:46.100
Here you can see someone can link to a virus total enterprise account.

04:46.100 --> 04:48.240
In virus total we do two main things.

04:48.360 --> 04:52.200
Search basic things or use the other rules with retro hunt.

04:52.280 --> 04:57.020
For retro hunt as you can see our script uses pin port to select interesting functions.

04:57.040 --> 05:04.160
On the right you see all the drivers we use as a black list to avoid drivers that already work or known to be vulnerable.

05:04.920 --> 05:09.780
We do a quick demo run, as you can see it finds many drivers with those functions very fast.

05:10.460 --> 05:14.700
That's running and before we had already launched two more.

05:15.340 --> 05:20.220
One with 4,000 results and another with 10,000 results.

05:21.480 --> 05:27.360
On the other hand we sometimes search for things like WPBH which Alejandro will explain later.

05:28.500 --> 05:31.860
We attach for example to only see same binaries.

05:37.070 --> 05:47.410
And I will say it's by looking for certificates like Microsoft Windows UFI driver, publisher or Microsoft corporation UFI CR2011.

05:54.740 --> 06:01.180
There are more options but these are a few examples so I don't understand how we search for useful binaries.

06:04.230 --> 06:09.050
The demo is ‑‑ okay.

06:09.890 --> 06:15.330
Here for example you see 64 AFI and it's all the binary sign.

06:21.250 --> 06:22.110
Okay.

06:22.110 --> 06:26.190
Also based on research from GitHub project we made this script.

06:26.350 --> 06:31.190
The script inquires to a Microsoft catalog like we have done before with retro hunt.

06:31.190 --> 06:33.490
Searching for driver with interesting function.

06:33.690 --> 06:35.010
Now we run this script.

06:35.010 --> 06:38.690
It searches all the pages and when it finds a string like go away.

06:38.970 --> 06:39.850
Spoiler.

06:40.070 --> 06:41.990
It downloads all the files.

06:42.790 --> 06:51.190
So this is the first demo showing you how we found some drivers and EFI files which we will later use in our research.

06:51.750 --> 06:55.430
With the next demo you will see more clearly how we use these files.

07:23.600 --> 07:24.560
Okay.

07:27.780 --> 07:37.040
Before going to the technical part I'll give some context about what UFI is, what a loader is and why these are so important for our research.

07:37.200 --> 07:41.860
When we turn on a computer the first thing that runs is not Windows, not ADR, not antivirus.

07:41.860 --> 07:43.080
The firmware runs first.

07:43.080 --> 07:44.040
UFI.

07:44.200 --> 07:49.080
UFI is like a operating system without memory, heap, services and drivers.

07:49.180 --> 07:55.680
It has many phases but the most interesting for us is DXE where EFI modules are loaded.

07:55.760 --> 08:00.880
After initial UFI runs the loader which loads the system kernel.

08:00.920 --> 08:06.140
In Windows it's usually booting GFWUFI or booting GREFI.

08:06.220 --> 08:09.720
In Linux it can be grab, sim or something custom.

08:09.960 --> 08:11.540
And here is the key point.

08:11.540 --> 08:16.820
Everything that's happened before ExitBoot services it's outside the radar of formal security solutions.

08:16.860 --> 08:25.800
If we can put a signed EFI in loading path we can interbind, redirect, persist or exploit the boot before the OS can defend itself.

08:25.860 --> 08:30.980
And now I give the floor to my colleague Alejandro who will explain this part in more detail.

08:35.280 --> 08:37.100
Okay, just a second.

08:42.720 --> 08:44.140
All right.

08:44.220 --> 08:49.080
As we discussed before you can't just run an EFI binary on the system.

08:49.140 --> 08:56.780
We must consider the security mechanisms that Windows implement to block the execution in the preboot environment.

08:59.120 --> 09:05.640
Secureboot aims to block the execution of an authorized code from running in the preboot environment.

09:05.680 --> 09:10.880
It does so by allowing only signed trusted binaries to execute.

09:11.000 --> 09:14.540
However, there are a lot of vulnerable applications in the wild.

09:14.540 --> 09:17.240
For example, Neorizon DataSuite boot loaders.

09:17.240 --> 09:22.220
Neorizon DataSuite boot loaders before June 2022 were assigned.

09:22.220 --> 09:24.680
However, they were also vulnerable.

09:25.000 --> 09:29.560
They allow the loading of arbitrary unsigned EFI binaries.

09:29.760 --> 09:39.540
With arbitrary EFI execution an attacker can bypass platform security, install persistent boot gates, perform preboot attacks and fully control the system.

09:39.540 --> 09:42.640
Including settings and boot flow.

09:43.500 --> 09:52.080
On the other hand, Microsoft mitigates this class of secureboot bypasses like the Neorizon DataSuite boot loaders using the DVX.

09:52.080 --> 10:02.400
DVX is a UFI secureboot revocation list and it contains signatures of known binaries that are no longer trusted.

10:02.400 --> 10:05.620
Even if they were originally signed.

10:05.680 --> 10:11.740
Even though the binary is signed, secureboot refuses to execute if it matches any DVX entry.

10:11.960 --> 10:15.900
Microsoft distributes DVX through Windows updates.

10:15.900 --> 10:19.180
Usually as part of regular security patches.

10:19.180 --> 10:31.740
However, in 2024, Microsoft published the secureboot object repository on github to openly share the contents of the secureboot DVX list and related signature databases.

10:31.740 --> 10:40.940
This repository allows security researchers to inspect which UFI boot loaders and certificates have been revoked by secureboot updates.

10:42.140 --> 10:55.120
So, using this resource, we downloaded a publicly available edition of secureboot restore, we extracted the hashes, and we compared those hashes against the entries in the DVX.

10:55.360 --> 11:00.100
We found that some versions of shield loader are correctly listed in the DVX.

11:00.100 --> 11:03.660
Specifically, those matching the hash line above.

11:03.880 --> 11:08.480
This hash corresponds to the entries of the CVE we talked about before.

11:08.480 --> 11:13.060
However, we also found several other versions of the boot loader.

11:13.060 --> 11:17.000
These have different hashes and were not present in the DVX.

11:17.120 --> 11:22.240
This suggests that additional vulnerable variants of shield loader may exist in the wild.

11:22.240 --> 11:30.760
It has not been added to Microsoft's revocation list and may still be trusted by secureboot on system that rely on DVX protection.

11:31.740 --> 11:37.060
So, let's now take a closer look at how reboot restore actually works.

11:37.060 --> 11:43.980
Reboot restore is a software that restores a computer to a preset state every time it restarts.

11:43.980 --> 11:47.420
Its main EFI binary is shield loader.

11:47.420 --> 11:53.040
Before we get into the loader internals, here's how shield loader gets into the chain.

11:53.260 --> 11:59.080
First, looks for the ESP, the EFI system partition for the boot loader.

11:59.740 --> 12:05.980
Shield loader is renamed or copied over the boot loader.

12:05.980 --> 12:10.900
When the finger invokes boot loader, it actually runs shield loader first.

12:11.080 --> 12:19.720
Shield loader then implements its own logic, the compression, signature checks and so on, before finally loading the real boot manager.

12:21.060 --> 12:23.620
Okay, but what does shield loader do?

12:23.620 --> 12:28.720
We divide the shield loader operation in four phases.

12:28.960 --> 12:36.580
First, shield loader opened the ESP volume, located the file shield manager underscore, notice underscore, this is important.

12:36.900 --> 12:40.660
Allocate the file size and read all bytes into a buffer.

12:40.740 --> 12:45.760
If that works, we end up with the proprietary format binary, NAUI.

12:46.100 --> 12:51.440
In memory, if it fails, the loader falls back to scanning every installed finger volume.

12:51.600 --> 12:53.820
We'll talk about this proprietary format later.

12:54.780 --> 12:57.440
Then, the loader invokes parse heater.

12:57.440 --> 13:07.180
This routine first inspects the 200 byte heater at the start, it reads the ASCII magic and extracts both the compressed and uncompressed file length.

13:07.180 --> 13:09.320
After that, it goes through the chunks.

13:09.320 --> 13:17.900
And for every chunk, it calls decompress on the payload and if it doesn't compress it, it simply main copy the raw data.

13:18.120 --> 13:21.380
And this is how the proprietary format looks like.

13:21.380 --> 13:23.820
This is the EF underscore format.

13:23.820 --> 13:30.040
We have the 200 byte heaters, with magic, compressed and uncompressed file length.

13:30.040 --> 13:31.180
Then the chunks.

13:31.180 --> 13:33.260
Mark as compressed or not.

13:33.260 --> 13:37.560
And finally, the trailer where the signature is located.

13:39.020 --> 13:45.880
After that, the shield loader looks for the signature of the trailer, the last 800 bytes.

13:46.300 --> 13:50.920
So after decompressing and allocating the image, the boot loader goes into phase three.

13:50.920 --> 13:54.540
In this phase, the loader invokes check signature.

13:54.540 --> 14:00.760
Then it jumps to the last 800 bytes of the buffer where it inspects the trailer.

14:00.880 --> 14:10.660
If the magic is wrong, the prediction fails or something doesn't look good, check signature returns false and the loader aborts with EFI security violation.

14:11.820 --> 14:17.500
Finally, in phase four, the loader hands off to the standard EFI boot services.

14:17.720 --> 14:22.140
It calls load image and returns a new EFI handle.

14:22.160 --> 14:27.700
It then invokes a start image, which transfers control into the loaded P.

14:27.700 --> 14:31.300
And this is almost the full chain of shield loader.

14:31.300 --> 14:35.680
But we also found an interesting proprietary format EFI file.

14:35.680 --> 14:39.880
Remember that underscore EFI files like this.

14:39.880 --> 14:47.460
Additionally, in one finger version, we discover a containing name shell dot EF underscore.

14:47.460 --> 14:54.080
This is actually a sign UFI shell binary with only a small subset of command enable.

14:54.080 --> 15:03.120
Although if functionality is limited, we can leverage it later as a convenient trusted entry point into the UFI environment.

15:04.440 --> 15:07.300
Right, but what does shell loader do?

15:07.420 --> 15:13.200
Remember that shield loader loads shield manager.

15:13.200 --> 15:23.340
So after the compression, the EFI in shield manager, the loader skips the custom format and directly load another EFI image.

15:24.060 --> 15:32.080
Any EFI executable placed at shield dot EFI at ESP will be loaded and run without checks.

15:32.080 --> 15:34.080
This means two things.

15:34.080 --> 15:36.680
First, there's no security verification.

15:36.680 --> 15:40.320
Load unsigned EFI never calls check signature.

15:40.320 --> 15:42.400
Also, there is no container parsing.

15:42.600 --> 15:46.240
It expects an extra P image so you can drop any EFI file there.

15:46.240 --> 15:55.400
You can write your own EFI binary and compile it and put it as shield dot EFI into the ESP partition and shield manager will load it for you.

15:55.920 --> 16:03.880
So this is supported so we can abuse this to load our own unsigned EFI binary.

16:03.880 --> 16:06.220
So let's look at this in a demo.

16:10.500 --> 16:11.080
Okay, so this is the demo .

16:11.080 --> 16:11.680
Okay .

16:13.740 --> 16:15.340
Well, let's begin the demo.

16:15.340 --> 16:18.960
First, we verify that secure boot is enabled.

16:19.140 --> 16:25.880
If the publisher command returns true, it means secure boot is active and functioning properly.

16:25.880 --> 16:28.900
In this case, we can see that this is enabled.

16:29.280 --> 16:32.140
Next, we run our EFI install.

16:32.160 --> 16:37.820
This tool replaces the files in the ESP, EFI system partition, with our own.

16:37.820 --> 16:41.940
So what happens after the system reboots?

16:41.940 --> 16:46.500
Remember that we have replaced it, the original boot loader, with our install.

16:46.500 --> 16:50.680
At this point, shield loader loads shield manager.

16:50.680 --> 16:57.680
Shield manager then loads shield dot EFI, which is our custom unsigned binary.

16:57.840 --> 17:05.240
This binary calls and reallocates another image and at this point, this binary displays this custom SDR splash screen.

17:05.740 --> 17:12.500
And once the animation completes, we chain load the original boot manager and Windows boot success.

17:13.160 --> 17:14.460
Okay.

17:22.910 --> 17:26.850
So, but, what about the local protection?

17:26.850 --> 17:36.310
When you enable BitLocker on a noise volume, the VNK is sealed in the TPN against the current values of several PCRs.

17:36.330 --> 17:44.230
With secure boot enable, usually PCR7 records a hash of every EFI executable that runs from the kernel.

17:44.230 --> 17:48.690
Boot manager, VCD, early drivers, and so on.

17:48.710 --> 18:00.270
If any one PCR is different, after boot, the comparison, the unseal fails and Windows falls back to BitLocker recovery mode.

18:00.610 --> 18:04.150
Okay, so, what does our proof of concept do?

18:04.150 --> 18:08.090
First, we suspend BitLocker protection indefinitely.

18:08.210 --> 18:15.930
We achieve this by using WMI to run disabled key protectors with disabled count equal to zero.

18:15.930 --> 18:22.650
This prevents triggering BitLocker recovery after modifying EFI files in the ESP partition.

18:22.650 --> 18:31.550
Then, we mount the EFI system partition, backup original boot loaders, and save boot manager and boot 64 for later restoration.

18:31.930 --> 18:34.890
Finally, we apply the modified boot files.

18:34.890 --> 18:51.830
To do this, we override the boot loader with shield loader, and we continue by replacing the expected shield manager, the shield manager underscore, remember, with shell dot EF underscore, which is the sign EFI shell with a limited command set enable.

18:52.030 --> 19:02.210
We also need to copy a stage zero dot EFI that is a sign tool capable of enrolling unsigned binaries into machine owner key.

19:02.490 --> 19:11.030
And last but not least, we copy loader dot EFI that is our final unsigned payload into ESP.

19:11.530 --> 19:13.310
Okay, that was a lot of things.

19:13.310 --> 19:15.830
Let's see it in action.

19:16.470 --> 19:17.550
Okay.

19:22.670 --> 19:23.670
Good.

19:24.130 --> 19:29.450
In this demo, we start by verifying that BitLocker protection is enabled.

19:29.530 --> 19:36.090
Using the manage BD command, we confirm that BitLocker is indeed active.

19:36.150 --> 19:40.990
After that, we run our EFI installer and reboot the system.

19:42.950 --> 19:47.870
Remember that secure boot is also enabled at this point.

19:48.850 --> 19:59.030
As part of the installer process, it replaces the files in the ESP, EFI system partition, and disable BitLocker protection using WMI.

19:59.370 --> 20:10.210
After reboot, instead of the usual boot flow, we load shell dot EF underscore, which is the sign proprietary version of the EFI shell we talked about before.

20:10.210 --> 20:13.990
The EFI shell with a limited command set enable.

20:14.550 --> 20:18.630
From this restricted EFI shell, we download a stage zero.

20:18.630 --> 20:24.190
A sign EFI binary designed to enroll any binary into the machine owner key.

20:24.370 --> 20:31.890
In this case, we enroll loader dot EFI, which is actually a fully functional version of the EFI shell.

20:32.250 --> 20:38.570
Now that we have a fully capable shell, let's attempt to load and sign EFI binary.

20:38.670 --> 20:43.090
As expected, this fails because secure boot is still enforced.

20:43.330 --> 20:53.170
To bypass this, we can do a lot of things, but we locate the EFI protocol handles associated with the security architecture protocols.

20:53.530 --> 21:00.650
Once identified, we patch them with the opcodes XR, RAX, RAX, and then return.

21:01.190 --> 21:14.170
In this example, to bypass secure boot protection, we first need to identify the addresses of the security architecture protocols handles, and once located, we modify the corresponding opcodes.

21:14.530 --> 21:25.690
For demonstration purposes, we are applying the patch byte-by-byte, rather than using a more automated or optimized method.

21:25.730 --> 21:33.450
So we just show up the left, and then return.

21:33.490 --> 21:38.350
This should disable the secure boot validation mechanism.

21:38.470 --> 21:45.250
So now, we need to try to run our EFI and sign EFI binary again.

21:45.250 --> 22:02.510
And it works, because we previously disabled BitLocker using WMI, we are able to chain load the original boot manager, allowing Windows to boot successfully without any BitLocker recovery screen or recovery patch.

22:02.510 --> 22:03.570
All right.

22:05.430 --> 22:07.110
Thank you.

22:08.130 --> 22:10.090
Okay, let's continue.

22:13.100 --> 22:14.860
Well, enough of CR.

22:14.860 --> 22:19.420
Let's do something more interesting, like achieving persistence.

22:19.600 --> 22:25.660
One technique we can try to abuse is WPPT, the Windows Platform Binary Table.

22:25.760 --> 22:34.820
WPPT lets the firmware place one native application as C Windows System 32 and execute it in the session manager context.

22:35.160 --> 22:35.960
This is important.

22:35.960 --> 22:42.320
In other research, this approach appears to work when the binary is signed with an old certificate.

22:42.600 --> 22:48.980
However, in our test on Windows 11 2482, this doesn't work if the certificate is revoked.

22:49.200 --> 22:56.060
Since many of the leaked co-signing certificates are now revoked, we need to find new ways to achieve our goals.

22:56.520 --> 23:00.240
So we can simply drop in a native application and run it.

23:00.240 --> 23:02.500
That's a problem, because we need to modify it.

23:02.500 --> 23:08.940
But what if instead we find a signed native application that's vulnerable and exploit it to do whatever we want?

23:09.240 --> 23:11.540
And that's exactly what we've done.

23:13.200 --> 23:16.900
We've found a signed application from Lenovo.

23:16.900 --> 23:28.480
This binary was used by Lenovo Service Engine, LSA, to smuggle a big blob of PDF files, registry keys, and config data from firmware into Windows.

23:28.480 --> 23:37.320
It uses a proprietary ACP table called LUFT table that isn't part of the ACP specification.

23:37.320 --> 23:40.420
Only Lenovo's binary parses it.

23:40.700 --> 23:48.200
This lets an attacker to install an arbitrary driver or service completely from ACP.

23:48.200 --> 23:52.620
So you are installing after the boot from the pre-boot environment.

23:52.620 --> 23:54.360
This will be interesting.

23:54.720 --> 24:00.380
So no disk write needed until the session manager does it for you.

24:00.580 --> 24:06.340
So we need to construct a new LUFT table, a new Lenovo table.

24:06.400 --> 24:09.080
That needs to drop help.sys.

24:09.080 --> 24:14.700
Help.sys is a non-signed vulnerable driver we found over there.

24:15.760 --> 24:19.500
We use this to construct our LUFT table.

24:19.700 --> 24:26.240
Then we also need to fill our table to create a service key under, for example, two server driver.

24:26.240 --> 24:27.580
It can be whatever name.

24:27.980 --> 24:32.680
We also need to set display name, image path, type, error control values.

24:32.680 --> 24:36.640
And after that we reuse slot 6 in the STD.

24:36.640 --> 24:41.640
The slot 6 points to the SMT entry of the OEMs.

24:41.700 --> 24:52.000
We need that slot points to the start of our buffer that we filled with our LUFT table.

24:52.000 --> 24:55.000
After that we also need to fix the checksum.

24:56.120 --> 25:00.340
Okay, but what does the Lenovo native application do?

25:00.500 --> 25:12.980
Well, it looks for a custom ACP table named LUFT, writes the binary to this calling the function level as say binary to C, Windows system 32, drivers, whatever that is.

25:12.980 --> 25:23.020
Then it invokes create registry keys on every subdescriptors which in turn writes or patches the registry so the binary will launch automatically.

25:23.560 --> 25:27.360
Right, we also need to construct our WPBT.

25:27.360 --> 25:34.880
We need to find a readable random space or we can just allocate it because we have random execution, we have EFI execution.

25:34.880 --> 25:41.100
So we can allocate and copy our real payload that is the Lenovo native sign application there.

25:41.240 --> 25:47.920
We also need to overwrite the first 16 bytes in the SRAT with this WPBT heater.

25:47.920 --> 25:53.220
This silently turns the SRAT into a WPBT and the system observes it.

25:53.220 --> 25:55.540
We also need to fix the checksum.

25:55.540 --> 25:58.820
So to summarize what we are going to do.

25:59.040 --> 26:06.440
Finger first finish post enters accessible services and real time memory still contains our injected blobs.

26:06.540 --> 26:20.640
Windows loader, scan the STD, find our Lenovo proprietary table, put the rampage that used to be SRAT but now begins with WPBT, sees a valid length and checksums and asserts it as WPBT.

26:20.820 --> 26:29.600
After that the session manager copies the Lenovo sign application from the WPBT to this and executes it as NT process start.

26:29.900 --> 26:42.660
Then the Lenovo native sign app started by run service 1, parses the lab, drop help.sys, write the registry values and start the service or schedule it for the next boot depending on the flags.

26:42.660 --> 26:48.080
On the next boot, Windows sees a legitimate driver entry under services to service driver.

26:48.080 --> 26:51.800
Loads help.sys and the system is compromised.

26:51.800 --> 26:54.600
It's better to see it in action.

27:03.460 --> 27:11.360
In this demo we once again begin by verifying that secure boot is enabled.

27:13.620 --> 27:18.980
We also confirm that the target service that we are using does not exist on the system.

27:18.980 --> 27:22.340
We are going to do everything of this from the pre-boot environment.

27:22.740 --> 27:34.380
As usual we run our EFI installer and afterwards we validate that neither the help.sys driver nor the Lenovo native application file is present.

27:34.700 --> 27:37.580
We then proceed to reboot the machine.

27:37.820 --> 27:46.580
Upon reboot we chain load our custom EFI binary which launches an EFI shell for demonstration purposes.

27:47.080 --> 27:49.480
Wait a few seconds until the system reboots.

27:51.300 --> 27:52.240
Okay.

27:52.820 --> 27:59.580
So remember we modified the EFI system partition to replace the boot loader with shield loader then shield manager.

27:59.580 --> 28:07.480
Shield manager is loading our custom EFI file and this custom EFI file right now is loading a fully functional EFI shell.

28:07.480 --> 28:18.480
From this EFI shell then we need to patch the WPBT, the Windows platform binary table and create our custom LUFT table.

28:18.480 --> 28:22.080
The Lenovo custom table.

28:22.900 --> 28:31.140
As the system boots, the session manager executes the Lenovo native application before prompting the user to log in.

28:31.360 --> 28:33.600
So here it is.

28:33.600 --> 28:43.060
Then the application with the LUFT table loads our signed vulnerable driver, help.sys into memory and write this into this.

28:43.320 --> 28:50.960
And after that it configures the appropriate registry keys to register the service and ensure it starts automatically.

28:51.980 --> 28:53.580
Only two key left.

28:53.580 --> 29:01.740
So type and then arrow control values, start values, arrow control and then the system should start.

29:04.780 --> 29:05.720
Okay.

29:05.720 --> 29:13.560
We need to confirm at first we didn't have a help.sys driver, not the Lenovo native application on the system.

29:13.560 --> 29:24.080
We are trying to put those files from the pre-boot environment and we need to check if after boot, if those files exist.

29:24.080 --> 29:36.880
So once Windows finishes booting, we need to confirm the presence of the help.sys driver and the WPBT, the renamed Lenovo native application.

29:37.360 --> 29:42.620
So first we need to check if our help.sys driver is present on the system.

29:42.860 --> 29:45.080
And here it is.

29:45.420 --> 29:51.620
And we also need to confirm that the Lenovo native application is over there.

29:51.620 --> 29:52.340
And here it is.

29:52.340 --> 29:57.160
We also can check its signature to see if it belongs to Lenovo.

29:57.360 --> 30:05.020
And finally the most important part is that we need to verify that our new service exists.

30:05.720 --> 30:07.160
And here it is.

30:07.160 --> 30:11.060
We have two service drivers installed on the system.

30:11.240 --> 30:17.080
It's successfully loading a kernel driver and on the next reboot it will be launched automatically.

30:17.280 --> 30:22.020
So now we have a vulnerable driver installed from the pre-boot.

30:22.020 --> 30:26.080
And now Borja will show you some ways to express this.

30:36.170 --> 30:37.130
Okay.

30:41.960 --> 30:42.940
Okay.

30:42.940 --> 30:52.160
In this last part of our presentation, we'll show you how we completed the full persistent chain from the system boot using legitimate signed but vulnerable drivers.

30:52.160 --> 30:55.400
The key thing here, we found these vulnerabilities ourselves.

30:55.400 --> 31:02.600
And we are using the method that my colleagues have presented earlier to load this driver right from the system start up.

31:05.760 --> 31:08.180
This is essentially a big WOD.

31:08.180 --> 31:11.100
Brand young vulnerable driver technique but with full control.

31:11.100 --> 31:15.900
We analyze, choose and exploit driver that haven't previously been reported as vulnerable.

31:15.900 --> 31:18.480
Just provided direct kernel access.

31:18.660 --> 31:21.180
Would that this achieve real persistence?

31:21.280 --> 31:26.500
From the moment the system boot until our payload runs without detection by security solutions.

31:26.500 --> 31:27.780
The flow like this.

31:27.780 --> 31:33.140
At the F8 stage we place a signed AFI file loaded before the operating system starts.

31:33.180 --> 31:37.960
From there we automated the loading of one of these vulnerable driver.

31:37.960 --> 31:42.560
Once the driver is loaded, we gain kernel full access using primitives.

31:42.720 --> 31:46.160
With kernel level access we implant silent and persistent malware.

31:46.420 --> 31:55.380
We discover this driver by analyzing numerous artifacts from the Microsoft catalog using retro hand in virus total and exploring other repositories as we've mentioned earlier.

31:55.380 --> 32:01.100
Many of these driver came of major vendor yet they have no detection whatsoever.

32:01.340 --> 32:10.700
We identify vulnerabilities in our CTL handling allowing user land control memory to invoke sensitive function without validation and even modify critical system structures.

32:11.040 --> 32:16.860
With this vulnerability we can bypass driver signal to informant, EDRs and other run time protections.

32:16.860 --> 32:25.160
Hook a driver function by modifying the import of the state board from kernel mode and register system call back to hide our activity and evade detection.

32:25.280 --> 32:29.520
The critical point, there is nothing malicious from the system's perspective.

32:29.520 --> 32:32.920
Everything is signed, legitimate and it's completely vulnerable.

32:33.060 --> 32:36.820
This type of persistent is very hard to detect and even harder to remove.

32:36.820 --> 32:43.360
It plays in a real environment, it ensures total control after every reboot without touching disk or visible processes.

32:44.260 --> 32:47.400
This is a real and interesting case.

32:47.580 --> 32:56.420
A send driver from Huawei not originally intended for malicious use but whose features are perfect for persistent and kernel level protection.

32:56.580 --> 33:02.780
This driver installed with Huawei AI service just remains active even after you install the software.

33:02.780 --> 33:07.120
This persistent behavior is particularly useful for an offensive property.

33:07.320 --> 33:08.800
What does this actually do?

33:08.800 --> 33:18.000
It registers callbacks for process creation and termination using PSR create process notify routine monitoring specific user defined processes.

33:18.080 --> 33:19.740
But this goes further.

33:19.740 --> 33:26.620
It also registers process access filtered via OB register callbacks intercepting calls like open process.

33:27.140 --> 33:34.980
If it detects a dangerous permission like process terminate, it removes them on the fly protecting the process from being killed or injected.

33:35.540 --> 33:40.820
Even if someone manages to terminate the process, the driver automatically restarts it.

33:40.820 --> 33:46.040
It achieves this by injecting an EPC to legitimate processes like service X.

33:46.040 --> 33:49.700
Quietly executing hidden command to restart the target service.

33:53.330 --> 33:58.830
The most serious issue isn't just the driver protect and restart processes from kernel mode.

33:58.830 --> 34:04.350
But that all this power is available from user language that require a privileged signature or validation.

34:04.650 --> 34:08.610
The driver creates a device object accessible by any process.

34:08.690 --> 34:16.390
It's WAI gallery work driver controlling application can send command ignoring right signature authentication needed.

34:16.470 --> 34:21.530
Huawei even provide a tool Eagle check X communicating with the driver via OCTL.

34:21.530 --> 34:31.450
Internally this command trigger OCTL 0X222004 passing a unicode string with the process path like C Windows system 32 notepad X.

34:31.450 --> 34:34.250
It's pointing the driver to protect this process.

34:36.590 --> 34:39.930
Here the vulnerability, the driver validating nothing.

34:40.030 --> 34:48.270
No check of command sender identity, no validation of the process that works in error signature, no limits on which or how many processes can be protected.

34:48.550 --> 34:57.370
This means you can't seal any process including malware, protect your exploitation tools, prevent EDR or forensics tool from killing the processes.

34:57.990 --> 35:08.770
Moreover if the process dies the driver automatically restarted effectively becoming a functional rootkit distributing by legitimate vendor control by sending simple string from user LAN.

35:13.500 --> 35:15.880
From an offensive viewpoint it's perfect.

35:16.480 --> 35:26.300
Kernel level persistence, real time protection, user LAN control, zero validation, authentication, you don't even need to exploit it, the driver isn't inherently vulnerable.

35:27.760 --> 35:35.900
Once the driver receives a command from user LAN to protect a process , for example C Windows 32 notepad X, it's internally validation is extremely weak .

35:36.300 --> 35:45.720
Instead of checking digital signature, hashing binaries or validation executables, it's simple compare the command line as a plain text.

35:46.440 --> 35:57.660
It's called PS get process pip to access the target processes PEB and then uses KE stack attached process to read its command line directly from memory.

35:58.080 --> 36:06.320
Then it compares this command line of string with the one received via OCTL using RTL compare unicode string.

36:06.600 --> 36:07.980
What's wrong here?

36:07.980 --> 36:19.260
Comparison is case sensitive, no path normalization, no handling of symbolic link, space or path variance, only a test comparison, no binary signature hash or meta data verification.

36:20.260 --> 36:25.520
To see simplifications, you can easily bypass protection by slightly altering the path or casing.

36:25.600 --> 36:29.740
You can protect arbitrary processes even malicious ones fully in EDR.

36:30.660 --> 36:33.020
The design is fundamentally broken.

36:33.020 --> 36:37.020
A slight difference in case is enough to bypass or abuse the mechanism.

36:37.200 --> 36:39.440
For attackers this is an opportunity.

36:39.480 --> 36:48.880
Protect malicious payloads as legitimate, evade detection, bypass invalidation, automatically seal anything you run without complex techniques.

36:50.740 --> 36:55.520
Okay, this part of the driver is extremely dangerous for persistence.

36:55.520 --> 37:01.320
Even if the Huawei software is uninstalled, the driver is still loaded in memory with kernel privileges.

37:01.320 --> 37:04.000
Removing it requires manual intervention.

37:04.000 --> 37:07.400
Use command like AC stop, AC delete or remove.

37:07.480 --> 37:13.180
If someone kills a protected process, the driver automatically restarts it without the user line intervention.

37:14.640 --> 37:27.380
It uses APC injection, construct command like AC start my service, find an active thread, it's a trusted process, usually service X, uses key insert QAPC to execute command silently.

37:27.700 --> 37:33.180
The processor restarts silently, invisibly and automatically kernel persist without touching the disk.

37:34.820 --> 37:42.360
This method evades most CDRs because process creation occurs from kernel space rather than user line bypassing security hooks.

37:42.360 --> 37:48.780
For red teams this means stealth persistence, invisible process creation, active defense against terminations.

37:50.880 --> 37:53.920
This driver behavior makes it essentially a primitive rocket.

37:53.920 --> 37:59.340
It not only protects a process but also completely disables normal OS monitoring and control mechanism.

37:59.480 --> 38:05.940
It removes process terminate from kernel mode, blocking user level tools from terminate protected processes.

38:06.000 --> 38:13.480
Everything occurs in kernel space and detectable by user line tools like tax manager, EDRs or antivirus solutions.

38:13.480 --> 38:20.400
Command and control action inject directly into legitimate process like services X for the high end activity.

38:20.760 --> 38:25.680
No signature validation means malicious or custom binaries are protected without detection.

38:26.500 --> 38:35.820
Offensive implications, persistent execution, real time evasion of monitoring and hooks, no user line agents needed for protection.

38:35.820 --> 38:36.500
Okay.

38:36.500 --> 38:37.460
Demo time.

38:46.980 --> 38:47.800
Okay.

38:47.920 --> 38:51.860
First we develop a proof of concept that deploys a malicious service called hell.

38:52.120 --> 39:00.980
When we launch the POC register and start a hell service on the business system, the service directly interacts with the vulnerable driver that we have described earlier.

39:01.320 --> 39:07.120
Upon activation, the service establishes a reverser granting us a remote control over the compromising point.

39:07.120 --> 39:12.820
As a visual indicator, the service also pwned a prompt window displaying the message, hello DEF CON 33.

39:13.660 --> 39:17.360
Confirming successful execution and persistent on the target machine.

39:17.600 --> 39:21.720
Next, we attempt to terminate the malicious process using tax manager.

39:21.720 --> 39:29.000
However, when we took this process, the system immediately returned an access DNA message.

39:30.440 --> 39:35.580
It's a direct result of the kernel protection implemented through the vulnerable driver.

39:35.620 --> 39:39.440
The driver steals away the privileges required to terminate the process.

39:39.520 --> 39:45.340
Effectively hardening the malicious service against any action from EDR tools or local administrative attempts.

39:45.940 --> 39:49.020
The system is protected by an EDR solutions.

39:49.580 --> 39:54.660
Fully operational and configuring with all protection at the highest enforcement level phase 3.

39:55.020 --> 40:01.980
Remote payload execution at active protection against termination, the EDR doesn't generate any alert or suspicious events.

40:02.780 --> 40:08.900
The second part of the demo, we presented a variant leveraging another vulnerable driver to discover our research.

40:08.960 --> 40:11.580
In this case, our role is different.

40:12.000 --> 40:22.540
To bypass protective process light, PPL, and still see terminated process , protective processes such as antivirus or EDR actions.

40:22.940 --> 40:35.340
To achieve this, we exploited the functionality exposed the vulnerable driver, specifically on a CTL interface that allow us to invoke the sub W terminate process function directly from the kernel node.

40:35.340 --> 40:46.140
Using this technique, the driver can terminate highly privileged process including antivirus on EDR without restriction and without generating any alert in the console on the EDR event logs.

40:46.340 --> 40:57.160
As a proof of concept, we've created an executable that interacts with the health service and also leverages the vulnerable function to kill the antivirus on an EDR process, as can be seen in task manager.

40:57.580 --> 41:08.160
As we mentioned before, this is just a POC, but the entire process could be made significantly sturdier and more sophisticated for a real world team operation.

41:10.580 --> 41:11.380
Okay.

41:21.890 --> 41:23.030
Thank you.

41:35.270 --> 41:38.550
To sum up the talk, let's quickly go over the key points.

41:38.550 --> 41:41.970
Secure boot improves security, but this has clear limitations.

41:42.050 --> 41:48.970
We've found that legitimate signed binaries can still be abused, especially when the DVX revocation list isn't properly updated.

41:49.650 --> 41:53.110
UFI remains a critical and often overlooked attack surface.

41:53.390 --> 42:01.530
It's allowed code execution very early in the boot process, far before traditional security tools can react providing a perfect window for persistence.

42:01.890 --> 42:07.350
The bring your vulnerable driver lets us abuse legitimate driver to gain direct kernel access.

42:07.810 --> 42:13.890
We've demonstrated it has poorly implemented your CTL enabled privilege escalation and the ability to disable protections.

42:14.070 --> 42:18.170
Every component we use is legitimate, signed and allowed silently.

42:18.370 --> 42:24.370
We didn't need any traditional malware just public, just a tool that we've revered most offensively.

42:24.510 --> 42:28.890
This clearly shows that the most effective offensive techniques don't rely on obvious malware.

42:29.130 --> 42:35.910
With the right vulnerabilities and smart use of legitimate components, it's possible to fully compromise the system silently and persistently.

42:36.670 --> 42:41.010
If you are interested in digging deeper, here are the references we use for our research.

42:41.130 --> 42:46.230
Don't worry I won't copy them now, the slides will be uploaded after the talk so you can check everything later.

42:47.810 --> 42:50.750
Okay, thank you for your time and attention.

42:50.750 --> 42:53.150
The GitHub repository is now a bible.

42:53.530 --> 42:57.250
We hope you enjoyed the talk and maybe learned something new today.

42:57.390 --> 43:01.090
Also thank you to our friends who have supported us during the project.

43:01.090 --> 43:02.230
Thank you so much.

