1 00:00:00,000 --> 00:00:01,200 Hello, everyone. 2 00:00:02,240 --> 00:00:06,260 It's a pleasure for us to be here at DEF CON 33. 3 00:00:06,980 --> 00:00:13,720 And honestly, it's exciting just to see so many people here interested in building this malware. 4 00:00:13,820 --> 00:00:15,320 So thank you for coming. 5 00:00:15,380 --> 00:00:17,400 I'm not going to ask questions. 6 00:00:17,400 --> 00:00:20,280 I suppose you want to develop malware, but whatever. 7 00:00:22,000 --> 00:00:28,300 Before diving in, we want to make something very clear right from the start so everyone is on the same page. 8 00:00:29,340 --> 00:00:34,320 This is not a talk about theoretical bootkit and rootkit development. 9 00:00:34,400 --> 00:00:40,840 What we are going to share with you today is a fully functional working piece of malware that we have developed. 10 00:00:41,160 --> 00:00:45,560 And in a moment we will explain why we have chosen to make it public. 11 00:00:45,800 --> 00:00:53,980 So during this talk, we will share with you a complete documented bootkit ready for you to use, build and study. 12 00:00:54,520 --> 00:01:01,420 Alongside that, a rootkit as well that implements some cool techniques to modify the Windows kernel. 13 00:01:02,500 --> 00:01:14,120 We will also point you to our repository with over 400 great resources that you can use to carry out your own research into bootkits and rootkits. 14 00:01:14,300 --> 00:01:22,460 And because setting up the environment can be half the battle, you will have access to a set of scripts we use to automate the entire setup. 15 00:01:23,140 --> 00:01:29,680 And by the way, this talk ends with a demo, a real vulnerable computer we have right here. 16 00:01:29,680 --> 00:01:31,840 We have right here this Lenovo. 17 00:01:32,700 --> 00:01:40,920 Showing the bootkitting action with secure boot enabled, taking control of the Windows kernel and running the entire malware exactly as designed. 18 00:01:40,920 --> 00:01:42,460 We hope you enjoy. 19 00:01:42,980 --> 00:01:49,360 My name is Alejandro, I'm a geek, which of course stands for a gentleman, as you can see. 20 00:01:49,420 --> 00:01:54,960 A gentleman exploring UFI and OS kernels, or at least that's what I like to say. 21 00:01:54,980 --> 00:01:56,420 And she's Maria. 22 00:01:57,820 --> 00:02:01,320 Hi everyone, I'm Maria, also a geek. 23 00:02:01,520 --> 00:02:04,800 A girl who explores exploits and kernel threats. 24 00:02:04,940 --> 00:02:09,460 You can find our full biographies on the official DEF CON page. 25 00:02:09,460 --> 00:02:17,760 But to summarize, I work in a law enforcement cyber crime department where I've spent the last few years analyzing malware. 26 00:02:17,760 --> 00:02:21,760 Don't worry, I'm not working right now, this is a safe place. 27 00:02:22,460 --> 00:02:28,060 Meanwhile, Alejandro is a red team operator focused on Windows internals. 28 00:02:28,200 --> 00:02:37,660 So we are two geeks with two different perspectives, two octopus lovers ready to publish a boot kit for the entire world to use. 29 00:02:39,160 --> 00:02:41,180 And the question is, why? 30 00:02:41,180 --> 00:02:43,080 Why are we publishing this? 31 00:02:43,100 --> 00:02:53,600 Well, we want every offensive team out there, every red teamer to walk away from here today with a real boot kit and a root kit they can actually use in their operations. 32 00:02:53,680 --> 00:02:56,080 And the knowledge to develop their own. 33 00:02:56,180 --> 00:03:11,160 Instead of spending a year crawling the internet, piecing together scattered bits of information and trying to figure it all out, you'll have it today, ready to customize, improve and build your own in just a few months. 34 00:03:12,400 --> 00:03:15,360 This entire subject fascinates us. 35 00:03:15,360 --> 00:03:19,720 And we believe it shouldn't feel like some kind of dark magic. 36 00:03:20,000 --> 00:03:25,480 Building a root kit and a boot kit isn't about having the secret knowledge look away. 37 00:03:25,480 --> 00:03:30,780 It's about having the right guidance, the right resources and the time to learn. 38 00:03:30,780 --> 00:03:38,700 So over the next 40, 45 minutes, we're going to explain everything in a very straightforward way, plain language. 39 00:03:38,860 --> 00:03:46,260 We want absolutely everyone to walk away with a clear understanding of what this is and how it works. 40 00:03:46,260 --> 00:03:48,260 That's what this talk is about. 41 00:03:50,240 --> 00:03:53,300 So let's get this started, guys. 42 00:03:53,900 --> 00:04:01,140 A boot kit is a program designed to implant itself as early as possible in the system's boot process. 43 00:04:01,140 --> 00:04:08,820 It gains control over every stage of the system's startup and modifies the entire boot flow, which we will break down shortly. 44 00:04:09,080 --> 00:04:10,320 How does it do that? 45 00:04:10,320 --> 00:04:15,500 By hooking and patching key functions in files involved in the boot sequence. 46 00:04:15,500 --> 00:04:22,160 Those hooks and patches are what allow the boot kit to keep executing while the boot sequence continues. 47 00:04:22,160 --> 00:04:27,760 And to install components that remain alive even after the operating system takes control. 48 00:04:28,360 --> 00:04:33,900 A boot kit is just a root kit that runs before the operating system is loaded. 49 00:04:33,900 --> 00:04:35,660 So what is a root kit? 50 00:04:35,700 --> 00:04:43,800 A root kit is another program designed to run inside the kernel, the core of the operating system. 51 00:04:43,800 --> 00:04:55,180 Because it operates at the kernel level and the kernel manages memory, processes and interrupts, the malware can do almost anything. 52 00:04:55,200 --> 00:05:04,240 It can hide files, network connections, disable security protections and modify the internal structures of the operating system. 53 00:05:04,660 --> 00:05:11,460 Now, someone who wants to get started in this field doesn't really understand a damn thing about these definitions. 54 00:05:11,460 --> 00:05:13,860 So let's demystify it. 55 00:05:14,160 --> 00:05:22,960 On any system you will find kernel mod drivers, legitimate components that run at the highest privilege level inside the kernel. 56 00:05:23,020 --> 00:05:29,020 Now, if you take that same concept and make it malicious, you get what we call a root kit. 57 00:05:29,020 --> 00:05:33,940 A malicious kernel mod driver designed to tamper with the kernel. 58 00:05:34,360 --> 00:05:42,060 And if the computer uses UFI BIOS to boot, then the starting point of the boot process is a UFI application. 59 00:05:42,060 --> 00:05:47,220 So a malicious UFI application is what fits the definition of a boot kit. 60 00:05:47,740 --> 00:05:51,140 At its core there are two main components we need to develop. 61 00:05:51,140 --> 00:05:53,240 Later we will see there are more. 62 00:05:53,240 --> 00:06:07,060 As the foundation, a malicious UFI application for the early boot stage and a malicious kernel mod driver to modify the operating system once it's loaded. 63 00:06:07,600 --> 00:06:19,500 And now that we have demystified them, it's worth mentioning, you will find official documentation from Microsoft and from UFI forum available to help you build both of them. 64 00:06:19,500 --> 00:06:24,300 This is not dark magic, it's just offensive software development. 65 00:06:25,280 --> 00:06:28,680 But of course it's not just about reading the official documentation. 66 00:06:28,680 --> 00:06:35,980 There are some amazing resources out there, almost like sacred texts that you simply cannot miss. 67 00:06:35,980 --> 00:06:41,140 If you really want to understand what's going on under the hood, start here. 68 00:06:41,480 --> 00:06:51,400 And of course, huge thanks to all the amazing folks that explored this subject before us and shared their knowledge, malware and tools with the entire community. 69 00:06:51,400 --> 00:06:54,560 Now it's our turn to give something back. 70 00:06:57,250 --> 00:07:00,330 By now we can summarize it like this. 71 00:07:00,330 --> 00:07:07,110 A boot kit is essentially a malicious UFI application and a root kit is essentially a malicious kernel mod driver. 72 00:07:07,110 --> 00:07:10,810 We already know the two main components we need to develop. 73 00:07:10,810 --> 00:07:14,770 But what actually prevents us from just installing them? 74 00:07:14,830 --> 00:07:19,090 Well, we are two protection mechanisms we need to talk about. 75 00:07:19,990 --> 00:07:22,250 First, we have security boot. 76 00:07:22,250 --> 00:07:24,930 Security boot is all about the chain of trust. 77 00:07:24,930 --> 00:07:28,870 Enforced through digital signatures and cryptographic keys. 78 00:07:28,870 --> 00:07:37,990 When it's enabled, every component in the boot process must be signed by a trusted vendor and verified against a list of allowed keys. 79 00:07:37,990 --> 00:07:39,250 That's the point. 80 00:07:39,250 --> 00:07:47,270 Malicious UFI applications, boot kits, simply won't run unless they are signed by a key that the firmware trusts. 81 00:07:47,630 --> 00:08:02,050 But like any system, and we've listed a few CVs there, if you exploit a weakness , or in this case, you find a way to include your own key into the chain and sign your binary with it, the whole thing collapses. 82 00:08:02,490 --> 00:08:12,950 And once security boot is bypassed, every protection that comes after, including what the operating system tries to enforce, basically doesn't matter anymore. 83 00:08:12,950 --> 00:08:16,410 Because if you control the boot, you control everything. 84 00:08:16,730 --> 00:08:22,330 So what happens when two geeks find a machine vulnerable to one of these flaws? 85 00:08:22,330 --> 00:08:26,230 Well, that's exactly what you'll see in our final demo. 86 00:08:27,190 --> 00:08:33,330 The second protection we need to talk about is driver signature enforcement, or DSE. 87 00:08:33,330 --> 00:08:39,270 If you already compromised the boot process, this protection doesn't really matter anymore. 88 00:08:39,450 --> 00:08:41,630 But let's assume you didn't. 89 00:08:41,630 --> 00:08:46,010 Maybe you couldn't find a vulnerability to break the boot signature chain. 90 00:08:46,010 --> 00:08:49,410 In that case, you can't install the full boot kit. 91 00:08:49,410 --> 00:08:53,750 But you can still find a way to install just the root kit part. 92 00:08:53,870 --> 00:09:04,350 The problem is, Windows won't let you just load a malicious kernel mode driver unless it's properly signed either by Microsoft or by a trusted vendor. 93 00:09:04,910 --> 00:09:14,410 As you can see on the screen, if you try to drop your sys file into the system and load it, you'll get an error saying the signature is invalid. 94 00:09:14,550 --> 00:09:16,970 That's DSE doing its job. 95 00:09:17,250 --> 00:09:19,310 But there are ways around it. 96 00:09:19,310 --> 00:09:23,770 And one of them is the technique called bring your own vulnerable driver. 97 00:09:23,990 --> 00:09:33,390 The idea is instead of loading your malicious driver directly, you first load a legitimate signed driver with a known vulnerability. 98 00:09:33,510 --> 00:09:42,830 And once that vulnerable driver is running, you exploit it to execute arbitrary code in kernel space and load your root kit from there. 99 00:09:43,650 --> 00:09:47,330 The vulnerability you use can be too well known. 100 00:09:47,330 --> 00:09:54,050 Because Microsoft maintains a block list of drivers which are already known to be abused for this technique. 101 00:09:54,050 --> 00:09:56,650 And it won't allow them to load. 102 00:09:56,990 --> 00:10:01,670 But at the end of the day, it's a constant kind of mouse game. 103 00:10:01,670 --> 00:10:09,750 As new vulnerable drivers are discovered, attackers use them, Microsoft eventually blocks them and the cycle keeps going. 104 00:10:10,630 --> 00:10:12,630 Now let's quickly recap. 105 00:10:13,090 --> 00:10:17,290 A UFI boot kit starts with a malicious UFI application. 106 00:10:17,410 --> 00:10:20,950 A root kit starts with a malicious kernel mode driver. 107 00:10:21,090 --> 00:10:26,370 To install either of these components, there are protection mechanisms you'll need to bypass. 108 00:10:26,410 --> 00:10:36,950 There are public vulnerabilities, public exploits and proven techniques you can adapt to get each part, each component of the boot kit we're sharing up and running. 109 00:10:38,490 --> 00:10:46,290 So to understand how our boot kit or root kit behaves, you first need to understand the boot process. 110 00:10:46,350 --> 00:10:48,190 And here is the general idea. 111 00:10:48,190 --> 00:10:54,330 When you press the power button, the system performs an operation called power on self test or post. 112 00:10:54,330 --> 00:10:59,210 A process that checks the hardware to make sure the essential components are working properly. 113 00:11:00,070 --> 00:11:06,770 After that, UFI framework is executed and it looks for the files and partitions required to boot. 114 00:11:06,770 --> 00:11:18,250 One of the first files it loads is the Windows boot manager, a legitimate UFI application found in a special disk partition called the ESP, EFI system partition. 115 00:11:18,650 --> 00:11:26,350 The Windows boot manager loads the Windows OS loader, which loads the operating system into memory. 116 00:11:26,350 --> 00:11:31,450 And from there the operating system takes control and initializes its main subsystems. 117 00:11:31,450 --> 00:11:35,830 So we have three key files involved in this process. 118 00:11:35,830 --> 00:11:40,710 The Windows boot manager, the Windows OS loader, and the Windows NT kernel. 119 00:11:40,750 --> 00:11:55,650 Three files you will want to load into your disassembler, reverse engineer to understand their inner workings, and figure out exactly which functions to hook and patch, just as we mentioned earlier, in order to take control of the process. 120 00:11:56,810 --> 00:12:00,670 This is the simplified explanation of how the malware works. 121 00:12:00,670 --> 00:12:05,210 Remember, each component in the boot chain loads the next one into memory. 122 00:12:05,210 --> 00:12:14,310 So at specific moments in the process, the next component, the next file is already in memory, but it has not yet taken control. 123 00:12:14,310 --> 00:12:15,110 That's the key. 124 00:12:15,110 --> 00:12:23,670 Those moments are when we can hook functions inside that next component, keeping our code in execution as the process continues. 125 00:12:24,370 --> 00:12:29,450 We begin by replacing the Windows boot manager with our own malicious version. 126 00:12:29,450 --> 00:12:39,250 This malicious version, or UFI application, hooks a function inside the firmware responsible for loading the original boot manager. 127 00:12:39,290 --> 00:12:47,450 But instead of immediately passing control to it, our code ensures that the original boot manager is fully loaded into memory first. 128 00:12:48,270 --> 00:13:07,110 Once it's loaded, and this right here is one of the most important lines among the thousands that make up the boot kit, once it's loaded in memory, we scan the memory using a known pattern to locate a specific function in that file that is called when the next component is already in memory. 129 00:13:07,110 --> 00:13:20,590 Then we hook it by patching its entry point with a small assembly trampling, redirecting the execution to our own custom handler, and then back to the original function, keeping our code without breaking the boot process. 130 00:13:20,630 --> 00:13:23,590 We repeat the same approach at each stage. 131 00:13:23,590 --> 00:13:31,450 So inside the Windows boot manager, we hook a function that is called when the OS loader is already in memory. 132 00:13:31,450 --> 00:13:38,090 Then inside the OS loader, we hook a function that is called when the anti-kernel is already in memory. 133 00:13:38,090 --> 00:13:43,110 Hook by hook, stage by stage, we maintain control through the entire boot process. 134 00:13:43,490 --> 00:13:46,130 But these hooks don't just keep the boot kit alive. 135 00:13:46,130 --> 00:13:55,230 Along the way, we also use specific functions in these files to drop the root kit, the malicious kernel mod driver, in memory at the right moment. 136 00:13:55,230 --> 00:14:01,690 So the root kit is ready and running by the time the operating system starts. 137 00:14:02,330 --> 00:14:06,570 And now let's see a quick demo. 138 00:14:13,400 --> 00:14:15,260 The first one. 139 00:14:16,640 --> 00:14:21,620 So here we have an unsigned kernel mod driver. 140 00:14:21,620 --> 00:14:29,140 We're going to try and load it in a common way and you're going to see an error because the DSE is enabled. 141 00:14:29,320 --> 00:14:36,380 So what we're going to do now is perform an advanced restart and we're going to change the way we boot. 142 00:14:36,380 --> 00:14:45,460 We're going to boot into the ESP, the EFI system partition, because in a specific folder in that partition we have our malicious EFI application. 143 00:14:45,460 --> 00:14:55,220 We're going to go to that folder, we're going to execute that EFI application and the EFI application is going to modify the entire boot flow. 144 00:14:55,220 --> 00:15:00,140 And we have configured the application to drop the root kit in memory. 145 00:15:00,640 --> 00:15:16,500 But we provide you with a tool to create the EFI, sorry, to create the configuration the EFI application uses because the EFI application can drop something in memory, modify partitions, can disable security protections. 146 00:15:16,500 --> 00:15:22,140 But in this demo we have only configured the EFI application to drop the root kit in memory. 147 00:15:22,140 --> 00:15:31,380 So as you can, as you are going to see now in a moment, there is something in kernel space that is printing, hey, hello, hello, hello. 148 00:15:31,380 --> 00:15:38,620 There is something in kernel space that can modify the entire operating system, how the operating system works. 149 00:15:38,760 --> 00:15:51,740 And we're going to explain that in a moment but you can also use that, a user mode application like that, hello.exe to communicate with the kernel mode driver. 150 00:15:51,920 --> 00:15:58,900 And something important to note is that the EFI application can disable DSE, of course you can configure the application to do it. 151 00:15:58,900 --> 00:16:04,600 But it's not necessary, it's not mandatory to drop the root kit in memory. 152 00:16:04,600 --> 00:16:15,540 In fact as you are going to see in a moment, DSE is still enabled because we saw, we saw that the root kit is already in memory. 153 00:16:28,310 --> 00:16:34,210 Now let's take a moment to talk about the power of the UFI specification itself. 154 00:16:34,270 --> 00:16:45,410 When we think about a boot kit, it's easy to just focus on hooking boot functions but UFI applications are not limited to redirection of patching. 155 00:16:45,410 --> 00:17:00,810 A UFI application can interact with a wide range of low level services because the UFI specification spans thousands of pages covering protocols for managing memory, file systems and even networking. 156 00:17:00,910 --> 00:17:16,410 That means the first element of the malware we build before the operating system even loads can fetch files from a remote server on the internet, modify partitions, create loads and leave markers for later payloads. 157 00:17:16,410 --> 00:17:22,730 In other words, you can do almost anything you want using a UFI application. 158 00:17:23,070 --> 00:17:30,830 And a word of advice, if you ever decide to go through all the thousands of pages of this specification, don't bother with coffee. 159 00:17:30,830 --> 00:17:31,990 It's useless. 160 00:17:31,990 --> 00:17:34,350 You need at least a couple of beers. 161 00:17:36,190 --> 00:17:41,770 Continuing with UFI, UFI defines two major service categories. 162 00:17:41,890 --> 00:17:47,470 Boot services which are only available during the early boot process is the blue zone. 163 00:17:47,650 --> 00:17:53,870 And then run time services which remain available even after the operating system has taken control. 164 00:17:53,870 --> 00:17:55,490 That's the orange zone. 165 00:17:55,490 --> 00:18:01,330 This distinction is crucial because every UFI application relies on boot services. 166 00:18:01,330 --> 00:18:11,850 So all the memory and resources it sets up are discarded once a call is made to terminate boot services and the operating system takes control. 167 00:18:12,290 --> 00:18:16,350 We've already loaded the root kit into memory by this stage. 168 00:18:16,350 --> 00:18:19,410 So losing boot services doesn't really hurt us. 169 00:18:19,710 --> 00:18:32,370 But if we design our code with this in mind, we can take advantage of run time services to establish something during boot that persists even after our application itself is gone. 170 00:18:33,890 --> 00:18:39,070 One way to achieve this is by developing a DXC run time driver. 171 00:18:39,070 --> 00:18:46,870 A special kind of UFI driver that stays in memory after the boot and allows you to hook run time services. 172 00:18:47,230 --> 00:18:52,610 In other words, it plans hooks that remain active while the system is running. 173 00:18:52,810 --> 00:19:02,330 This gives you an almost invisible back door which allows you to execute arbitrary payloads and read or write anywhere in memory. 174 00:19:02,430 --> 00:19:06,230 So at this point, what is our boot kit in practice? 175 00:19:06,770 --> 00:19:09,730 It consists in two main components. 176 00:19:09,750 --> 00:19:26,030 First, a UFI application that cooks key functions to stay alive through the boot process, drops the root kit into memory at the right moment, disables security protections if needed, and takes full advantage of the UFI specification. 177 00:19:26,410 --> 00:19:34,630 And second, a malicious DXC run time driver acting as a back door that can read and write in memory while the system is running. 178 00:19:36,750 --> 00:19:39,850 So let's see the second device. 179 00:19:48,110 --> 00:19:52,410 So as you can see here, we have an HTTP server up. 180 00:19:52,910 --> 00:19:55,970 We're going to do the same we did in the first demo. 181 00:19:55,970 --> 00:20:06,310 We're going to boot into the ASP and in a specific folder now we have, we're going to see two files, the UFI application and the DXC run time driver. 182 00:20:06,750 --> 00:20:17,670 We're going to execute the UFI application and the UFI application is going to download a UFI utility in the disk. 183 00:20:18,150 --> 00:20:31,630 We don't use that UFI utility in this demo, but if you see the source code that is completely available, you're going to realize what new capabilities this UFI utility gives me. 184 00:20:32,210 --> 00:20:37,490 The UFI application is going to load the DXC run time driver in memory too. 185 00:20:38,370 --> 00:20:41,550 And it downloaded that file. 186 00:20:43,630 --> 00:20:48,750 And now the DXC run time driver is in memory because the UFI application loaded. 187 00:20:49,550 --> 00:20:57,050 We have developed a tool to communicate with the DXC run time driver. 188 00:20:57,050 --> 00:21:15,850 Something important to know is we, give me a moment, I have to pause here, you have to execute that UFI, sorry, you have to execute the program we developed with admin privileges. 189 00:21:15,850 --> 00:21:19,970 That's very important to communicate with the DXC run time driver. 190 00:21:20,410 --> 00:21:26,210 So we're going to use that specific tool first to check if the DXC run time driver is in memory. 191 00:21:26,410 --> 00:21:28,910 He's going to say, oh yeah, I'm alive. 192 00:21:29,170 --> 00:21:41,370 So now we can drop another malicious component in memory, we can execute payloads, we can execute shell codes, we can read and write anywhere in memory. 193 00:21:41,390 --> 00:21:51,250 And we have configured specific functionality to communicate with the DXC run time driver and say, hey, I want you to load this rootkit. 194 00:21:51,250 --> 00:21:54,510 I want you to load this malicious kernel mod driver. 195 00:21:54,530 --> 00:21:55,690 And it loaded. 196 00:21:55,690 --> 00:22:01,850 So now you have two ways to load something in memory to load the rootkit. 197 00:22:03,050 --> 00:22:17,550 You can use the UFI application or you can use the DXC run time driver to drop something in memory that as we are going to see now in a moment can modify how the operating system works. 198 00:22:18,830 --> 00:22:24,490 The core of the malware and what truly gives the bootkit its power is the rootkit. 199 00:22:24,490 --> 00:22:33,230 The rootkit is the component that lives in kernel space, operates with the highest privileges and enables deep manipulation of the system. 200 00:22:33,250 --> 00:22:39,750 From intercepting callbacks to hiding files and network activity, the rootkit is what delivers full control. 201 00:22:40,010 --> 00:22:48,550 In fact, everything we have discussed so far, UFI, hookings, early boot hijacking, run time drivers, has just been the setup. 202 00:22:48,550 --> 00:22:53,150 It's all part of the infection chain that ensures the rootkit runs reliably. 203 00:23:01,260 --> 00:23:21,560 As you can see in the right circle, a rootkit, it could be, but most of the time a rootkit is not just a malicious kernel driver. 204 00:23:21,560 --> 00:23:26,720 There are more components that make up this concept, all working in a coordinated way. 205 00:23:27,300 --> 00:23:32,100 So the question now is what makes this rootkit we have built, this driver , a good one? 206 00:23:32,100 --> 00:23:37,880 What key aspects did we focus on to give it a solid foundation and meaningful capabilities? 207 00:23:37,880 --> 00:23:46,860 Well, there are more techniques implemented, as you will see in the source code, but we think these six form the essential foundation to start with. 208 00:23:47,140 --> 00:23:48,760 First, communication. 209 00:23:48,760 --> 00:23:59,940 A good rootkit must be able to communicate either with a user-learned application, with a command and control server, or both, while still being capable of acting autonomously when necessary. 210 00:23:59,940 --> 00:24:07,220 This is what allows you to send instructions, receive responses, and adapt the driver's behavior on demand. 211 00:24:08,460 --> 00:24:11,700 Second, direct kernel object manipulation. 212 00:24:12,240 --> 00:24:20,940 This is what allows the rootkit to, for example, do something as fundamental as hiding a process. 213 00:24:21,040 --> 00:24:31,980 And while that may sound simple, now in 2025 it has to be done the right way, otherwise you risk a protection and crashing the system with a blue screen. 214 00:24:32,380 --> 00:24:34,500 Third, keystroke logging. 215 00:24:34,540 --> 00:24:43,620 It's also possible to capture keystrokes at the kernel level, intercepting some kind of packets. 216 00:24:45,040 --> 00:24:48,260 Fourth, network filtering. 217 00:24:48,340 --> 00:25:02,380 By leveraging the Windows filtering platform technology, the rootkit can alter, block, you know, capture network traffic in real time. 218 00:25:02,740 --> 00:25:06,560 Fifth, kernel level command and control manipulation. 219 00:25:07,060 --> 00:25:22,440 As you can see on the screen, Winsock kernel allows the rootkit to make HTTP connections entirely within the driver. 220 00:25:22,500 --> 00:25:29,080 So enabling a full command and control in the internal space. 221 00:25:29,080 --> 00:25:31,460 So this is very important. 222 00:25:31,460 --> 00:25:44,100 You don't need a user land process to communicate with the server on the Internet, download files or even handle network connections or communications. 223 00:25:44,100 --> 00:25:47,980 Because the driver can handle all of it on its own. 224 00:25:48,260 --> 00:25:51,280 And finally, file system filtering. 225 00:25:51,560 --> 00:25:58,180 There is a special class of drivers that many security solutions use called mini-filters. 226 00:25:58,320 --> 00:26:14,600 And the rootkit can also make use of the underlying technology behind those drivers to hide and deny the access to specific files and folders, effectively preventing the operating system and other tools from analyzing them. 227 00:26:15,040 --> 00:26:21,640 So we're going to see a rootkit with these six capabilities. 228 00:26:26,800 --> 00:26:29,120 We're going to boot into the ESP. 229 00:26:29,120 --> 00:26:34,200 In the ESP we have a malicious UFI application. 230 00:26:34,200 --> 00:26:36,620 We're going to execute the UFI application. 231 00:26:36,620 --> 00:26:45,100 The UFI application is going to modify the entire boot flow and it's going to drop all rootkit in memory. 232 00:26:50,500 --> 00:26:56,140 We have developed a user mode application to communicate with the rootkit. 233 00:26:56,140 --> 00:27:02,340 You don't need admin privileges to open this, to execute this application. 234 00:27:02,660 --> 00:27:12,300 We're going to use this user mode application to communicate with the kernel mode driver and say, hey, the first thing we're going to try is hiding a process. 235 00:27:12,300 --> 00:27:17,320 We're going to try and hide the one drive.exe process with that specific bit. 236 00:27:17,320 --> 00:27:25,280 It's going to fail because we have to execute some commands to see if the kernel mode driver is in memory. 237 00:27:25,280 --> 00:27:35,960 So we execute them and now you're going to see how that specific line is going to be printed in red and the process disappears from the eyes of the user. 238 00:27:35,960 --> 00:27:41,840 Well, from the eyes of the task manager and in this case the process hacker program. 239 00:27:42,080 --> 00:27:52,340 We can list the hidden processes and we can hide in an easy way only with the identifier and the process appears again. 240 00:27:52,460 --> 00:27:55,780 We can do the same with files and folders. 241 00:27:55,780 --> 00:28:10,260 So we're going to copy a specific folder here and we're going to communicate with the kernel mode driver and say, hey, I don't want the user to see that specific file. 242 00:28:10,260 --> 00:28:12,660 We reload it and it disappeared. 243 00:28:13,160 --> 00:28:17,200 We communicate again with the kernel mode driver and it appeared again. 244 00:28:17,220 --> 00:28:24,980 It's like there is something in the kernel space that modifies how the operating system works. 245 00:28:25,640 --> 00:28:28,180 We can block connections too. 246 00:28:28,180 --> 00:28:38,120 Maybe we don't want the computer or the user to be able to communicate with some kind of IP addresses, some servers on the internet, some range. 247 00:28:38,520 --> 00:28:45,780 We block those IP addresses and the user, the machine cannot communicate with them. 248 00:28:45,780 --> 00:28:53,020 There is something in the kernel space that denies those communications. 249 00:28:56,960 --> 00:29:01,780 And we can hide network connections too. 250 00:29:02,440 --> 00:29:08,820 We execute netstat, as you can see there are some TCP connections to the remote port 443. 251 00:29:10,040 --> 00:29:18,240 We communicate with the driver and say, hey, I don't want the user to see those connections, maybe there is a shell code or whatever. 252 00:29:19,980 --> 00:29:24,760 We execute netstat again and the connections disappear from the eyes of the user. 253 00:29:26,600 --> 00:29:35,040 The thing is, you don't need a user mode application to communicate with the driver. 254 00:29:35,620 --> 00:29:40,280 You can develop some kind of alternative ways of communication. 255 00:29:41,560 --> 00:29:46,680 You can, for example, enable a keylogger. 256 00:29:46,680 --> 00:29:54,820 The driver can capture, as you are going to see in a moment, can capture every keystroke you type. 257 00:29:54,820 --> 00:30:03,000 So you can use the keylogger to communicate with the driver so you don't need the application. 258 00:30:06,520 --> 00:30:14,940 We are going to show you that we have categorized everything in different techniques. 259 00:30:15,000 --> 00:30:31,380 We have seen something related with the kernel object manipulation, keyboard filtering, WFP, mini filter and now WSK. 260 00:30:31,840 --> 00:30:36,160 As I said before, this is very important. 261 00:30:36,660 --> 00:30:44,100 You can enable a fully common and controlled channel in the driver. 262 00:30:44,100 --> 00:30:57,980 So you enable the command and control and the driver is going to call your server on the internet and your server responds, hey, I want you to execute this thing and the driver is going to execute it. 263 00:30:58,340 --> 00:31:03,440 In this version we don't provide you a full command and control in the source code. 264 00:31:04,160 --> 00:31:11,900 So you can find everything you need to develop your own command and control in the kernel space. 265 00:31:11,900 --> 00:31:14,340 But that is the idea. 266 00:31:15,200 --> 00:31:18,900 You can wait a few months and we are going to release that as well. 267 00:31:24,350 --> 00:31:41,230 So we cannot explain these six techniques in detail, but you have all the source code and not just the root source code itself but also a stand-alone proof of concepts for each example. 268 00:31:41,230 --> 00:31:49,790 There is a book just for communication, another just for how to hide a process, another just for the key logger and so on. 269 00:31:49,790 --> 00:31:57,030 That being said, understanding how a user mode application communicates with a kernel mode driver is crucial. 270 00:31:57,090 --> 00:32:11,790 Learning the fundamentals of how IOCTLs and how IRPs work is going to give you a solid foundation and will naturally prepare you to move on to exploiting vulnerabilities in kernel mode drivers as you progress in this area. 271 00:32:11,790 --> 00:32:16,390 That's going to be something you are going to introduce yourself as you progress. 272 00:32:17,130 --> 00:32:20,630 I hate doing this but I don't have so much time. 273 00:32:20,630 --> 00:32:24,270 So communication, you have some work to do at home. 274 00:32:24,270 --> 00:32:43,010 So communication, kernel structure manipulation, keyboard filtering, network filtering, kernel level command and control, file system filtering, and of course the entire boot process infection chain we have been talking about along with the security bypasses we mentioned at the beginning, 275 00:32:43,010 --> 00:32:45,730 all of that brings us here. 276 00:32:48,400 --> 00:32:50,740 We are going to see the last demo. 277 00:32:53,160 --> 00:32:56,940 This is vulnerable by the way. 278 00:32:57,980 --> 00:33:01,400 So we are going to bring up a physical machine. 279 00:33:01,600 --> 00:33:05,600 The boot kit works in virtual machines and physical machines. 280 00:33:06,280 --> 00:33:11,140 So we are going to install the boot kit, UFI boot kit. 281 00:33:11,760 --> 00:33:16,200 You need admin privileges to install the boot kit. 282 00:33:16,440 --> 00:33:20,760 We are going to execute, sorry, we are going to pause it here. 283 00:33:20,760 --> 00:33:23,260 We execute a script. 284 00:33:23,260 --> 00:33:26,020 Everything is available so don't worry. 285 00:33:26,020 --> 00:33:30,040 We execute a script to check if secure boot is enabled. 286 00:33:30,460 --> 00:33:33,420 And yes, secure boot is enabled as you see on the screen. 287 00:33:33,420 --> 00:33:40,780 But there is some kind of flaw in the UFI firmware, so who cares if secure boot is enabled or not. 288 00:33:41,000 --> 00:33:42,540 The machine is vulnerable. 289 00:33:44,040 --> 00:33:47,780 We install the UFI boot kit. 290 00:33:47,780 --> 00:33:51,160 We add a new boot entry by default. 291 00:33:51,340 --> 00:33:57,640 I'm going to, you know, the internet connection was slow and we have to download something. 292 00:33:58,000 --> 00:34:03,120 So the root kit, sorry, the UFI boot kit is installed. 293 00:34:04,160 --> 00:34:08,260 So now we shut down the machine. 294 00:34:12,460 --> 00:34:17,000 We power on again and the 295 00:34:21,060 --> 00:34:22,900 UFI boot kit is there. 296 00:34:22,900 --> 00:34:30,860 UFI boot kit, you know, you can configure the boot kit to not show the messages. 297 00:34:32,160 --> 00:34:39,460 The UFI boot kit, the UFI boot kit is dropped the root kit or root kit in memory. 298 00:34:40,620 --> 00:34:51,020 By default we have configured the UFI application to drop some kind of basic kernel mode driver, some kind of basic root kit in memory. 299 00:34:51,020 --> 00:34:56,040 So you can use that specific kernel mode driver. 300 00:34:56,040 --> 00:35:01,560 You can communicate with it and say, hey, I want you to load another kernel mode driver. 301 00:35:01,560 --> 00:35:15,540 We do it by default this way because maybe you want to load or root kit or maybe you want to load the proof of concept we give you to blind IDRs or you want to load your own root kit. 302 00:35:15,540 --> 00:35:32,960 So by default the UFI application dropped a basic kernel mode driver in memory and you can communicate, as you can see in the screen, you can communicate with that specific kernel mode driver and say, hey, I want you to load another one. 303 00:35:34,140 --> 00:35:39,360 So this machine is fully compromised. 304 00:35:39,360 --> 00:35:41,560 There are no more levels. 305 00:35:52,320 --> 00:36:01,380 Now that you have seen the final demo, it's time to take out your phones and make a picture of the screen. 306 00:36:01,380 --> 00:36:04,420 On the screen you will see six QR codes. 307 00:36:04,420 --> 00:36:09,980 This gives you access not just to everything we showed here today but much more. 308 00:36:09,980 --> 00:36:21,360 Starting from the top row, left to right, the first QR takes you to the repository or UFI boot kit project. 309 00:36:21,500 --> 00:36:31,700 It includes the UFI application, basic kernel mode drivers that UFI application can drop in memory, the driver, the tool to 310 00:36:36,840 --> 00:36:50,660 create the encrypted configuration UFI application uses, and a massive amount of documentation on how to get started in developing boot kits. 311 00:36:50,660 --> 00:36:58,320 So everything you need to develop your first UFI boot kit from scratch is there in the first QR. 312 00:36:58,420 --> 00:37:08,040 The second takes you to the Bantic repository or full featured kernel mode boot kit. 313 00:37:08,220 --> 00:37:20,320 You will find the kernel mode driver, the application to communicate with the kernel mode driver, and a dozen proof of concepts for each technique implemented and documentation as well. 314 00:37:20,600 --> 00:37:32,080 The third QR takes you to a repository with hundreds of resources you can use to dive even deeper into the subject. 315 00:37:33,000 --> 00:37:43,680 On the bottom row, the first QR, I think it gives you access to a set of scripts you use to automate the entire development environment set up. 316 00:37:43,680 --> 00:37:49,880 You need to configure something to develop boot kits and root kits in a machine. 317 00:37:49,880 --> 00:37:54,560 So you can execute over scripts and it's completely automatically. 318 00:37:55,120 --> 00:38:08,880 The second QR, that's a good one, the last one, there is some notes there to install the root kit on a physical real machine. 319 00:38:09,200 --> 00:38:16,060 And the last one includes some notes to help you analyze your own UFI firmware and check for non‑vulnerabilities. 320 00:38:17,580 --> 00:38:27,720 We believe this is the first time so much documentation and code has been shared with the entire community to help you build both a boot kit and a root kit. 321 00:38:28,040 --> 00:38:39,500 But that was the idea, to provide anyone looking to deliver adversary simulation services with the knowledge to emulate the kind of malware only APTs deploy. 322 00:38:39,900 --> 00:38:53,720 And the last thing we want to say, as you can see on the screen, our lovely dog, Shira, passed away recently and without her we wouldn't be here. 323 00:38:53,820 --> 00:38:58,040 So you all owe her a big thank you for making this talk. 324 00:38:58,040 --> 00:39:01,100 And that's all from us. 325 00:39:01,100 --> 00:39:07,340 If you want to see, if someone wants to see a live demo, we have the vulnerable computer right here. 326 00:39:07,340 --> 00:39:11,580 We are very approachable people and we have some cool stickers too. 327 00:39:11,700 --> 00:39:15,860 So that's all from us. 328 00:39:15,860 --> 00:39:17,020 Enjoy the malware. 329 00:39:17,020 --> 00:39:20,780 You are not going to find anything like this on the Internet. 330 00:39:20,780 --> 00:39:23,280 This is very, very cool. 331 00:39:23,360 --> 00:39:24,820 So enjoy it. 332 00:39:24,820 --> 00:39:25,660 See you soon.