1 00:00:00,000 --> 00:00:07,660 It is my absolute pleasure to introduce these two first time DEF CON speakers, Alejandro and Boya. 2 00:00:08,200 --> 00:00:15,680 The title of their talk is Kill Chain Reloaded, Abusing Legacy Pass for Stealth Persistence. 3 00:00:15,680 --> 00:00:17,620 With that, take it away, guys. 4 00:00:24,050 --> 00:00:25,430 Hello, everyone. 5 00:00:25,450 --> 00:00:28,470 First of all, thank you for inviting us to DEF CON. 6 00:00:28,470 --> 00:00:30,930 It's an honor for us to be here. 7 00:00:30,930 --> 00:00:34,810 Our English is not perfect, but we will try to explain everything as clear as possible. 8 00:00:34,890 --> 00:00:37,750 We ask for your patience and please don't be too hard with us. 9 00:00:39,170 --> 00:00:41,690 This is my colleague, Alejandro Hernando. 10 00:00:41,690 --> 00:00:45,950 We both work in the hacking department at Accenture Spain in red team and research. 11 00:00:46,270 --> 00:00:49,190 We love breaking things and finding more abilities. 12 00:00:49,870 --> 00:00:54,950 Here is your social media just in case you want to contact us or ask anything about this talk. 13 00:00:57,110 --> 00:00:58,430 I am Borja Martinez. 14 00:00:58,430 --> 00:01:01,250 I also work in the hacking department at Accenture Spain. 15 00:01:01,250 --> 00:01:06,090 Sometimes I participate in Capture the Flag competition as a member of the team. 16 00:01:06,770 --> 00:01:08,390 But now we are retired. 17 00:01:08,930 --> 00:01:14,130 Here is my social network for any questions or doubts you may have after the presentation. 18 00:01:16,330 --> 00:01:17,230 Okay. 19 00:01:17,810 --> 00:01:22,530 In this part we will focus on how we do threat hunting to find vulnerable artifacts. 20 00:01:22,870 --> 00:01:25,430 Our methodology to look for these drivers. 21 00:01:25,670 --> 00:01:28,590 Specific software and drivers we use in our research. 22 00:01:29,310 --> 00:01:34,570 Vulnerabilities we found in UFI software to develop advanced boot kits and new persistent techniques. 23 00:01:34,610 --> 00:01:39,470 Finally how we use these vulnerable drivers to get persistent in real red team exercises. 24 00:01:42,380 --> 00:01:42,900 Okay. 25 00:01:42,900 --> 00:01:47,980 Before we go deeper we're going to explain why I think this topic is especially important today. 26 00:01:48,340 --> 00:01:53,900 In recent years we have seen that threats which look almost theoretical are now completely real. 27 00:01:54,020 --> 00:02:00,960 Boot kits like Black Lotus for example have managed to run malware on Windows 11 system with secure boot enabled. 28 00:02:01,480 --> 00:02:06,080 So system with all security enabled can still be fully compromised. 29 00:02:06,300 --> 00:02:10,560 And we are not talking about all APTS from 10 years ago. 30 00:02:10,580 --> 00:02:14,720 That is the reality we find when researching low level security. 31 00:02:16,660 --> 00:02:20,740 One common mistake is to think that if you have secure boot enabled you are protected. 32 00:02:20,880 --> 00:02:22,360 But it isn't that simple. 33 00:02:22,360 --> 00:02:28,100 Secure boot works with a list of trusted binaries and another list called DBX for revoked binaries. 34 00:02:28,420 --> 00:02:34,080 If a vulnerable binary is in the DBX secure boot will allow it anyway even if it's compromised. 35 00:02:34,120 --> 00:02:36,940 Also many vendors don't update that quickly. 36 00:02:37,900 --> 00:02:43,280 There are cases where it takes months to revoke binaries with critical vulnerabilities like Black Lotus. 37 00:02:45,720 --> 00:02:49,200 But not everything is caught by attackers. 38 00:02:49,200 --> 00:02:51,440 Sometimes there are failures from inside. 39 00:02:51,460 --> 00:02:55,380 In July 2024 a crash type update broke computers all over the world. 40 00:02:55,560 --> 00:03:02,460 The faulty agents could abuse this especially in corporate environment as airport, banks, hospital or were affected. 41 00:03:02,860 --> 00:03:08,020 And this was without malware, without exploit, only about binary running a critical part of the system. 42 00:03:08,340 --> 00:03:13,580 We mention this because boot kits won the single level of control but with a malicious and persistent goal. 43 00:03:13,800 --> 00:03:17,620 It's a good example of how one single binary can break everything. 44 00:03:20,180 --> 00:03:25,780 Here is a quick table with some of the most well known boot kits used in real operations. 45 00:03:25,840 --> 00:03:27,440 Many link to APTS. 46 00:03:27,720 --> 00:03:33,200 Most of them load before the operating system so no EDR, antivirus or side channel solution can see them. 47 00:03:33,340 --> 00:03:36,240 They control the system from the moment you turn it on. 48 00:03:38,900 --> 00:03:39,660 Okay. 49 00:03:40,060 --> 00:03:42,760 We have been researching all this for a long time. 50 00:03:42,760 --> 00:03:49,100 We want persistent, we have used vulnerable software, signed files in trusting drivers. 51 00:03:49,220 --> 00:03:52,740 And change everything to execution and total control. 52 00:03:52,740 --> 00:03:58,040 We will show how we did threat hunting for signed artifacts that lets us do this in real scenarios. 53 00:04:01,560 --> 00:04:08,980 You will see how we use virus total, retro hunt and the Microsoft catalog to find components with useful functions. 54 00:04:09,360 --> 00:04:12,540 Physical memory access, can I rewrite and so on. 55 00:04:12,680 --> 00: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. 56 00:04:20,820 --> 00:04:26,000 And the most important thing is how to use all this in real extreme exercises without raising alert. 57 00:04:27,060 --> 00:04:27,920 Okay. 58 00:04:28,020 --> 00:04:28,980 Demo time. 59 00:04:41,320 --> 00:04:42,080 Okay. 60 00:04:42,280 --> 00:04:46,100 Here you can see someone can link to a virus total enterprise account. 61 00:04:46,100 --> 00:04:48,240 In virus total we do two main things. 62 00:04:48,360 --> 00:04:52,200 Search basic things or use the other rules with retro hunt. 63 00:04:52,280 --> 00:04:57,020 For retro hunt as you can see our script uses pin port to select interesting functions. 64 00:04:57,040 --> 00: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. 65 00:05:04,920 --> 00:05:09,780 We do a quick demo run, as you can see it finds many drivers with those functions very fast. 66 00:05:10,460 --> 00:05:14,700 That's running and before we had already launched two more. 67 00:05:15,340 --> 00:05:20,220 One with 4,000 results and another with 10,000 results. 68 00:05:21,480 --> 00:05:27,360 On the other hand we sometimes search for things like WPBH which Alejandro will explain later. 69 00:05:28,500 --> 00:05:31,860 We attach for example to only see same binaries. 70 00:05:37,070 --> 00:05:47,410 And I will say it's by looking for certificates like Microsoft Windows UFI driver, publisher or Microsoft corporation UFI CR2011. 71 00:05:54,740 --> 00:06:01,180 There are more options but these are a few examples so I don't understand how we search for useful binaries. 72 00:06:04,230 --> 00:06:09,050 The demo is ‑‑ okay. 73 00:06:09,890 --> 00:06:15,330 Here for example you see 64 AFI and it's all the binary sign. 74 00:06:21,250 --> 00:06:22,110 Okay. 75 00:06:22,110 --> 00:06:26,190 Also based on research from GitHub project we made this script. 76 00:06:26,350 --> 00:06:31,190 The script inquires to a Microsoft catalog like we have done before with retro hunt. 77 00:06:31,190 --> 00:06:33,490 Searching for driver with interesting function. 78 00:06:33,690 --> 00:06:35,010 Now we run this script. 79 00:06:35,010 --> 00:06:38,690 It searches all the pages and when it finds a string like go away. 80 00:06:38,970 --> 00:06:39,850 Spoiler. 81 00:06:40,070 --> 00:06:41,990 It downloads all the files. 82 00:06:42,790 --> 00: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. 83 00:06:51,750 --> 00:06:55,430 With the next demo you will see more clearly how we use these files. 84 00:07:23,600 --> 00:07:24,560 Okay. 85 00:07:27,780 --> 00: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. 86 00:07:37,200 --> 00:07:41,860 When we turn on a computer the first thing that runs is not Windows, not ADR, not antivirus. 87 00:07:41,860 --> 00:07:43,080 The firmware runs first. 88 00:07:43,080 --> 00:07:44,040 UFI. 89 00:07:44,200 --> 00:07:49,080 UFI is like a operating system without memory, heap, services and drivers. 90 00:07:49,180 --> 00:07:55,680 It has many phases but the most interesting for us is DXE where EFI modules are loaded. 91 00:07:55,760 --> 00:08:00,880 After initial UFI runs the loader which loads the system kernel. 92 00:08:00,920 --> 00:08:06,140 In Windows it's usually booting GFWUFI or booting GREFI. 93 00:08:06,220 --> 00:08:09,720 In Linux it can be grab, sim or something custom. 94 00:08:09,960 --> 00:08:11,540 And here is the key point. 95 00:08:11,540 --> 00:08:16,820 Everything that's happened before ExitBoot services it's outside the radar of formal security solutions. 96 00:08:16,860 --> 00: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. 97 00:08:25,860 --> 00:08:30,980 And now I give the floor to my colleague Alejandro who will explain this part in more detail. 98 00:08:35,280 --> 00:08:37,100 Okay, just a second. 99 00:08:42,720 --> 00:08:44,140 All right. 100 00:08:44,220 --> 00:08:49,080 As we discussed before you can't just run an EFI binary on the system. 101 00:08:49,140 --> 00:08:56,780 We must consider the security mechanisms that Windows implement to block the execution in the preboot environment. 102 00:08:59,120 --> 00:09:05,640 Secureboot aims to block the execution of an authorized code from running in the preboot environment. 103 00:09:05,680 --> 00:09:10,880 It does so by allowing only signed trusted binaries to execute. 104 00:09:11,000 --> 00:09:14,540 However, there are a lot of vulnerable applications in the wild. 105 00:09:14,540 --> 00:09:17,240 For example, Neorizon DataSuite boot loaders. 106 00:09:17,240 --> 00:09:22,220 Neorizon DataSuite boot loaders before June 2022 were assigned. 107 00:09:22,220 --> 00:09:24,680 However, they were also vulnerable. 108 00:09:25,000 --> 00:09:29,560 They allow the loading of arbitrary unsigned EFI binaries. 109 00:09:29,760 --> 00: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. 110 00:09:39,540 --> 00:09:42,640 Including settings and boot flow. 111 00:09:43,500 --> 00:09:52,080 On the other hand, Microsoft mitigates this class of secureboot bypasses like the Neorizon DataSuite boot loaders using the DVX. 112 00:09:52,080 --> 00:10:02,400 DVX is a UFI secureboot revocation list and it contains signatures of known binaries that are no longer trusted. 113 00:10:02,400 --> 00:10:05,620 Even if they were originally signed. 114 00:10:05,680 --> 00:10:11,740 Even though the binary is signed, secureboot refuses to execute if it matches any DVX entry. 115 00:10:11,960 --> 00:10:15,900 Microsoft distributes DVX through Windows updates. 116 00:10:15,900 --> 00:10:19,180 Usually as part of regular security patches. 117 00:10:19,180 --> 00: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. 118 00:10:31,740 --> 00:10:40,940 This repository allows security researchers to inspect which UFI boot loaders and certificates have been revoked by secureboot updates. 119 00:10:42,140 --> 00: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. 120 00:10:55,360 --> 00:11:00,100 We found that some versions of shield loader are correctly listed in the DVX. 121 00:11:00,100 --> 00:11:03,660 Specifically, those matching the hash line above. 122 00:11:03,880 --> 00:11:08,480 This hash corresponds to the entries of the CVE we talked about before. 123 00:11:08,480 --> 00:11:13,060 However, we also found several other versions of the boot loader. 124 00:11:13,060 --> 00:11:17,000 These have different hashes and were not present in the DVX. 125 00:11:17,120 --> 00:11:22,240 This suggests that additional vulnerable variants of shield loader may exist in the wild. 126 00:11:22,240 --> 00: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. 127 00:11:31,740 --> 00:11:37,060 So, let's now take a closer look at how reboot restore actually works. 128 00:11:37,060 --> 00:11:43,980 Reboot restore is a software that restores a computer to a preset state every time it restarts. 129 00:11:43,980 --> 00:11:47,420 Its main EFI binary is shield loader. 130 00:11:47,420 --> 00:11:53,040 Before we get into the loader internals, here's how shield loader gets into the chain. 131 00:11:53,260 --> 00:11:59,080 First, looks for the ESP, the EFI system partition for the boot loader. 132 00:11:59,740 --> 00:12:05,980 Shield loader is renamed or copied over the boot loader. 133 00:12:05,980 --> 00:12:10,900 When the finger invokes boot loader, it actually runs shield loader first. 134 00:12:11,080 --> 00:12:19,720 Shield loader then implements its own logic, the compression, signature checks and so on, before finally loading the real boot manager. 135 00:12:21,060 --> 00:12:23,620 Okay, but what does shield loader do? 136 00:12:23,620 --> 00:12:28,720 We divide the shield loader operation in four phases. 137 00:12:28,960 --> 00:12:36,580 First, shield loader opened the ESP volume, located the file shield manager underscore, notice underscore, this is important. 138 00:12:36,900 --> 00:12:40,660 Allocate the file size and read all bytes into a buffer. 139 00:12:40,740 --> 00:12:45,760 If that works, we end up with the proprietary format binary, NAUI. 140 00:12:46,100 --> 00:12:51,440 In memory, if it fails, the loader falls back to scanning every installed finger volume. 141 00:12:51,600 --> 00:12:53,820 We'll talk about this proprietary format later. 142 00:12:54,780 --> 00:12:57,440 Then, the loader invokes parse heater. 143 00:12:57,440 --> 00: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. 144 00:13:07,180 --> 00:13:09,320 After that, it goes through the chunks. 145 00:13:09,320 --> 00: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. 146 00:13:18,120 --> 00:13:21,380 And this is how the proprietary format looks like. 147 00:13:21,380 --> 00:13:23,820 This is the EF underscore format. 148 00:13:23,820 --> 00:13:30,040 We have the 200 byte heaters, with magic, compressed and uncompressed file length. 149 00:13:30,040 --> 00:13:31,180 Then the chunks. 150 00:13:31,180 --> 00:13:33,260 Mark as compressed or not. 151 00:13:33,260 --> 00:13:37,560 And finally, the trailer where the signature is located. 152 00:13:39,020 --> 00:13:45,880 After that, the shield loader looks for the signature of the trailer, the last 800 bytes. 153 00:13:46,300 --> 00:13:50,920 So after decompressing and allocating the image, the boot loader goes into phase three. 154 00:13:50,920 --> 00:13:54,540 In this phase, the loader invokes check signature. 155 00:13:54,540 --> 00:14:00,760 Then it jumps to the last 800 bytes of the buffer where it inspects the trailer. 156 00:14:00,880 --> 00: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. 157 00:14:11,820 --> 00:14:17,500 Finally, in phase four, the loader hands off to the standard EFI boot services. 158 00:14:17,720 --> 00:14:22,140 It calls load image and returns a new EFI handle. 159 00:14:22,160 --> 00:14:27,700 It then invokes a start image, which transfers control into the loaded P. 160 00:14:27,700 --> 00:14:31,300 And this is almost the full chain of shield loader. 161 00:14:31,300 --> 00:14:35,680 But we also found an interesting proprietary format EFI file. 162 00:14:35,680 --> 00:14:39,880 Remember that underscore EFI files like this. 163 00:14:39,880 --> 00:14:47,460 Additionally, in one finger version, we discover a containing name shell dot EF underscore. 164 00:14:47,460 --> 00:14:54,080 This is actually a sign UFI shell binary with only a small subset of command enable. 165 00:14:54,080 --> 00:15:03,120 Although if functionality is limited, we can leverage it later as a convenient trusted entry point into the UFI environment. 166 00:15:04,440 --> 00:15:07,300 Right, but what does shell loader do? 167 00:15:07,420 --> 00:15:13,200 Remember that shield loader loads shield manager. 168 00:15:13,200 --> 00:15:23,340 So after the compression, the EFI in shield manager, the loader skips the custom format and directly load another EFI image. 169 00:15:24,060 --> 00:15:32,080 Any EFI executable placed at shield dot EFI at ESP will be loaded and run without checks. 170 00:15:32,080 --> 00:15:34,080 This means two things. 171 00:15:34,080 --> 00:15:36,680 First, there's no security verification. 172 00:15:36,680 --> 00:15:40,320 Load unsigned EFI never calls check signature. 173 00:15:40,320 --> 00:15:42,400 Also, there is no container parsing. 174 00:15:42,600 --> 00:15:46,240 It expects an extra P image so you can drop any EFI file there. 175 00:15:46,240 --> 00: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. 176 00:15:55,920 --> 00:16:03,880 So this is supported so we can abuse this to load our own unsigned EFI binary. 177 00:16:03,880 --> 00:16:06,220 So let's look at this in a demo. 178 00:16:10,500 --> 00:16:11,080 Okay, so this is the demo . 179 00:16:11,080 --> 00:16:11,680 Okay . 180 00:16:13,740 --> 00:16:15,340 Well, let's begin the demo. 181 00:16:15,340 --> 00:16:18,960 First, we verify that secure boot is enabled. 182 00:16:19,140 --> 00:16:25,880 If the publisher command returns true, it means secure boot is active and functioning properly. 183 00:16:25,880 --> 00:16:28,900 In this case, we can see that this is enabled. 184 00:16:29,280 --> 00:16:32,140 Next, we run our EFI install. 185 00:16:32,160 --> 00:16:37,820 This tool replaces the files in the ESP, EFI system partition, with our own. 186 00:16:37,820 --> 00:16:41,940 So what happens after the system reboots? 187 00:16:41,940 --> 00:16:46,500 Remember that we have replaced it, the original boot loader, with our install. 188 00:16:46,500 --> 00:16:50,680 At this point, shield loader loads shield manager. 189 00:16:50,680 --> 00:16:57,680 Shield manager then loads shield dot EFI, which is our custom unsigned binary. 190 00:16:57,840 --> 00:17:05,240 This binary calls and reallocates another image and at this point, this binary displays this custom SDR splash screen. 191 00:17:05,740 --> 00:17:12,500 And once the animation completes, we chain load the original boot manager and Windows boot success. 192 00:17:13,160 --> 00:17:14,460 Okay. 193 00:17:22,910 --> 00:17:26,850 So, but, what about the local protection? 194 00:17:26,850 --> 00: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. 195 00:17:36,330 --> 00:17:44,230 With secure boot enable, usually PCR7 records a hash of every EFI executable that runs from the kernel. 196 00:17:44,230 --> 00:17:48,690 Boot manager, VCD, early drivers, and so on. 197 00:17:48,710 --> 00:18:00,270 If any one PCR is different, after boot, the comparison, the unseal fails and Windows falls back to BitLocker recovery mode. 198 00:18:00,610 --> 00:18:04,150 Okay, so, what does our proof of concept do? 199 00:18:04,150 --> 00:18:08,090 First, we suspend BitLocker protection indefinitely. 200 00:18:08,210 --> 00:18:15,930 We achieve this by using WMI to run disabled key protectors with disabled count equal to zero. 201 00:18:15,930 --> 00:18:22,650 This prevents triggering BitLocker recovery after modifying EFI files in the ESP partition. 202 00:18:22,650 --> 00:18:31,550 Then, we mount the EFI system partition, backup original boot loaders, and save boot manager and boot 64 for later restoration. 203 00:18:31,930 --> 00:18:34,890 Finally, we apply the modified boot files. 204 00:18:34,890 --> 00: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. 205 00:18:52,030 --> 00: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. 206 00:19:02,490 --> 00:19:11,030 And last but not least, we copy loader dot EFI that is our final unsigned payload into ESP. 207 00:19:11,530 --> 00:19:13,310 Okay, that was a lot of things. 208 00:19:13,310 --> 00:19:15,830 Let's see it in action. 209 00:19:16,470 --> 00:19:17,550 Okay. 210 00:19:22,670 --> 00:19:23,670 Good. 211 00:19:24,130 --> 00:19:29,450 In this demo, we start by verifying that BitLocker protection is enabled. 212 00:19:29,530 --> 00:19:36,090 Using the manage BD command, we confirm that BitLocker is indeed active. 213 00:19:36,150 --> 00:19:40,990 After that, we run our EFI installer and reboot the system. 214 00:19:42,950 --> 00:19:47,870 Remember that secure boot is also enabled at this point. 215 00:19:48,850 --> 00: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. 216 00:19:59,370 --> 00: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. 217 00:20:10,210 --> 00:20:13,990 The EFI shell with a limited command set enable. 218 00:20:14,550 --> 00:20:18,630 From this restricted EFI shell, we download a stage zero. 219 00:20:18,630 --> 00:20:24,190 A sign EFI binary designed to enroll any binary into the machine owner key. 220 00:20:24,370 --> 00:20:31,890 In this case, we enroll loader dot EFI, which is actually a fully functional version of the EFI shell. 221 00:20:32,250 --> 00:20:38,570 Now that we have a fully capable shell, let's attempt to load and sign EFI binary. 222 00:20:38,670 --> 00:20:43,090 As expected, this fails because secure boot is still enforced. 223 00:20:43,330 --> 00: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. 224 00:20:53,530 --> 00:21:00,650 Once identified, we patch them with the opcodes XR, RAX, RAX, and then return. 225 00:21:01,190 --> 00: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. 226 00:21:14,530 --> 00:21:25,690 For demonstration purposes, we are applying the patch byte-by-byte, rather than using a more automated or optimized method. 227 00:21:25,730 --> 00:21:33,450 So we just show up the left, and then return. 228 00:21:33,490 --> 00:21:38,350 This should disable the secure boot validation mechanism. 229 00:21:38,470 --> 00:21:45,250 So now, we need to try to run our EFI and sign EFI binary again. 230 00:21:45,250 --> 00: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. 231 00:22:02,510 --> 00:22:03,570 All right. 232 00:22:05,430 --> 00:22:07,110 Thank you. 233 00:22:08,130 --> 00:22:10,090 Okay, let's continue. 234 00:22:13,100 --> 00:22:14,860 Well, enough of CR. 235 00:22:14,860 --> 00:22:19,420 Let's do something more interesting, like achieving persistence. 236 00:22:19,600 --> 00:22:25,660 One technique we can try to abuse is WPPT, the Windows Platform Binary Table. 237 00:22:25,760 --> 00:22:34,820 WPPT lets the firmware place one native application as C Windows System 32 and execute it in the session manager context. 238 00:22:35,160 --> 00:22:35,960 This is important. 239 00:22:35,960 --> 00:22:42,320 In other research, this approach appears to work when the binary is signed with an old certificate. 240 00:22:42,600 --> 00:22:48,980 However, in our test on Windows 11 2482, this doesn't work if the certificate is revoked. 241 00:22:49,200 --> 00:22:56,060 Since many of the leaked co-signing certificates are now revoked, we need to find new ways to achieve our goals. 242 00:22:56,520 --> 00:23:00,240 So we can simply drop in a native application and run it. 243 00:23:00,240 --> 00:23:02,500 That's a problem, because we need to modify it. 244 00:23:02,500 --> 00:23:08,940 But what if instead we find a signed native application that's vulnerable and exploit it to do whatever we want? 245 00:23:09,240 --> 00:23:11,540 And that's exactly what we've done. 246 00:23:13,200 --> 00:23:16,900 We've found a signed application from Lenovo. 247 00:23:16,900 --> 00: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. 248 00:23:28,480 --> 00:23:37,320 It uses a proprietary ACP table called LUFT table that isn't part of the ACP specification. 249 00:23:37,320 --> 00:23:40,420 Only Lenovo's binary parses it. 250 00:23:40,700 --> 00:23:48,200 This lets an attacker to install an arbitrary driver or service completely from ACP. 251 00:23:48,200 --> 00:23:52,620 So you are installing after the boot from the pre-boot environment. 252 00:23:52,620 --> 00:23:54,360 This will be interesting. 253 00:23:54,720 --> 00:24:00,380 So no disk write needed until the session manager does it for you. 254 00:24:00,580 --> 00:24:06,340 So we need to construct a new LUFT table, a new Lenovo table. 255 00:24:06,400 --> 00:24:09,080 That needs to drop help.sys. 256 00:24:09,080 --> 00:24:14,700 Help.sys is a non-signed vulnerable driver we found over there. 257 00:24:15,760 --> 00:24:19,500 We use this to construct our LUFT table. 258 00:24:19,700 --> 00:24:26,240 Then we also need to fill our table to create a service key under, for example, two server driver. 259 00:24:26,240 --> 00:24:27,580 It can be whatever name. 260 00:24:27,980 --> 00:24:32,680 We also need to set display name, image path, type, error control values. 261 00:24:32,680 --> 00:24:36,640 And after that we reuse slot 6 in the STD. 262 00:24:36,640 --> 00:24:41,640 The slot 6 points to the SMT entry of the OEMs. 263 00:24:41,700 --> 00:24:52,000 We need that slot points to the start of our buffer that we filled with our LUFT table. 264 00:24:52,000 --> 00:24:55,000 After that we also need to fix the checksum. 265 00:24:56,120 --> 00:25:00,340 Okay, but what does the Lenovo native application do? 266 00:25:00,500 --> 00: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. 267 00:25:12,980 --> 00: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. 268 00:25:23,560 --> 00:25:27,360 Right, we also need to construct our WPBT. 269 00:25:27,360 --> 00: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. 270 00:25:34,880 --> 00:25:41,100 So we can allocate and copy our real payload that is the Lenovo native sign application there. 271 00:25:41,240 --> 00:25:47,920 We also need to overwrite the first 16 bytes in the SRAT with this WPBT heater. 272 00:25:47,920 --> 00:25:53,220 This silently turns the SRAT into a WPBT and the system observes it. 273 00:25:53,220 --> 00:25:55,540 We also need to fix the checksum. 274 00:25:55,540 --> 00:25:58,820 So to summarize what we are going to do. 275 00:25:59,040 --> 00:26:06,440 Finger first finish post enters accessible services and real time memory still contains our injected blobs. 276 00:26:06,540 --> 00: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. 277 00:26:20,820 --> 00: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. 278 00:26:29,900 --> 00: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. 279 00:26:42,660 --> 00:26:48,080 On the next boot, Windows sees a legitimate driver entry under services to service driver. 280 00:26:48,080 --> 00:26:51,800 Loads help.sys and the system is compromised. 281 00:26:51,800 --> 00:26:54,600 It's better to see it in action. 282 00:27:03,460 --> 00:27:11,360 In this demo we once again begin by verifying that secure boot is enabled. 283 00:27:13,620 --> 00:27:18,980 We also confirm that the target service that we are using does not exist on the system. 284 00:27:18,980 --> 00:27:22,340 We are going to do everything of this from the pre-boot environment. 285 00:27:22,740 --> 00: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. 286 00:27:34,700 --> 00:27:37,580 We then proceed to reboot the machine. 287 00:27:37,820 --> 00:27:46,580 Upon reboot we chain load our custom EFI binary which launches an EFI shell for demonstration purposes. 288 00:27:47,080 --> 00:27:49,480 Wait a few seconds until the system reboots. 289 00:27:51,300 --> 00:27:52,240 Okay. 290 00:27:52,820 --> 00:27:59,580 So remember we modified the EFI system partition to replace the boot loader with shield loader then shield manager. 291 00:27:59,580 --> 00: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. 292 00:28:07,480 --> 00: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. 293 00:28:18,480 --> 00:28:22,080 The Lenovo custom table. 294 00:28:22,900 --> 00:28:31,140 As the system boots, the session manager executes the Lenovo native application before prompting the user to log in. 295 00:28:31,360 --> 00:28:33,600 So here it is. 296 00:28:33,600 --> 00:28:43,060 Then the application with the LUFT table loads our signed vulnerable driver, help.sys into memory and write this into this. 297 00:28:43,320 --> 00:28:50,960 And after that it configures the appropriate registry keys to register the service and ensure it starts automatically. 298 00:28:51,980 --> 00:28:53,580 Only two key left. 299 00:28:53,580 --> 00:29:01,740 So type and then arrow control values, start values, arrow control and then the system should start. 300 00:29:04,780 --> 00:29:05,720 Okay. 301 00:29:05,720 --> 00: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. 302 00:29:13,560 --> 00: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. 303 00:29:24,080 --> 00: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. 304 00:29:37,360 --> 00:29:42,620 So first we need to check if our help.sys driver is present on the system. 305 00:29:42,860 --> 00:29:45,080 And here it is. 306 00:29:45,420 --> 00:29:51,620 And we also need to confirm that the Lenovo native application is over there. 307 00:29:51,620 --> 00:29:52,340 And here it is. 308 00:29:52,340 --> 00:29:57,160 We also can check its signature to see if it belongs to Lenovo. 309 00:29:57,360 --> 00:30:05,020 And finally the most important part is that we need to verify that our new service exists. 310 00:30:05,720 --> 00:30:07,160 And here it is. 311 00:30:07,160 --> 00:30:11,060 We have two service drivers installed on the system. 312 00:30:11,240 --> 00:30:17,080 It's successfully loading a kernel driver and on the next reboot it will be launched automatically. 313 00:30:17,280 --> 00:30:22,020 So now we have a vulnerable driver installed from the pre-boot. 314 00:30:22,020 --> 00:30:26,080 And now Borja will show you some ways to express this. 315 00:30:36,170 --> 00:30:37,130 Okay. 316 00:30:41,960 --> 00:30:42,940 Okay. 317 00:30:42,940 --> 00: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. 318 00:30:52,160 --> 00:30:55,400 The key thing here, we found these vulnerabilities ourselves. 319 00:30:55,400 --> 00: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. 320 00:31:05,760 --> 00:31:08,180 This is essentially a big WOD. 321 00:31:08,180 --> 00:31:11,100 Brand young vulnerable driver technique but with full control. 322 00:31:11,100 --> 00:31:15,900 We analyze, choose and exploit driver that haven't previously been reported as vulnerable. 323 00:31:15,900 --> 00:31:18,480 Just provided direct kernel access. 324 00:31:18,660 --> 00:31:21,180 Would that this achieve real persistence? 325 00:31:21,280 --> 00:31:26,500 From the moment the system boot until our payload runs without detection by security solutions. 326 00:31:26,500 --> 00:31:27,780 The flow like this. 327 00:31:27,780 --> 00:31:33,140 At the F8 stage we place a signed AFI file loaded before the operating system starts. 328 00:31:33,180 --> 00:31:37,960 From there we automated the loading of one of these vulnerable driver. 329 00:31:37,960 --> 00:31:42,560 Once the driver is loaded, we gain kernel full access using primitives. 330 00:31:42,720 --> 00:31:46,160 With kernel level access we implant silent and persistent malware. 331 00:31:46,420 --> 00: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. 332 00:31:55,380 --> 00:32:01,100 Many of these driver came of major vendor yet they have no detection whatsoever. 333 00:32:01,340 --> 00: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. 334 00:32:11,040 --> 00:32:16,860 With this vulnerability we can bypass driver signal to informant, EDRs and other run time protections. 335 00:32:16,860 --> 00: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. 336 00:32:25,280 --> 00:32:29,520 The critical point, there is nothing malicious from the system's perspective. 337 00:32:29,520 --> 00:32:32,920 Everything is signed, legitimate and it's completely vulnerable. 338 00:32:33,060 --> 00:32:36,820 This type of persistent is very hard to detect and even harder to remove. 339 00:32:36,820 --> 00:32:43,360 It plays in a real environment, it ensures total control after every reboot without touching disk or visible processes. 340 00:32:44,260 --> 00:32:47,400 This is a real and interesting case. 341 00:32:47,580 --> 00: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. 342 00:32:56,580 --> 00:33:02,780 This driver installed with Huawei AI service just remains active even after you install the software. 343 00:33:02,780 --> 00:33:07,120 This persistent behavior is particularly useful for an offensive property. 344 00:33:07,320 --> 00:33:08,800 What does this actually do? 345 00:33:08,800 --> 00:33:18,000 It registers callbacks for process creation and termination using PSR create process notify routine monitoring specific user defined processes. 346 00:33:18,080 --> 00:33:19,740 But this goes further. 347 00:33:19,740 --> 00:33:26,620 It also registers process access filtered via OB register callbacks intercepting calls like open process. 348 00:33:27,140 --> 00: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. 349 00:33:35,540 --> 00:33:40,820 Even if someone manages to terminate the process, the driver automatically restarts it. 350 00:33:40,820 --> 00:33:46,040 It achieves this by injecting an EPC to legitimate processes like service X. 351 00:33:46,040 --> 00:33:49,700 Quietly executing hidden command to restart the target service. 352 00:33:53,330 --> 00:33:58,830 The most serious issue isn't just the driver protect and restart processes from kernel mode. 353 00:33:58,830 --> 00:34:04,350 But that all this power is available from user language that require a privileged signature or validation. 354 00:34:04,650 --> 00:34:08,610 The driver creates a device object accessible by any process. 355 00:34:08,690 --> 00:34:16,390 It's WAI gallery work driver controlling application can send command ignoring right signature authentication needed. 356 00:34:16,470 --> 00:34:21,530 Huawei even provide a tool Eagle check X communicating with the driver via OCTL. 357 00:34:21,530 --> 00:34:31,450 Internally this command trigger OCTL 0X222004 passing a unicode string with the process path like C Windows system 32 notepad X. 358 00:34:31,450 --> 00:34:34,250 It's pointing the driver to protect this process. 359 00:34:36,590 --> 00:34:39,930 Here the vulnerability, the driver validating nothing. 360 00:34:40,030 --> 00: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. 361 00:34:48,550 --> 00: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. 362 00:34:57,990 --> 00: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. 363 00:35:13,500 --> 00:35:15,880 From an offensive viewpoint it's perfect. 364 00:35:16,480 --> 00: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. 365 00:35:27,760 --> 00: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 . 366 00:35:36,300 --> 00:35:45,720 Instead of checking digital signature, hashing binaries or validation executables, it's simple compare the command line as a plain text. 367 00:35:46,440 --> 00: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. 368 00:35:58,080 --> 00:36:06,320 Then it compares this command line of string with the one received via OCTL using RTL compare unicode string. 369 00:36:06,600 --> 00:36:07,980 What's wrong here? 370 00:36:07,980 --> 00: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. 371 00:36:20,260 --> 00:36:25,520 To see simplifications, you can easily bypass protection by slightly altering the path or casing. 372 00:36:25,600 --> 00:36:29,740 You can protect arbitrary processes even malicious ones fully in EDR. 373 00:36:30,660 --> 00:36:33,020 The design is fundamentally broken. 374 00:36:33,020 --> 00:36:37,020 A slight difference in case is enough to bypass or abuse the mechanism. 375 00:36:37,200 --> 00:36:39,440 For attackers this is an opportunity. 376 00:36:39,480 --> 00:36:48,880 Protect malicious payloads as legitimate, evade detection, bypass invalidation, automatically seal anything you run without complex techniques. 377 00:36:50,740 --> 00:36:55,520 Okay, this part of the driver is extremely dangerous for persistence. 378 00:36:55,520 --> 00:37:01,320 Even if the Huawei software is uninstalled, the driver is still loaded in memory with kernel privileges. 379 00:37:01,320 --> 00:37:04,000 Removing it requires manual intervention. 380 00:37:04,000 --> 00:37:07,400 Use command like AC stop, AC delete or remove. 381 00:37:07,480 --> 00:37:13,180 If someone kills a protected process, the driver automatically restarts it without the user line intervention. 382 00:37:14,640 --> 00: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. 383 00:37:27,700 --> 00:37:33,180 The processor restarts silently, invisibly and automatically kernel persist without touching the disk. 384 00:37:34,820 --> 00:37:42,360 This method evades most CDRs because process creation occurs from kernel space rather than user line bypassing security hooks. 385 00:37:42,360 --> 00:37:48,780 For red teams this means stealth persistence, invisible process creation, active defense against terminations. 386 00:37:50,880 --> 00:37:53,920 This driver behavior makes it essentially a primitive rocket. 387 00:37:53,920 --> 00:37:59,340 It not only protects a process but also completely disables normal OS monitoring and control mechanism. 388 00:37:59,480 --> 00:38:05,940 It removes process terminate from kernel mode, blocking user level tools from terminate protected processes. 389 00:38:06,000 --> 00:38:13,480 Everything occurs in kernel space and detectable by user line tools like tax manager, EDRs or antivirus solutions. 390 00:38:13,480 --> 00:38:20,400 Command and control action inject directly into legitimate process like services X for the high end activity. 391 00:38:20,760 --> 00:38:25,680 No signature validation means malicious or custom binaries are protected without detection. 392 00:38:26,500 --> 00:38:35,820 Offensive implications, persistent execution, real time evasion of monitoring and hooks, no user line agents needed for protection. 393 00:38:35,820 --> 00:38:36,500 Okay. 394 00:38:36,500 --> 00:38:37,460 Demo time. 395 00:38:46,980 --> 00:38:47,800 Okay. 396 00:38:47,920 --> 00:38:51,860 First we develop a proof of concept that deploys a malicious service called hell. 397 00:38:52,120 --> 00: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. 398 00:39:01,320 --> 00:39:07,120 Upon activation, the service establishes a reverser granting us a remote control over the compromising point. 399 00:39:07,120 --> 00:39:12,820 As a visual indicator, the service also pwned a prompt window displaying the message, hello DEF CON 33. 400 00:39:13,660 --> 00:39:17,360 Confirming successful execution and persistent on the target machine. 401 00:39:17,600 --> 00:39:21,720 Next, we attempt to terminate the malicious process using tax manager. 402 00:39:21,720 --> 00:39:29,000 However, when we took this process, the system immediately returned an access DNA message. 403 00:39:30,440 --> 00:39:35,580 It's a direct result of the kernel protection implemented through the vulnerable driver. 404 00:39:35,620 --> 00:39:39,440 The driver steals away the privileges required to terminate the process. 405 00:39:39,520 --> 00:39:45,340 Effectively hardening the malicious service against any action from EDR tools or local administrative attempts. 406 00:39:45,940 --> 00:39:49,020 The system is protected by an EDR solutions. 407 00:39:49,580 --> 00:39:54,660 Fully operational and configuring with all protection at the highest enforcement level phase 3. 408 00:39:55,020 --> 00:40:01,980 Remote payload execution at active protection against termination, the EDR doesn't generate any alert or suspicious events. 409 00:40:02,780 --> 00:40:08,900 The second part of the demo, we presented a variant leveraging another vulnerable driver to discover our research. 410 00:40:08,960 --> 00:40:11,580 In this case, our role is different. 411 00:40:12,000 --> 00:40:22,540 To bypass protective process light, PPL, and still see terminated process , protective processes such as antivirus or EDR actions. 412 00:40:22,940 --> 00: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. 413 00:40:35,340 --> 00: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. 414 00:40:46,340 --> 00: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. 415 00:40:57,580 --> 00: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. 416 00:41:10,580 --> 00:41:11,380 Okay. 417 00:41:21,890 --> 00:41:23,030 Thank you. 418 00:41:35,270 --> 00:41:38,550 To sum up the talk, let's quickly go over the key points. 419 00:41:38,550 --> 00:41:41,970 Secure boot improves security, but this has clear limitations. 420 00:41:42,050 --> 00:41:48,970 We've found that legitimate signed binaries can still be abused, especially when the DVX revocation list isn't properly updated. 421 00:41:49,650 --> 00:41:53,110 UFI remains a critical and often overlooked attack surface. 422 00:41:53,390 --> 00: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. 423 00:42:01,890 --> 00:42:07,350 The bring your vulnerable driver lets us abuse legitimate driver to gain direct kernel access. 424 00:42:07,810 --> 00:42:13,890 We've demonstrated it has poorly implemented your CTL enabled privilege escalation and the ability to disable protections. 425 00:42:14,070 --> 00:42:18,170 Every component we use is legitimate, signed and allowed silently. 426 00:42:18,370 --> 00:42:24,370 We didn't need any traditional malware just public, just a tool that we've revered most offensively. 427 00:42:24,510 --> 00:42:28,890 This clearly shows that the most effective offensive techniques don't rely on obvious malware. 428 00:42:29,130 --> 00:42:35,910 With the right vulnerabilities and smart use of legitimate components, it's possible to fully compromise the system silently and persistently. 429 00:42:36,670 --> 00:42:41,010 If you are interested in digging deeper, here are the references we use for our research. 430 00:42:41,130 --> 00: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. 431 00:42:47,810 --> 00:42:50,750 Okay, thank you for your time and attention. 432 00:42:50,750 --> 00:42:53,150 The GitHub repository is now a bible. 433 00:42:53,530 --> 00:42:57,250 We hope you enjoyed the talk and maybe learned something new today. 434 00:42:57,390 --> 00:43:01,090 Also thank you to our friends who have supported us during the project. 435 00:43:01,090 --> 00:43:02,230 Thank you so much.