[00:02.310 --> 00:06.610] Okay, thank you all for coming to my presentation. [00:10.370 --> 00:13.870] For those who I haven't met before, my name is Andrew Case. [00:13.870 --> 00:17.390] I am a core developer on the Volatility Memory Analysis Project [00:17.390 --> 00:21.010] and also the Director of Research at Vellect City. [00:22.530 --> 00:28.430] At Vellect City, we do a significant amount of incident response and malware analysis. [00:28.670 --> 00:32.390] And as part of our research workflow and being on the research team there, [00:32.390 --> 00:36.930] we make sure that for all the malware techniques that we see during our attacks [00:36.930 --> 00:41.110] and that we see other vendors reporting about, any type of malware technique, [00:41.110 --> 00:43.930] any attacker toolkit that's really being used in the wild, [00:43.930 --> 00:47.090] we want to make sure that we have a complete understanding of it [00:47.090 --> 00:50.990] and also that we can automatically detect it during our investigations. [00:51.890 --> 00:55.010] To ensure that we meet that goal and meet that reality, [00:55.010 --> 00:59.310] we very often perform very targeted, very specific deep dives [00:59.310 --> 01:03.870] on specific techniques that we see the malware using, that we see attackers using. [01:03.990 --> 01:07.230] And then we make sure that we document all the different techniques, [01:07.230 --> 01:10.810] all the different tools that use it, whether they're private tools from threat groups, [01:10.810 --> 01:14.310] whether it's some open source tool that has implemented it. [01:14.310 --> 01:17.110] And then we make infected machines with it. [01:17.110 --> 01:20.970] So we make our infected virtual machines. We make sure all the techniques are active. [01:21.010 --> 01:24.490] We do the deepest memory forensics research we know how to do, [01:24.490 --> 01:28.310] which we have most of the volatility developers at Vellect City, so that's pretty deep. [01:28.310 --> 01:31.130] And then we do talks like this where we publish it. [01:31.270 --> 01:36.110] For one of the latest research projects that we did, that's what I'm going to be talking to you about today, [01:36.110 --> 01:41.230] we looked at all the ways that EDRs were being evaded by real malware. [01:41.230 --> 01:46.150] Because what we noticed in our investigations is that we're working in enterprises, [01:46.150 --> 01:51.090] they're trying to do security correctly, they have EDRs, they have them configured, [01:51.090 --> 01:55.010] they're listed as active on these machines, but over and over again, [01:55.010 --> 01:58.690] as we were doing memory forensics, we were finding very potent malware [01:58.690 --> 02:02.090] in the same processes where the EDRs supposedly were. [02:02.090 --> 02:05.430] So obviously we wanted to figure out why that disconnect was happening, [02:05.430 --> 02:11.330] and through our memory forensics work, we wanted to be able to detect it automatically as well. [02:11.330 --> 02:14.050] Because as you'll see as we go through the slides, [02:14.050 --> 02:18.110] normally when malware bypasses EDRs, it's not every process. [02:18.110 --> 02:22.890] It's just the process or the two processes where the malware is running out of directly [02:22.890 --> 02:28.590] or where it's injected code into, so if you detect the EDR evasion, [02:28.590 --> 02:30.810] then you also directly detect the malware. [02:30.810 --> 02:33.750] And so this has allowed us to do very scalable work. [02:34.250 --> 02:37.250] And at Vilexity, where we're dealing in many investigations [02:37.250 --> 02:40.530] with dozens, hundreds, thousands of memory samples, [02:40.530 --> 02:44.070] we don't have time, and it would obviously not be very time efficient, [02:44.410 --> 02:46.850] to manually look at anything to start. [02:46.850 --> 02:49.630] So we want a set of techniques that will at least say, [02:49.630 --> 02:53.610] hey, out of these hundred memory samples, these are the five you really need to focus on. [02:53.610 --> 02:55.250] And that's where we target our research. [02:55.250 --> 02:56.910] We don't want a lot of false positives. [02:56.970 --> 02:59.150] We don't want algorithms that take forever to run. [02:59.150 --> 03:02.650] We just want to find the malware so that we can deep dive it. [03:02.710 --> 03:04.790] And then, as you can probably guess by the title [03:04.790 --> 03:07.810] and the fact that all this research was done with volatility, [03:07.810 --> 03:10.370] we're going to be looking for that malware in memory. [03:11.530 --> 03:13.670] If you haven't seen memory forensics before, [03:13.670 --> 03:16.170] or maybe you've never looked at a memory sample yourself, [03:16.170 --> 03:20.070] the reason why there's this whole industry now around memory forensics [03:20.070 --> 03:23.370] and why it's so vital to incorporate it in your investigations [03:23.370 --> 03:27.090] is that when you look at the real attacks in the wild, [03:27.090 --> 03:30.290] when you look at the malware that's going to be used in environments [03:30.290 --> 03:32.110] where the attackers don't want to get caught, [03:32.110 --> 03:34.890] where the EDRs are, where there's actually security teams, [03:34.890 --> 03:37.270] that malware is going to be memory only. [03:37.270 --> 03:39.550] It's not going to touch the file system. [03:39.570 --> 03:42.770] Anything that traverses the network is going to be encrypted. [03:42.850 --> 03:44.830] So if you don't get a memory sample, [03:44.830 --> 03:46.890] then you just threw all the evidence away. [03:46.890 --> 03:49.690] If you walk up to that compromised machine and you turn it off, [03:49.690 --> 03:53.250] as soon as that machine shuts down, the evidence is gone forever. [03:53.650 --> 03:56.470] And what I have highlighted here on the slide [03:56.470 --> 03:59.130] is just an interesting report from Microsoft. [03:59.130 --> 04:00.910] There's hundreds of reports like this [04:03.410 --> 04:05.470] that companies have published. [04:05.610 --> 04:07.530] But I like this one because in two sentences [04:07.530 --> 04:10.730] it really summarizes why we spend so much time doing memory. [04:10.890 --> 04:13.170] This was Microsoft. It was really interesting. [04:13.170 --> 04:16.410] It was basically a spyware company out of Australia [04:16.410 --> 04:19.650] that was being used to target some high-level people. [04:19.790 --> 04:22.970] And Microsoft burned the whole company to the ground in one report. [04:22.970 --> 04:26.410] They burned every piece of malware that company had, all the capabilities. [04:26.810 --> 04:29.750] And as I have highlighted in red here with the screenshot, [04:29.750 --> 04:32.170] over and over again, Microsoft made the point to say [04:32.170 --> 04:37.030] that where the evasion is, where the real payloads are, are in memory. [04:37.030 --> 04:39.530] And if you look at what these payloads are capable of, [04:39.530 --> 04:42.710] it's key logging, it's screenshots, it's recording the microphone, [04:42.710 --> 04:45.410] it's recording the webcam, exfiltrating files, [04:45.410 --> 04:50.090] everything that allowed this spyware to operate against politicians, [04:50.090 --> 04:52.610] journalists, all these people, it was memory only. [04:52.610 --> 04:55.430] So traditional disk forensics isn't going to get you anywhere. [04:55.530 --> 04:58.130] And you need to know how to efficiently do memory forensics [04:58.130 --> 05:02.390] to even make sense of the data and detect the malware in the first place. [05:03.290 --> 05:05.370] So as part of our research project, [05:05.370 --> 05:09.550] when we first broke down how EDRs are monitoring system activity, [05:09.550 --> 05:12.150] the first three have been around a while. [05:12.150 --> 05:16.290] Kernel callbacks is where EDRs or antivirus inside the kernel, [05:16.290 --> 05:19.010] so from their driver, they can register to say [05:19.010 --> 05:22.910] that that callback will be notified every time a process starts [05:22.910 --> 05:25.770] or a thread starts or a DLL gets loaded. [05:26.030 --> 05:30.870] EDRs will also monitor activity through two of the newer interfaces, [05:30.870 --> 05:36.010] so ETW and AMSI. ETW is where kernel drivers can receive [05:36.230 --> 05:39.650] a wide range of system activity from processes, [05:39.650 --> 05:41.370] also other parts of the kernel. [05:41.530 --> 05:44.870] And then AMSI, if you go to other DEF CON talks, Black Hat talks, [05:44.870 --> 05:47.370] it gets mentioned a lot because at this point, [05:47.370 --> 05:51.450] what AMSI does is it lets Defender, so Windows Defender, [05:51.450 --> 05:54.610] as well as all the AVs and EDRs, [05:54.610 --> 05:57.670] they get to register to say before a PowerShell script runs, [05:57.670 --> 06:00.390] before a macro runs, before all these scripting languages [06:00.390 --> 06:04.950] where traditional reversing doesn't work and there's a lot of obfuscation, [06:04.950 --> 06:08.850] those antivirus engines and the EDR engines get to scan the scripts. [06:08.850 --> 06:12.590] If they say they are malicious, then the scripts get blocked. [06:12.910 --> 06:17.250] And then what we'll really be focusing on with this talk is the last one, [06:17.250 --> 06:19.230] which is system call monitoring. [06:19.290 --> 06:23.230] And we'll have some pictures for that to make sure everyone is on the same page. [06:23.830 --> 06:26.290] And so when we broke down the bypasses, [06:26.290 --> 06:29.890] even, not even just like your really sophisticated threat groups, [06:29.890 --> 06:33.650] every ransomware family at this point, the half-decent ones, [06:33.650 --> 06:35.930] the first thing they do is load a kernel driver [06:35.930 --> 06:38.010] through Bring Your Own Vulnerable Driver, [06:38.010 --> 06:41.830] and they disable all the EDR callbacks and the AV callbacks. [06:41.830 --> 06:45.370] At that point, the ransomware can inject code, start new processes, [06:45.370 --> 06:47.630] and those systems are blind. [06:47.690 --> 06:51.990] For event tracing and AMSI, there are dozens and dozens of papers [06:51.990 --> 06:55.090] on how to disable these, and it's essentially a modern part [06:55.090 --> 06:57.130] of what you see in real investigations. [06:57.330 --> 07:01.410] But what we noticed, and as we'll see here on the next slide, [07:01.410 --> 07:05.110] is when we get to system call monitoring, we had no way to detect this. [07:05.110 --> 07:09.690] So before this research effort, with memory forensics, with volatility, [07:09.690 --> 07:13.050] you could very quickly determine that callbacks had been unregistered, [07:13.050 --> 07:16.970] that ETW had been tampered with, that AMSI had been tampered with. [07:16.970 --> 07:19.530] Again, these are going to point you right to the malware. [07:19.630 --> 07:22.210] But the system call monitoring that EDRs use, [07:22.210 --> 07:26.090] and it's one of the best ways they get visibility on the system, [07:26.090 --> 07:27.610] there was no way to detect this. [07:27.610 --> 07:30.970] And so in our investigations, we were having to do a lot of manual work [07:30.970 --> 07:34.170] to find it, to unravel it, and that just doesn't work [07:34.170 --> 07:37.450] for the scale that we operate at. We need automated ways. [07:40.270 --> 07:43.670] And the reason that the system calls are so critical to EDRs [07:43.670 --> 07:47.550] is the idea with system calls is this is your boundary [07:47.550 --> 07:49.910] from process memory to the kernel. [07:49.910 --> 07:52.910] So this diagram here, the Windows internals book, [07:52.910 --> 07:57.950] you have your processes running, your web browser, your office application, [07:57.950 --> 08:01.750] whatever it is that the process is running in user land or user mode, [08:01.750 --> 08:03.130] it's all the same thing. [08:03.130 --> 08:06.970] Besides manipulating their own memory, whenever they want to access [08:07.250 --> 08:10.330] a resource on the system, so they want to read or write a file, [08:10.330 --> 08:12.370] they want to read or write a network packet, [08:12.370 --> 08:14.770] anything beyond manipulating their own memory, [08:14.770 --> 08:17.030] they have to ask the operating system to do it. [08:17.030 --> 08:19.630] Because obviously you don't want your random notepad process [08:19.630 --> 08:21.670] writing directly to the hard drive. [08:21.670 --> 08:24.790] Or you don't want notepad writing directly to the ring buffer [08:24.790 --> 08:26.870] of your network driver. [08:26.870 --> 08:31.310] So, for processes that want to talk to network devices [08:31.310 --> 08:36.010] and request those operations, reading a file, writing a file, [08:36.010 --> 08:39.390] interacting with the network, it has to go through a system call. [08:39.390 --> 08:42.630] And that system call is going to change the execution context [08:42.630 --> 08:46.210] into the kernel, which is obviously the most privileged part. [08:46.210 --> 08:48.670] It has full access to the operating system itself, [08:48.670 --> 08:50.650] to other drivers, to other hardware. [08:50.990 --> 08:53.270] What you're seeing on the right side of this slide [08:53.270 --> 08:57.510] is the arrow that breaks down between process memory and the kernel [08:57.510 --> 08:59.770] where the system calls happen. [08:59.770 --> 09:02.070] You're seeing a stack trace of that here. [09:02.190 --> 09:04.330] When you look at a stack trace, you want to start at the bottom [09:04.330 --> 09:05.790] to make sense of it. [09:05.790 --> 09:09.250] So in the beginning, what these lines or these rows here with the U, [09:09.250 --> 09:12.070] this is in user land, or again, process memory. [09:12.110 --> 09:15.010] You can see that the Edge browser is running. [09:15.110 --> 09:18.570] It eventually gets to this call, ZW create file. [09:18.570 --> 09:22.490] Your system calls will, in almost all cases, start with ZW. [09:22.490 --> 09:26.750] And then you can see this is sysinternals monitoring the call stack. [09:26.750 --> 09:29.010] It eventually, when the system call is made, [09:29.010 --> 09:31.030] it jumps into the kernel file. [09:31.050 --> 09:33.070] And this K means we're in kernel memory. [09:33.170 --> 09:37.730] So this last call, the ZW, whatever that particular system call is, [09:37.730 --> 09:40.550] that is the last boundary before we jump in the kernel. [09:40.550 --> 09:43.270] And the reason we're focusing on this background so much [09:43.270 --> 09:45.550] is this is where your EDRs live. [09:45.910 --> 09:48.910] Because if you look at this slide, what we're seeing, [09:48.910 --> 09:50.470] I'll explain in more detail in a second, [09:50.470 --> 09:53.650] but on the left is the normal system call handler. [09:53.650 --> 09:56.230] So this is what you get with Windows by default. [09:56.230 --> 10:00.730] In this case, the slide is showing ZW protect virtual memory, [10:00.730 --> 10:02.930] so another system call on Windows. [10:02.930 --> 10:06.410] On the left is the normal flow that's going to reach the kernel. [10:06.450 --> 10:09.290] On the right is an EDR that has hooked it. [10:09.290 --> 10:13.330] So EDRs that want to monitor what processes are doing on the machine [10:13.330 --> 10:16.690] by injecting code into every process, [10:16.690 --> 10:18.970] hooking the system call functions of interest, [10:18.970 --> 10:21.910] it has complete control over what that process is doing [10:21.910 --> 10:23.950] right before it makes the system call. [10:23.950 --> 10:26.390] So if it wants to look for suspicious parameters, [10:26.390 --> 10:28.850] if it wants to log out what files are being read, [10:28.850 --> 10:31.210] what parts of the registry are being interacted with, [10:31.210 --> 10:35.770] by hooking that lowest level function, the EDR has full visibility. [10:36.130 --> 10:38.270] And so as we'll see here in a second, [10:38.270 --> 10:41.310] what malware wants to do is make its system calls [10:41.310 --> 10:44.650] without EDRs interfering or detecting it. [10:44.710 --> 10:46.010] But some background real quick [10:46.010 --> 10:48.250] while we're on a nice slide with a picture. [10:48.250 --> 10:50.750] What we're seeing here, again on the left, [10:50.750 --> 10:54.170] is the normal system call handler that jumped. [10:54.170 --> 10:55.290] We're going to go back. [10:55.370 --> 10:59.030] So what we see on the left is the normal system call handler. [10:59.030 --> 11:01.090] And there's a few things to keep in mind. [11:01.090 --> 11:03.930] First off, when you have the NT version of a function [11:03.930 --> 11:06.470] and then the ZW prefix version, [11:06.470 --> 11:09.170] it's the same exact function, but one's in user land, [11:09.170 --> 11:10.270] one's in the kernel. [11:10.270 --> 11:11.930] So we're seeing that here. [11:11.930 --> 11:16.430] The second thing is, from regular C code or C++ code, [11:16.430 --> 11:17.730] when you call a function, [11:17.730 --> 11:20.390] the parameters are sent in certain registers. [11:20.390 --> 11:22.790] We're going to focus on 64-bit machines. [11:23.050 --> 11:27.570] And besides RCX and R10, they're exactly the same. [11:27.570 --> 11:30.830] The weird thing is, with Windows, when you make a system call, [11:30.830 --> 11:34.770] your second parameter needs to be an R10 instead of RCX. [11:34.770 --> 11:37.410] So this has to get updated in those paths. [11:37.410 --> 11:41.410] And then EAX or REX has to hold the system call number. [11:41.410 --> 11:43.470] So for all the hundreds of system calls [11:43.470 --> 11:46.050] that Windows has for a particular version, [11:46.050 --> 11:48.210] each system call has its own number. [11:48.210 --> 11:49.590] And if you look at these handlers, [11:49.590 --> 11:52.770] they all look exactly like this, except this number changes, [11:52.770 --> 11:56.610] because that is the index into the system call table at runtime. [11:57.130 --> 11:58.370] And then we have a quick check [11:58.370 --> 12:01.130] to see what system call path is supported. [12:01.290 --> 12:04.130] And then to make that transition to kernel mode, [12:04.130 --> 12:06.290] we're either going to use the system call instruction, [12:06.290 --> 12:08.330] or if we're on an older processor, [12:08.330 --> 12:09.590] older version of Windows, [12:09.590 --> 12:11.810] we're going to make the int2e call. [12:11.890 --> 12:13.830] So again, this is, on the left, [12:13.830 --> 12:16.350] is what we would expect on a regular machine [12:16.350 --> 12:17.870] where you don't have EDRs. [12:17.870 --> 12:19.730] And then if you look on the right here, [12:19.730 --> 12:21.090] instead of all this code, [12:21.090 --> 12:23.150] eventually calling system call, [12:23.150 --> 12:25.470] we just have a jump out to an unknown region, [12:25.470 --> 12:27.470] which is going to be the EDR. [12:27.530 --> 12:29.450] And then when malware calls something like [12:29.450 --> 12:31.490] protect virtual memory here, [12:31.490 --> 12:33.630] or create file on the previous slide, [12:33.630 --> 12:35.550] the EDR has full control of that. [12:35.550 --> 12:36.710] It's going to kill the ransomware [12:36.710 --> 12:38.970] before it can launch any payloads. [12:38.970 --> 12:41.610] It's going to kill all the code injection techniques. [12:41.610 --> 12:43.250] And so if you have a decent EDR [12:43.250 --> 12:45.290] and it's not being tampered with, [12:45.290 --> 12:47.750] it's going to stop all these regular malware techniques [12:47.750 --> 12:48.790] from functioning. [12:48.850 --> 12:50.770] But like I said, we constantly do investigations [12:50.770 --> 12:53.810] where there's very potent malware on the machine, [12:53.810 --> 12:55.910] there's supposedly EDR on the machine, [12:55.910 --> 12:58.490] but when we dig into the infected processes, [12:58.490 --> 13:00.230] the EDR has been nullified. [13:07.280 --> 13:09.340] So what we're going to do for the rest of the talk [13:09.340 --> 13:12.120] is look at all of the bypasses that we found. [13:12.120 --> 13:13.780] Like I said, in our own investigations, [13:13.780 --> 13:15.040] there's a bunch of open source tools [13:15.040 --> 13:16.040] that do it as well. [13:16.040 --> 13:17.900] And then how we can detect them. [13:17.900 --> 13:20.800] The first one goes by a couple different names. [13:20.800 --> 13:22.860] Module unhooking, system call unhooking, [13:22.860 --> 13:24.280] API unhooking. [13:24.360 --> 13:26.200] The basic idea here is the malware [13:26.200 --> 13:29.200] is going to unhook the system call handlers. [13:29.280 --> 13:30.600] And the end goal is [13:30.600 --> 13:32.200] when malware starts running [13:32.200 --> 13:34.260] and they're in a process that EDRs [13:34.260 --> 13:36.660] have all the system calls in this hooked form, [13:36.660 --> 13:38.520] it wants to get it back to the original form [13:38.520 --> 13:41.640] so that the EDR is blind to what's going on. [13:42.600 --> 13:43.960] The way this works, [13:43.960 --> 13:46.180] and this PowerPoint keeps jumping a lot, [13:46.180 --> 13:48.180] the way this works, this is a screenshot [13:48.180 --> 13:49.940] from a very recent report [13:50.800 --> 13:52.380] from a very recent report [13:52.380 --> 13:53.620] maybe two or three months ago [13:54.120 --> 13:56.120] of malware that did this to then spread [13:56.120 --> 13:57.840] across a huge network. [13:57.880 --> 14:00.480] The basic idea is where system calls [14:00.480 --> 14:01.880] are implemented in memory [14:01.880 --> 14:03.560] is NTDLL. [14:03.680 --> 14:05.880] So the first DLL that loads in every process [14:05.880 --> 14:08.300] is NTDLL that has all of those [14:08.300 --> 14:11.180] system call handlers, one per system call. [14:11.340 --> 14:12.900] And that's what the EDRs hook. [14:12.900 --> 14:14.220] They put the jump instruction, [14:14.220 --> 14:15.880] it goes directly to the EDR code [14:15.880 --> 14:17.980] and then like I said, the EDR can evaluate [14:17.980 --> 14:20.700] the parameters before the system call is made. [14:20.760 --> 14:22.120] So you can see it in the steps here, [14:22.120 --> 14:23.860] this report was really nice. [14:23.860 --> 14:25.800] What this malware did is it read [14:25.800 --> 14:28.320] the clean copy of NTDLL from disk [14:28.320 --> 14:30.180] so that copy on disk is what [14:30.180 --> 14:32.260] Microsoft published that does not have [14:32.260 --> 14:33.860] any EDR hooks present. [14:33.860 --> 14:36.000] So it reads NTDLL from disk, [14:36.000 --> 14:38.060] it finds where those system call handlers [14:38.060 --> 14:40.000] are in their clean state on disk [14:40.000 --> 14:42.220] and it just overwrites all the EDRs [14:42.220 --> 14:44.260] hooks. And now the malware can call [14:44.260 --> 14:46.380] any system call at once with whatever malicious [14:46.380 --> 14:48.320] parameters it wants, any malicious [14:48.320 --> 14:50.380] end goal that it has, and even [14:50.380 --> 14:52.320] though the EDR is technically loaded in that [14:52.320 --> 14:54.220] process, its code is never going to be [14:54.220 --> 14:56.440] activated. And so when we look at ransomware [14:56.440 --> 14:58.200] and we're like, how can it inject code? [14:58.200 --> 15:00.460] How's it encrypting all the files? How's it elevating [15:00.460 --> 15:02.240] privileges? It's because the EDR [15:02.240 --> 15:04.360] has no idea what's going on, and this [15:04.360 --> 15:06.400] is one of the many ways that we'll talk [15:06.400 --> 15:08.280] about how it happens. So again, [15:08.280 --> 15:10.220] you go from the state where every [15:10.220 --> 15:12.240] process on the machine has their [15:12.240 --> 15:14.480] system calls hooked, the malicious [15:14.480 --> 15:16.260] code, the malware is going to run in its [15:16.260 --> 15:18.120] own process, or it's going to inject code [15:18.120 --> 15:20.180] into a victim process, and in that [15:20.180 --> 15:22.720] victim process, or the malware's own process, [15:22.720 --> 15:24.280] the system call handlers will [15:24.280 --> 15:26.200] be reverted back to where [15:26.200 --> 15:28.120] they were on disk, but all the other [15:28.120 --> 15:30.300] processes will have the hooked form. [15:30.360 --> 15:32.200] So what we realized is instead of trying [15:32.200 --> 15:34.000] to figure out the 50 different [15:34.000 --> 15:36.260] variations for module unhooking, [15:36.260 --> 15:38.240] we could just use data in memory to [15:38.240 --> 15:39.140] tell us where [15:40.460 --> 15:42.280] the malware is. So [15:42.280 --> 15:44.240] what our new volatility plugin does [15:44.240 --> 15:46.180] is it enumerates every [15:46.180 --> 15:48.360] process, it reads the bytes [15:48.360 --> 15:50.380] of all the system call handlers that [15:50.380 --> 15:52.440] the malware often [15:52.440 --> 15:54.160] targets, and then we just compare [15:54.160 --> 15:56.300] the implementations. And as you'll see here [15:56.300 --> 15:58.360] in a couple slides, what we can do is [15:58.360 --> 16:00.160] say, you have 100 processes [16:00.160 --> 16:02.160] running, 99 of them have [16:02.160 --> 16:04.420] one implementation, and this one process [16:04.420 --> 16:06.840] on its own has a different implementation. [16:06.840 --> 16:08.760] The 99 are the ones where the EDR [16:08.760 --> 16:10.800] is still active, and that one kind of [16:10.800 --> 16:12.820] outlier process is the one that the malware [16:12.820 --> 16:14.880] is unhooked. And so [16:14.880 --> 16:16.800] we like, when we do this type of research, we [16:16.800 --> 16:18.700] like to make experiments that can be [16:18.700 --> 16:20.880] repeated by anyone else. Obviously [16:20.880 --> 16:22.660] not everyone works at Velocity [16:22.660 --> 16:24.820] and has access to our infected [16:24.820 --> 16:26.700] samples from the wild, so we come up with [16:26.700 --> 16:28.880] experiments using open source tools [16:28.880 --> 16:30.760] where you can recreate this on your own [16:30.760 --> 16:33.120] and you can test it in your own environment. [16:33.220 --> 16:34.540] So a very nice tool [16:34.540 --> 16:36.760] for testing EDR, a very nice [16:36.760 --> 16:38.580] open source tool for testing [16:38.580 --> 16:41.260] EDR bypasses is called SilentStrike. [16:41.260 --> 16:42.620] So this is an open [16:42.620 --> 16:44.840] source EDR, and it was actually developed [16:44.840 --> 16:46.960] just to test these bypasses [16:46.960 --> 16:48.860] and then see if you could detect them. [16:48.860 --> 16:50.620] The way SilentStrike works is [16:50.620 --> 16:52.520] it hooks NT protect virtual [16:52.520 --> 16:54.820] memory. This is one of the main functions [16:54.820 --> 16:56.840] that malware needs to perform [16:56.840 --> 16:58.680] code injection and also to try [16:58.680 --> 17:00.840] to keep that code injection stealthy. [17:00.840 --> 17:02.760] And so what this open source EDR [17:02.760 --> 17:04.260] does is it hooks that function [17:04.260 --> 17:07.020] if it gets called where the region is going to become [17:07.020 --> 17:08.600] readable, writable, and executable [17:08.600 --> 17:10.880] the EDR says you can't do that, and that [17:10.880 --> 17:13.560] stops a lot of different code injection techniques. [17:13.680 --> 17:15.020] So for our experiment [17:15.020 --> 17:16.920] what we did is we took a base [17:16.920 --> 17:18.820] Windows 10 install, so no [17:18.820 --> 17:20.760] EDR. With SilentStrike [17:21.280 --> 17:22.840] you can tell it to create [17:22.840 --> 17:24.760] individual processes that it will [17:24.760 --> 17:27.260] then treat as an EDR and protect. [17:27.340 --> 17:28.640] So we started a notepad [17:28.640 --> 17:30.920] and we started a wordpad. At this point [17:30.920 --> 17:32.960] they have SilentStrike active in it [17:32.960 --> 17:34.820] which is your EDR. [17:34.820 --> 17:36.860] We then took a memory sample. [17:37.000 --> 17:38.680] After that we ran R77 [17:38.680 --> 17:40.800] which is an open source rootkit [17:40.800 --> 17:42.420] that does this module unhooking [17:42.920 --> 17:45.040] and we unhooked the notepad [17:45.040 --> 17:46.820] process. And then we took a second [17:46.820 --> 17:48.880] memory sample. So we have the state [17:48.880 --> 17:51.000] before and after the malware ran [17:51.920 --> 17:52.980] and with [17:52.980 --> 17:54.900] our new plugin, so unhook system [17:54.900 --> 17:56.620] calls to volatility 3 [17:56.620 --> 17:58.900] what it's saying here is what [17:58.900 --> 18:00.740] we do is we enumerate all the functions [18:00.740 --> 18:03.080] the slide is cut, there's probably like 50 functions [18:03.080 --> 18:04.960] we actually check. But the idea [18:04.960 --> 18:06.920] is we're saying for these processes [18:06.920 --> 18:08.920] down here, there's no distinct [18:08.920 --> 18:10.920] implementations. So every process [18:11.580 --> 18:12.880] inside of that memory [18:12.880 --> 18:15.120] sample had the same version of the function [18:15.120 --> 18:17.140] and then the two that we started [18:17.140 --> 18:18.940] under SilentStrike, their NT [18:18.940 --> 18:20.840] protect virtual memory, had the [18:20.840 --> 18:23.080] EDR's view. This is before we ran [18:23.080 --> 18:24.940] R77. We [18:24.940 --> 18:26.920] then ran the R77 rootkit [18:26.920 --> 18:28.840] on the machine. We [18:28.840 --> 18:30.820] unhooked notepad and you can see it [18:30.820 --> 18:33.020] removes from distinct implementations [18:33.020 --> 18:34.820] it's been reverted back to the base [18:34.820 --> 18:36.720] form. So then we took this plugin [18:36.720 --> 18:38.980] ran it across the many [18:38.980 --> 18:40.960] hundreds of memory samples that we have [18:40.960 --> 18:42.420] to test our code on [18:42.760 --> 18:44.720] and the only place this plugin [18:44.720 --> 18:46.540] fired was either traditional [18:46.540 --> 18:48.800] API hooking or EDR unhooks. [18:48.800 --> 18:51.020] So there's no false positives with this [18:51.020 --> 18:52.640] if the EDR's hooked every process [18:52.640 --> 18:54.920] it doesn't make sense that it would skip one or that [18:54.920 --> 18:56.860] one should be reverted. This directly [18:56.860 --> 18:59.220] tells you where the malware is running. [19:00.560 --> 19:02.900] We then started looking into other [19:02.900 --> 19:04.980] ways to read NTDLL. So [19:04.980 --> 19:06.960] you saw it in the screenshot before from that [19:06.960 --> 19:08.900] malware report and I walked you [19:08.900 --> 19:10.920] through where to, for unhooking [19:10.920 --> 19:12.740] to work, the malware needs access [19:12.740 --> 19:14.700] to a clean copy of NTDLL [19:14.700 --> 19:17.060] which normally you can just read from disk [19:17.060 --> 19:18.960] but there were several EDR vendors [19:18.960 --> 19:20.820] that started detecting that because [19:20.820 --> 19:23.080] why would some random process need to read [19:23.080 --> 19:24.960] NTDLL as a file and like [19:24.960 --> 19:27.100] parse the section? The only reason to [19:27.100 --> 19:28.980] do that is to unhook the EDR [19:28.980 --> 19:31.100] out of memory. So this made [19:31.100 --> 19:33.280] it harder for that malware to operate [19:33.280 --> 19:35.100] it can't read NTDLL from [19:35.100 --> 19:36.740] disk or it's going to get caught. [19:36.780 --> 19:39.140] So we saw some malware samples and some [19:39.140 --> 19:40.820] open source tools that [19:40.820 --> 19:43.060] abused suspended processes to get [19:43.060 --> 19:45.380] the clean copy. If you've ever investigated [19:45.380 --> 19:47.040] process hollowing, whether [19:47.040 --> 19:49.080] you were writing code for it or you were trying to [19:49.080 --> 19:51.060] detect it, creating suspended [19:51.060 --> 19:53.140] processes is the first step of every [19:53.140 --> 19:55.040] process hollowing technique. So we'll see [19:55.040 --> 19:56.940] that we catch some of those as well [19:56.940 --> 19:59.100] as kind of a side effect. But the idea [19:59.100 --> 20:00.900] for EDR bypasses is [20:00.900 --> 20:03.180] the malware will create a suspended [20:03.180 --> 20:05.020] process. The idea with [20:05.180 --> 20:06.960] a suspended process is that the [20:06.960 --> 20:09.080] only thing that's going to load is [20:09.080 --> 20:11.000] the application executable and [20:11.000 --> 20:12.980] NTDLL. It's kind of like a half [20:12.980 --> 20:14.800] created process at that point. [20:15.020 --> 20:16.880] Once the EXE and [20:16.880 --> 20:19.380] NTDLL are mapped into the process [20:19.380 --> 20:21.500] then at that point the parent [20:21.500 --> 20:23.500] process, the one who created the process, gets [20:23.500 --> 20:25.420] control back. So then what the [20:25.420 --> 20:27.380] malware does is it just reads from its [20:27.380 --> 20:29.700] child process, the clean NTDLL [20:29.700 --> 20:31.320] out of memory. The EDR [20:31.320 --> 20:33.380] doesn't see a suspended process until [20:33.380 --> 20:35.460] it actually starts running. So this [20:35.460 --> 20:37.360] puts a clean copy of NTDLL in [20:37.360 --> 20:39.500] memory. The malware doesn't have to go read it from [20:39.500 --> 20:41.400] disk. And so obviously we want it to be [20:41.400 --> 20:43.220] able to detect this as well. [20:44.240 --> 20:45.380] So we did [20:45.380 --> 20:47.140] some reverse engineering and read some [20:47.140 --> 20:49.140] pre-existing reports on what [20:49.140 --> 20:51.120] happens with suspended processes. Like I [20:51.120 --> 20:53.060] said, we see it a lot because you have to do [20:53.060 --> 20:55.600] this if you want to create a hollowed process. [20:55.740 --> 20:57.020] But what you have in kernel [20:57.020 --> 20:59.100] memory is for every process you have [20:59.100 --> 21:01.060] an E-process structure. For every [21:01.060 --> 21:03.020] thread you have an E-thread or a [21:03.020 --> 21:05.260] K-thread structure. When that process [21:05.260 --> 21:07.540] gets created in the suspended state [21:07.540 --> 21:09.980] every process starts with one thread. [21:09.980 --> 21:11.260] And when you create the [21:11.260 --> 21:13.480] thread suspended, its suspense [21:13.480 --> 21:14.960] count goes to one, which tells the [21:14.960 --> 21:17.120] operating system not to run it. Normally [21:17.120 --> 21:18.920] if you just create a process in the normal [21:18.920 --> 21:21.240] way or you double click it on your desktop, [21:21.240 --> 21:23.020] the suspend count is going to be zero. [21:23.020 --> 21:24.940] And as soon as that process can get scheduled, [21:24.940 --> 21:26.940] its threads are going to run. But what [21:26.940 --> 21:29.020] we saw in every piece of malware [21:29.020 --> 21:30.880] that we had and every open source tool we [21:30.880 --> 21:32.880] had access to that did this, when [21:32.880 --> 21:34.920] they create the suspended process just [21:34.920 --> 21:36.980] to read the clean NTDLL, [21:36.980 --> 21:39.220] they're never going to run that child process. [21:39.220 --> 21:40.740] They are just getting that into memory [21:40.740 --> 21:42.820] to get access to the clean [21:42.820 --> 21:44.900] system call handlers. So this was [21:44.900 --> 21:47.180] pretty easy. We wrote a plugin. [21:47.180 --> 21:48.760] Volatility could already enumerate [21:48.760 --> 21:50.760] every thread of every process. [21:50.760 --> 21:52.760] And then we just added an extra step to say [21:52.760 --> 21:54.620] does that thread have a suspend count [21:54.620 --> 21:56.740] greater than zero. Running it across [21:56.740 --> 21:59.260] our large data set of memory samples, [21:59.260 --> 22:00.980] the only false positive we had, [22:00.980 --> 22:02.620] which was pretty random, is this [22:02.620 --> 22:04.740] work folder shell DLL inside [22:04.740 --> 22:06.600] of edge makes suspended threads. [22:06.600 --> 22:08.640] We don't know why. So we just added that [22:08.640 --> 22:11.040] to the list of ones we don't print out. [22:11.040 --> 22:12.820] And besides that, we didn't have a single [22:12.820 --> 22:14.820] false positive. And then like I said, [22:14.820 --> 22:16.840] at Vlexity, we have hundreds and hundreds [22:16.840 --> 22:18.660] of memory samples in different states [22:18.660 --> 22:20.680] that we test these things on. And [22:20.680 --> 22:22.720] quite a few of the samples that we know [22:22.720 --> 22:24.780] have process hollowing in them, they were [22:24.780 --> 22:26.780] detected too, because if you're [22:26.780 --> 22:28.700] familiar with that technique, the idea [22:28.700 --> 22:30.580] is you create a process in a suspended [22:30.580 --> 22:32.640] state, you overwrite the code, and then [22:32.640 --> 22:34.800] you let that new process run. And so [22:34.800 --> 22:36.660] not only is this plugin picking up [22:36.660 --> 22:38.800] all the EDR bypasses, we caught [22:38.880 --> 22:41.000] a bunch of different... we generically [22:41.000 --> 22:42.900] caught a bunch of different process hollowing [22:42.900 --> 22:44.340] techniques as well. [22:51.750 --> 22:52.790] At Blackhat [22:52.790 --> 22:54.750] Europe, maybe two years ago now, [22:54.750 --> 22:56.730] three years ago, there was a really cool white [22:56.730 --> 22:58.970] paper and talk on a project called [22:58.970 --> 23:01.050] Dirty Vanity. The idea was [23:01.050 --> 23:02.730] they tested against basically every [23:02.730 --> 23:04.870] commercial EDR they could get their hands [23:04.870 --> 23:06.650] on. And the idea is they wanted [23:06.650 --> 23:08.630] to be able to do code injection into [23:08.870 --> 23:11.050] a victim process without the EDRs [23:11.050 --> 23:12.690] catching them. And if you're familiar [23:12.690 --> 23:14.670] with this, to do code injection, there's five [23:14.670 --> 23:16.690] or six APIs you have to call to make [23:16.690 --> 23:18.770] that work. And if you call all [23:18.770 --> 23:20.670] those in a row and you're injecting, the [23:20.670 --> 23:22.610] end result is you're going to inject into your [23:22.610 --> 23:24.890] victim process, any half-decent [23:24.890 --> 23:26.810] EDR, any enterprise-level [23:26.810 --> 23:28.890] EDR is going to catch that. [23:28.990 --> 23:30.730] So what was really interesting about Dirty [23:30.730 --> 23:32.630] Vanity is they instead created [23:32.630 --> 23:34.750] clone processes, or a forked process [23:34.750 --> 23:36.930] if you're more familiar with Linux. [23:36.950 --> 23:39.110] So the idea with a clone or a [23:39.110 --> 23:40.930] forked process is your process [23:40.930 --> 23:43.030] is running, you create a clone [23:43.030 --> 23:44.870] of your own process, so that [23:44.870 --> 23:46.930] child process you created has your [23:46.930 --> 23:49.010] same exact state. So then what [23:49.010 --> 23:51.110] Dirty Vanity did is they called the first [23:51.110 --> 23:52.710] couple APIs from the parent [23:52.710 --> 23:54.890] and then they create the clone, [23:54.890 --> 23:56.810] which has the same exact state as the parent [23:56.810 --> 23:58.810] and they called the final set of APIs [23:58.810 --> 24:01.030] from the child. So the end result is [24:01.030 --> 24:02.970] they're still injecting code into the [24:02.970 --> 24:05.030] victim process, but none of the [24:05.030 --> 24:07.090] EDRs that they tested were able to [24:07.090 --> 24:08.890] detect the calls going across [24:08.890 --> 24:10.810] the process boundary. So obviously [24:10.810 --> 24:12.350] we wanted to be able to detect this [24:12.810 --> 24:15.150] from a memory forensic standpoint. [24:15.390 --> 24:16.750] So while we were looking [24:16.750 --> 24:19.110] into what it means to clone a process [24:19.110 --> 24:20.830] in Windows, the real internal [24:20.830 --> 24:22.970] state, we saw that what Windows [24:22.970 --> 24:24.670] does when it's setting up that clone [24:24.670 --> 24:26.810] is it makes a suspended thread. [24:26.810 --> 24:28.950] So that child that's being cloned into [24:28.950 --> 24:30.810] has its first thread suspended [24:30.810 --> 24:32.910] and with Dirty Vanity it [24:32.910 --> 24:34.850] never restarted the child process [24:34.850 --> 24:37.390] or the initial thread of the child process. [24:37.390 --> 24:39.270] So the plugin that we had detected it [24:39.270 --> 24:41.530] right away. And if you're interested in this [24:41.530 --> 24:43.670] I have it cited here at the bottom. [24:43.670 --> 24:45.370] We found this thing called the Definitive Guide [24:45.370 --> 24:47.110] to Process Cloning on Windows. It's like [24:47.110 --> 24:49.290] 40 pages of APIs and [24:49.290 --> 24:51.230] data structures and background, but it [24:51.230 --> 24:53.490] pretty much told us exactly what we needed to know [24:53.490 --> 24:56.070] on top of what we saw with reversing. [24:57.190 --> 24:59.110] We made a memory sample that was [24:59.110 --> 25:00.870] infected with Dirty Vanity [25:01.390 --> 25:03.090] and as you can see we're running our [25:03.090 --> 25:04.890] suspended threads plugin. [25:04.890 --> 25:06.630] It's telling us that inside [25:06.630 --> 25:08.910] of the fake EXE process, which is [25:08.910 --> 25:10.690] what Dirty Vanity calls itself [25:10.690 --> 25:12.550] if you just compile it straight from GitHub [25:12.550 --> 25:14.810] and then it's saying that [25:14.810 --> 25:17.350] this process ID, 6752 [25:17.350 --> 25:19.070] this thread, it is [25:19.070 --> 25:20.830] suspended or suspend count [25:20.830 --> 25:22.750] is greater than zero. And then [25:22.750 --> 25:24.750] if you look at PSTree in Volatility [25:24.750 --> 25:26.950] so this is drawing out the parent [25:26.950 --> 25:28.590] child relationship of processes [25:28.590 --> 25:31.110] you can see that the original [25:31.110 --> 25:32.910] fake EXE has [25:33.030 --> 25:35.370] a child called fake EXE [25:35.370 --> 25:36.730] so this is that [25:36.730 --> 25:39.070] process that was created through [25:39.070 --> 25:40.970] cloning. So this is the [25:40.970 --> 25:42.890] parent, this is where Dirty Vanity [25:42.890 --> 25:44.430] will call the first couple APIs [25:44.430 --> 25:46.910] it then forks or clones off [25:47.090 --> 25:49.010] a child process where it will call the remaining [25:49.010 --> 25:50.970] APIs bypassing the [25:50.970 --> 25:52.970] EDR, but what you can [25:52.970 --> 25:54.930] see Volatility picking up on is the [25:54.930 --> 25:56.790] child's always going to have it's main thread [25:56.790 --> 25:58.950] suspended. And so we pick up on that [25:58.950 --> 26:01.010] right away, you would then run PSTree [26:01.010 --> 26:02.870] would probably be the next thing if this was a real [26:02.870 --> 26:04.950] investigation, you would figure out the [26:04.950 --> 26:07.150] parent that created the suspended [26:07.150 --> 26:08.910] process. And then you can see [26:08.910 --> 26:11.010] here what it does in demo [26:11.010 --> 26:13.230] mode, so if you don't have an EDR you're targeting [26:13.230 --> 26:14.910] Dirty Vanity will run [26:14.910 --> 26:17.110] command shell with some shell code that [26:17.110 --> 26:19.050] makes a pop up on the screen or prints it [26:19.050 --> 26:21.050] to the terminal. So you see that here [26:21.050 --> 26:23.010] as well, that child process. [26:23.010 --> 26:24.890] But through the new plugin you see exactly [26:24.890 --> 26:26.950] which process is malicious, you can [26:26.950 --> 26:28.750] then do your normal memory forensics [26:28.750 --> 26:29.730] workflow. [26:34.060 --> 26:36.560] As you've been seeing in the slides, [26:36.560 --> 26:38.220] the previous techniques that we looked [26:38.220 --> 26:40.440] into for bypassing [26:40.440 --> 26:42.400] the system call handlers relied [26:42.400 --> 26:44.140] on overwriting code. [26:44.260 --> 26:46.240] And you might have been thinking, especially if you've [26:46.240 --> 26:47.680] done debugging before or [26:47.680 --> 26:50.100] low level programming before, the [26:50.100 --> 26:52.400] idea that you're going to overwrite NTDLL [26:52.400 --> 26:54.160] the entire thing or certain functions [26:54.160 --> 26:56.060] at run time is a bit unsafe. [26:56.060 --> 26:58.320] Because you can imagine if you're overwriting [26:58.320 --> 27:00.140] 30 or 40 functions code in [27:00.140 --> 27:02.120] memory, if any other thread is [27:02.120 --> 27:04.100] using that function or a system call [27:04.100 --> 27:06.160] was just made and you're waiting for user land [27:06.160 --> 27:08.160] to return again, you just blew away [27:08.160 --> 27:10.160] the code that was technically running on the [27:10.160 --> 27:12.140] CPU. So malware does it, [27:12.140 --> 27:14.380] it generally works, but it's a bit unsafe. [27:14.380 --> 27:16.020] And then the other thing you could imagine [27:16.020 --> 27:18.240] is EDR could just check for its hooks. [27:18.240 --> 27:20.260] If it hooked 40 or 50 system [27:20.260 --> 27:22.000] call handlers and then it checks [27:22.000 --> 27:24.340] whatever frequency later and its handlers [27:24.340 --> 27:26.200] are overwritten, it knows that there's [27:26.200 --> 27:28.280] malware inside of that process. [27:28.280 --> 27:30.260] So this led to what was some [27:30.260 --> 27:32.280] really interesting research on the open [27:32.280 --> 27:33.980] source side, and like I said, we saw it [27:33.980 --> 27:36.220] in private malware as well. [27:36.220 --> 27:38.140] So there were alternative methods developed [27:38.140 --> 27:40.560] where the code is not overwritten. [27:40.560 --> 27:42.300] The malware, as you'll see, can [27:42.300 --> 27:44.260] still make its malicious system calls, [27:44.260 --> 27:46.220] it can still do any system calls at once [27:46.220 --> 27:48.180] with any parameters, but [27:48.180 --> 27:50.400] we're not overwriting code. So inside [27:50.400 --> 27:52.340] of NTDLL, in that EDR [27:52.340 --> 27:54.440] protected process, the original [27:54.440 --> 27:56.460] implementation that the EDR gave [27:56.460 --> 27:58.460] is the same, the hooks are present, [27:58.460 --> 28:00.560] the EDR would get control if the [28:00.560 --> 28:02.480] real system call was used, but [28:02.480 --> 28:04.440] malware is just going to avoid those code [28:04.440 --> 28:06.280] paths. So we'll look at the different ways [28:06.280 --> 28:08.840] they do that and the ways we can detect it. [28:09.540 --> 28:10.540] The first one we [28:10.540 --> 28:12.640] looked at were direct system calls. [28:12.680 --> 28:14.540] So the malware authors realized that [28:14.540 --> 28:16.560] why do I need to call the system call [28:16.560 --> 28:18.860] handler inside of NTDLL? [28:18.860 --> 28:20.420] You saw that a system call handler [28:20.420 --> 28:22.780] is only 5 or 6 instructions, [28:22.780 --> 28:24.500] why don't I just do that myself? [28:24.500 --> 28:26.440] So rather than going through NTDLL, [28:26.440 --> 28:28.500] which the EDR is hooked, I'm just going to [28:28.500 --> 28:30.460] set up the registers that are needed and I'm going to [28:30.460 --> 28:32.840] make the syscall instruction on my own. [28:32.920 --> 28:34.580] And again, the EDRs that are [28:34.580 --> 28:36.640] trying to catch you through system call hooks, [28:36.640 --> 28:38.400] they are blind to you because you're not [28:38.400 --> 28:40.200] going through their hooked code. [28:40.200 --> 28:42.500] The problem with this, and there was a [28:43.740 --> 28:44.840] very interesting series [28:44.840 --> 28:46.680] of posts by Elastic that I have cited [28:46.680 --> 28:48.860] at the end, this is where they started doing [28:48.860 --> 28:50.740] call stack examination, Elastic [28:50.740 --> 28:52.400] does this really well, there's some open [28:52.400 --> 28:54.700] source implementations of it also, [28:54.700 --> 28:56.400] but the idea is, if you [28:56.400 --> 28:58.980] were making a system call instruction, [28:58.980 --> 29:00.520] or you're calling a system call instruction [29:00.520 --> 29:02.640] outside of NTDLL, [29:02.640 --> 29:04.400] so you're in some random DLL that you've [29:04.400 --> 29:06.540] injected, or you're in a shellcode region, [29:06.540 --> 29:08.280] your EDR in kernel mode [29:08.280 --> 29:10.380] can see that. And then it's going to say, why is [29:10.560 --> 29:12.180] a system call being made from a random [29:12.180 --> 29:14.240] shellcode region that wouldn't normally [29:14.240 --> 29:16.160] happen on a running machine? [29:16.260 --> 29:18.740] And then the other downside to this, as we'll see, [29:18.740 --> 29:20.220] is you have to know where the system call [29:20.220 --> 29:22.300] indexes are. So like I said, there's hundreds [29:22.300 --> 29:24.200] of system calls per release of [29:24.200 --> 29:26.340] Windows, and the indexes change almost [29:26.340 --> 29:28.860] every time. The indexes are not guaranteed. [29:28.960 --> 29:30.200] If you're writing normal [29:30.200 --> 29:32.160] legitimate code, you shouldn't care about [29:32.160 --> 29:34.220] the indexes, you just call the higher [29:34.220 --> 29:36.100] level API, and the operating system [29:36.100 --> 29:38.160] does the work for you. But in this case, [29:38.160 --> 29:40.140] where you want to make the system call yourself, and you [29:40.140 --> 29:42.360] don't want to use the normal APIs [29:42.360 --> 29:44.160] because the EDR has hooked them, you [29:44.160 --> 29:46.060] have to be able to get that index value [29:46.060 --> 29:48.020] to put into EAX. [29:48.500 --> 29:49.860] So if we look at the [29:50.400 --> 29:51.860] way that this has evolved [29:51.860 --> 29:53.980] over time, the first tool that made [29:53.980 --> 29:56.060] this popular is called dumpERT. [29:56.060 --> 29:58.280] It's an open source tool, it's still on GitHub, [29:58.280 --> 29:59.880] has a very nice companion blog [29:59.880 --> 30:02.080] post, and as you can see, [30:02.080 --> 30:03.980] for every system call it [30:03.980 --> 30:05.920] wants to make available to the malware, [30:05.920 --> 30:07.920] it has to put that little stub itself. [30:07.920 --> 30:10.000] It has to update R10, [30:10.000 --> 30:12.060] update EAX with the very specific [30:12.060 --> 30:13.880] index for the very specific system [30:13.880 --> 30:16.020] call, then it can call system call [30:16.020 --> 30:18.060] in return, and at this point you [30:18.060 --> 30:20.180] can make those, but if you look at the code, [30:20.180 --> 30:21.900] this is hard-coded to one [30:21.900 --> 30:23.940] version of Windows 7, one release [30:23.940 --> 30:26.100] under Service Pack 1, this is not [30:26.100 --> 30:27.500] something you could use in [30:28.020 --> 30:30.040] generic malware. So instead [30:30.040 --> 30:32.120] what we want to be able to have is where [30:32.120 --> 30:34.100] that is very loud, [30:34.100 --> 30:35.960] instead we want to make it where system [30:35.960 --> 30:38.040] calls can be resolved dynamically. [30:38.040 --> 30:39.980] So instead of your malware having [30:39.980 --> 30:41.880] what would literally be hundreds [30:41.880 --> 30:43.880] of hard-coded system call [30:43.880 --> 30:46.240] tables for different versions of Windows, [30:46.240 --> 30:47.820] we want to find those indexes [30:47.820 --> 30:49.760] dynamically. The first [30:49.760 --> 30:51.980] implementation of this is called [30:51.980 --> 30:53.720] Hell's Gate. Almost every technique [30:53.720 --> 30:55.860] has gate in the name, which makes it kind of annoying [30:55.860 --> 30:57.980] to remember. So the first one is Hell's [30:57.980 --> 30:59.760] Gate. In this case, what it did [30:59.760 --> 31:02.080] is it parsed NTDLL on disk. [31:02.080 --> 31:03.860] Kind of like we talked about before, but [31:03.860 --> 31:05.960] instead of overwriting pre-existing [31:05.960 --> 31:07.820] code or the EDR's code, [31:07.820 --> 31:09.960] it's just parsing NTDLL on disk [31:09.960 --> 31:11.680] and then it's dynamically resolving [31:11.680 --> 31:14.160] the numbers. Because, for example, [31:14.160 --> 31:15.800] let's say in this case it wants to [31:15.800 --> 31:17.780] call a ZW open process. [31:17.840 --> 31:19.560] Instead of having to know beforehand [31:19.560 --> 31:21.560] that on Windows 7 Service Pack 1 [31:21.560 --> 31:23.900] the index is 23 hex, [31:23.900 --> 31:26.260] it can just load NTDLL, [31:26.260 --> 31:27.600] it can call get proc address [31:27.600 --> 31:29.720] for ZW open process, it can [31:29.720 --> 31:32.080] do some automated disassembly on the code, [31:32.080 --> 31:34.320] and it can read out the index dynamically. [31:34.620 --> 31:35.920] So this was Hell's Gate. [31:35.920 --> 31:38.020] You can see the code here on the right. [31:38.020 --> 31:39.660] Instead of being hard-coded to a certain [31:39.660 --> 31:41.800] number, it has a little API wrapper [31:41.800 --> 31:43.500] that you use as a programmer. [31:43.640 --> 31:45.660] You prep the system call, that's going to fill [31:45.660 --> 31:47.620] in this global variable, and then when it [31:47.620 --> 31:49.700] comes time to make the system call, [31:49.700 --> 31:52.300] it will fill in the number correctly for you. [31:52.300 --> 31:54.080] The problem with this, like I said, [31:54.080 --> 31:55.180] is most [31:55.180 --> 31:57.880] decent EDRs, I'm not going to say certain vendors, [31:57.880 --> 31:59.600] but most decent EDRs, if [31:59.600 --> 32:01.520] random code is reading NTDLL [32:01.520 --> 32:03.720] and parsing the P header and all of that, [32:03.720 --> 32:05.580] the EDR is going to flag on it because it's just [32:05.580 --> 32:08.020] not something legitimate code would do. [32:08.020 --> 32:10.020] So this led to even more [32:10.020 --> 32:12.020] gates. There is Tataris [32:12.020 --> 32:14.040] Gate, which initially, there [32:14.040 --> 32:15.920] was some detections and some YARA [32:15.920 --> 32:18.160] rules that were put out to detect [32:18.160 --> 32:20.200] this code pattern that's very hard-coded [32:20.200 --> 32:21.960] and this code pattern that's very [32:21.960 --> 32:24.040] hard-coded. All it did was [32:24.040 --> 32:25.960] make it a little more difficult to where [32:25.960 --> 32:27.940] those naive patterns would break. It put [32:27.940 --> 32:29.960] some no-op instructions, it [32:29.960 --> 32:31.980] put some other instructions that didn't have a side [32:31.980 --> 32:33.980] effect. But remember, you're in the system [32:33.980 --> 32:36.020] call handler path, so you can't [32:36.020 --> 32:38.080] add a bunch of junk instructions or you will [32:38.080 --> 32:40.140] kill performance on the machine. [32:40.140 --> 32:42.040] In a real process, you're going to have thousands [32:42.040 --> 32:44.140] and thousands of system calls running. [32:44.140 --> 32:45.980] You cannot have where you put in a bunch of [32:45.980 --> 32:47.860] junk code just to throw off a YARA [32:47.860 --> 32:49.860] rule. So even adding a few extra [32:49.860 --> 32:51.820] instructions will have a real impact [32:51.820 --> 32:54.120] on the system. So like I said, Tataris [32:54.120 --> 32:55.960] Gate is just trying to make it where if all [32:55.960 --> 32:57.780] you have is a kind of brittle, basic [32:57.780 --> 32:59.960] YARA rule, you will not catch those code [32:59.960 --> 33:02.000] patterns. There was then Halos [33:02.000 --> 33:04.000] Gate, which was an interesting [33:04.000 --> 33:06.220] twist on reading NTDLL [33:06.220 --> 33:08.160] from disk. So they wanted to, [33:08.160 --> 33:10.140] these malware authors wanted to get away [33:10.140 --> 33:12.400] from reading NTDLL from disk. [33:12.400 --> 33:14.080] So instead what they do is they kind [33:14.080 --> 33:16.080] of rely on the fact that the EDRs [33:16.080 --> 33:18.040] aren't going to hook every system call. [33:18.040 --> 33:19.980] They're just going to, the malware is [33:19.980 --> 33:22.020] only going to unhook this, sorry, the EDR is [33:22.020 --> 33:24.160] only going to hook the system calls that it wants to [33:24.160 --> 33:25.980] monitor. So what [33:25.980 --> 33:28.180] Halos Gate does is it dynamically goes [33:28.180 --> 33:29.720] through all the other system calls [33:29.720 --> 33:31.820] that the EDR is not hooking [33:31.820 --> 33:33.760] and then it just does some math. It says, [33:33.760 --> 33:35.880] OK, I know the system call before it and the system [33:35.880 --> 33:37.880] call after it are this number, so the one [33:37.880 --> 33:39.880] in the middle, it can dynamically figure it [33:39.880 --> 33:41.800] out. Again, this avoids reading [33:41.800 --> 33:43.700] NTDLL from disk. [33:43.900 --> 33:45.660] And then there's a really cool technique [33:45.660 --> 33:47.160] called address sorting. [33:47.640 --> 33:49.760] One of the authors of this open [33:49.760 --> 33:51.760] source project realized that all the [33:51.760 --> 33:54.500] system calls are put in order alphabetically. [33:54.500 --> 33:55.740] So if you just read [33:55.740 --> 33:57.840] the addresses of where they all are, [33:57.840 --> 33:59.420] it's kind of the same idea. You [34:00.120 --> 34:01.660] alphabetically sort them. [34:01.740 --> 34:03.440] If they're the one that you're trying to use as [34:03.440 --> 34:05.460] hooked, you just look at the one before it and you [34:05.460 --> 34:07.440] add one and now you know the index that [34:07.440 --> 34:09.360] you need. And then even dealing [34:09.360 --> 34:11.340] with all of that previously was kind of [34:11.340 --> 34:13.320] difficult. There's a lot of assembly, a lot of low [34:13.320 --> 34:15.380] level C code. So there's this really [34:15.380 --> 34:17.600] nice project called Sys Whisperers 2. [34:17.600 --> 34:19.400] And the 2 is important because the first version [34:19.400 --> 34:21.280] was not very good, but the second [34:21.280 --> 34:23.400] version is very powerful. [34:23.420 --> 34:25.640] This integrates with Visual Studio. [34:25.640 --> 34:27.400] You call directly through this and [34:27.400 --> 34:29.260] it does all the nasty work in the background [34:29.260 --> 34:31.440] for you to dynamically resolve [34:31.440 --> 34:33.420] those system call indexes. So if you [34:33.420 --> 34:35.720] want to write code that bypasses EDRs, [34:35.720 --> 34:37.520] you want to be able to make whatever system [34:37.520 --> 34:39.440] call you want without being detected, [34:39.440 --> 34:41.440] all you have to do is import the Sys [34:41.440 --> 34:43.380] Whispers 2 into your Visual Studio [34:43.380 --> 34:45.300] project, write your malware freely [34:45.300 --> 34:47.380] and it does all the hard work in the [34:47.380 --> 34:49.540] background for you. So with [34:49.540 --> 34:51.340] all these different techniques that [34:51.340 --> 34:53.600] make EDRs blind to what's happening, [34:53.600 --> 34:55.660] we wanted to be able to detect this. [34:55.660 --> 34:57.580] So we kind of already knew this before going [34:57.580 --> 34:59.880] into it, but we did a large sweep [34:59.880 --> 35:01.700] across all of our Windows [35:01.700 --> 35:03.700] memory samples and for every [35:03.700 --> 35:05.360] version of Windows going back to XP [35:05.360 --> 35:07.560] through the latest Windows 11, there's [35:07.560 --> 35:09.400] only 3 DLLs that legitimately [35:09.400 --> 35:11.380] implement system calls. There's the [35:11.380 --> 35:13.380] NTDLL that I talked about, [35:13.380 --> 35:15.340] Wow64 for 32-bit processes [35:15.340 --> 35:17.500] and then Win32 is for [35:17.500 --> 35:19.540] the GUI, so what you're seeing here on the screen [35:19.540 --> 35:22.080] with Explorer and PowerPoint. [35:22.260 --> 35:23.640] So the idea is [35:23.640 --> 35:25.800] through memory forensics, if we find [35:25.800 --> 35:27.820] the instructions needed to make [35:28.020 --> 35:29.640] a system call instruction and set the [35:29.640 --> 35:31.820] parameters and it's not in one of those [35:31.820 --> 35:33.540] 3 DLLs, this is malware [35:33.540 --> 35:35.700] trying to bypass the system. [35:37.400 --> 35:38.020] And then [35:38.020 --> 35:39.560] like I mentioned, it's some very, very [35:39.560 --> 35:41.640] cool low-level work. I threw this [35:41.640 --> 35:43.660] screenshot in literally last [35:43.660 --> 35:45.600] second, like right before I sent these slides to [35:45.600 --> 35:47.860] DEF CON, because [35:47.860 --> 35:49.620] there was a talk by a security vendor [35:49.620 --> 35:51.740] as I was making the slides, right as I [35:51.740 --> 35:53.600] was about to upload it and I took this screenshot [35:53.600 --> 35:55.640] and threw it in last second, because it was talking [35:55.640 --> 35:57.580] about malware that was just used recently [35:57.580 --> 35:59.880] in the last 1 or 2 months in real attacks [35:59.880 --> 36:01.620] and it, the malware was called [36:01.620 --> 36:03.860] Dodgebox and it's talking about how [36:03.860 --> 36:05.880] in every phase of the malware, every component [36:05.880 --> 36:07.800] the malware had, it did call [36:07.800 --> 36:10.000] stack spoofing, so bypassing [36:10.000 --> 36:11.900] the EDRs to make it appear [36:11.900 --> 36:13.780] where those system calls, so it's doing [36:13.780 --> 36:15.820] direct system calls, making it appear [36:15.820 --> 36:17.720] where it came from the trusted binary, so [36:17.720 --> 36:19.780] the ones we saw in the last slide, instead [36:19.780 --> 36:21.740] of the malware itself. And so it's this [36:21.740 --> 36:23.820] constant back and forth between EDRs [36:23.820 --> 36:25.720] and malware, trying to figure out that [36:25.720 --> 36:27.780] system calls are being made from the wrong spot [36:27.780 --> 36:29.740] but quite honestly the EDRs are in [36:29.860 --> 36:31.540] a tough spot and usually the malware [36:31.540 --> 36:33.680] wins. We don't have [36:33.680 --> 36:35.680] these problems with memory forensics, we don't have [36:35.680 --> 36:37.720] to detect the system call the second [36:37.720 --> 36:39.760] it's made, we're trying to find proof [36:39.760 --> 36:41.680] of code that can do that or does that [36:41.680 --> 36:43.800] through memory forensics, and so what [36:43.800 --> 36:45.740] we did is we wrote, we used [36:45.740 --> 36:47.900] Capstone, which is a very flexible [36:47.900 --> 36:50.040] disassembly library, has Python [36:50.040 --> 36:52.100] support so you can use it directly in volatility [36:52.100 --> 36:53.940] and what we do is look [36:53.940 --> 36:55.720] for blocks of code, so block [36:55.720 --> 36:57.520] code pattern blocks where [36:58.100 --> 37:00.040] EAX gets updated, that's your [37:00.040 --> 37:01.940] system call index, where R10 gets [37:01.940 --> 37:03.960] updated, where one of the system call [37:03.960 --> 37:06.480] instruction happens and where there's a return. [37:06.500 --> 37:07.920] We did a bunch of work so that [37:07.920 --> 37:09.920] simple things like Tataris gate with this [37:09.920 --> 37:12.240] noops wouldn't bypass our code, [37:12.240 --> 37:14.060] we're not doing pattern matching, we're doing [37:14.060 --> 37:15.980] actual automated static disassembly [37:15.980 --> 37:18.200] and when we tested this on [37:18.200 --> 37:20.200] every implementation that we had [37:20.200 --> 37:22.260] of this technique, our new plug-in [37:22.260 --> 37:24.340] direct system calls detected it. [37:24.340 --> 37:26.180] In this case, just to make it fit on a slide [37:26.180 --> 37:28.320] nicer, this is Hell's Descent [37:28.320 --> 37:30.280] from Hell's Gate, so this is where it's [37:30.280 --> 37:32.120] calling the system call instruction [37:32.120 --> 37:34.220] on its own, and then the plug-in [37:34.220 --> 37:36.060] saying, hey, inside of this process, [37:36.060 --> 37:38.180] executable with this PID, and it shows [37:38.180 --> 37:40.160] you right in memory where that system call [37:40.160 --> 37:42.180] handler is. So it's as simple as [37:42.180 --> 37:44.020] running this plug-in across your [37:44.020 --> 37:46.140] potentially infected samples, and it tells you [37:46.140 --> 37:48.260] right where the malware is. [37:49.620 --> 37:50.200] And then [37:50.200 --> 37:52.540] with the indirect system calls, [37:52.540 --> 37:54.160] the idea is, instead of having [37:54.160 --> 37:56.020] that code pattern where you're making [37:56.020 --> 37:58.240] syscall or int2e directly from [37:58.240 --> 38:00.400] your malware code or your shell code, [38:00.400 --> 38:02.020] which, again, you have to do a bunch of call [38:02.020 --> 38:04.060] stack spoofing and things, or the EDRs will [38:04.060 --> 38:06.100] see you, the idea is [38:06.100 --> 38:08.180] you find the address of the [38:08.180 --> 38:10.660] syscall instruction in ntdll, [38:10.660 --> 38:12.120] but instead of calling the [38:12.120 --> 38:14.160] function of that, you find where [38:14.160 --> 38:16.100] the syscall instruction is, and you jump to [38:16.100 --> 38:18.340] it. So you set the registers yourself, [38:18.340 --> 38:20.060] you do all the prereqs yourself, [38:20.060 --> 38:22.160] you jump to the syscall instruction, it looks [38:22.160 --> 38:24.380] like it's coming from ntdll, [38:24.380 --> 38:26.060] and then depending on which EDR you [38:26.060 --> 38:28.020] have, that EDR is going to think it's [38:28.020 --> 38:29.980] the real system call, and then you've [38:29.980 --> 38:31.140] bypassed it. [38:31.900 --> 38:33.540] So we wanted to be able to [38:34.100 --> 38:36.160] detect that as well, and something [38:36.160 --> 38:38.060] that also gets used with this technique [38:38.060 --> 38:40.140] are the exception handlers and the debug [38:40.140 --> 38:42.120] registers, which is the last thing we [38:42.120 --> 38:44.220] cover in this talk. So the idea is [38:44.220 --> 38:46.140] debug registers have been abused forever [38:46.140 --> 38:48.080] by malware, there was a frack article in [38:48.080 --> 38:50.180] 2008 that's the first, considered [38:50.180 --> 38:52.480] the first public documentation of it, [38:52.480 --> 38:54.120] and the idea is by [38:54.120 --> 38:56.160] abusing debug registers, you can [38:56.160 --> 38:58.100] get your exception handler called [38:58.100 --> 39:00.080] at any point in time, and then [39:00.080 --> 39:02.080] from your exception handler, you're going to [39:02.080 --> 39:04.280] make the system call instruction, and [39:05.040 --> 39:06.200] EDRs do not follow [39:06.200 --> 39:08.040] this well as, at all. They don't expect [39:08.040 --> 39:10.040] malware to be running inside of exception [39:10.040 --> 39:12.080] handlers. So a cool [39:12.080 --> 39:14.020] open source project for this, if you want to see it [39:14.020 --> 39:16.060] yourself, is called MutationGate, it is [39:16.060 --> 39:18.160] on GitHub, and you can see [39:18.160 --> 39:20.340] what it's doing, it's adding a vectored [39:20.340 --> 39:22.040] exception handler, [39:22.040 --> 39:23.960] so it's saying it wants to handle exceptions [39:23.960 --> 39:26.220] in its process, this is the function [39:26.220 --> 39:27.980] that's going to be called, and then [39:27.980 --> 39:29.820] on its own, it sets a breakpoint [39:29.820 --> 39:31.940] at this innocuous system call, [39:32.460 --> 39:34.100] NTDrawText, that has nothing to do [39:34.100 --> 39:36.120] with code injection or malware, [39:36.120 --> 39:38.360] so the idea is, this malware, [39:38.360 --> 39:40.000] this code injection, uh, this EDR [39:40.000 --> 39:42.080] bypass technique, will get called [39:42.080 --> 39:44.120] whenever a breakpoint is set, and then [39:44.120 --> 39:46.240] it explicitly sets a breakpoint on [39:46.240 --> 39:48.300] where the system call instruction [39:48.300 --> 39:50.880] is inside of this innocuous function. [39:51.280 --> 39:52.180] So then, in [39:52.180 --> 39:54.120] the implementation of it, what it does, [39:54.120 --> 39:56.160] is every time the malware wants to make [39:56.260 --> 39:58.220] a malicious system call, it just calls [39:58.220 --> 40:00.040] NTDrawText, which again, [40:00.040 --> 40:02.060] you can't do anything malicious with that, [40:02.060 --> 40:04.580] and then the malware, the MutationGate, [40:04.580 --> 40:06.700] it updates RAX right before [40:06.700 --> 40:08.520] the system call instruction to be [40:08.520 --> 40:10.560] the real system call. So your EDR [40:10.560 --> 40:12.520] is going to think, hey, this malicious code's [40:12.520 --> 40:14.540] calling DrawText, it's going to write something on [40:14.540 --> 40:16.540] the screen, but in reality, it's [40:16.540 --> 40:18.860] all the prereqs you need for code injection. [40:20.500 --> 40:22.660] So we wanted to detect this, we didn't [40:22.660 --> 40:24.600] even have to do any major reversing [40:24.600 --> 40:26.520] for this, there was two very nice [40:26.520 --> 40:28.600] blog posts on the topic that we have referenced [40:28.600 --> 40:30.620] here, and the only downside [40:30.620 --> 40:32.340] to this is legitimate software [40:32.340 --> 40:34.620] uses uh, exception handlers, [40:34.620 --> 40:36.280] you don't want your software [40:36.280 --> 40:38.260] having an unhandled exception and then like [40:38.260 --> 40:40.320] crashing the machine, so by having [40:40.320 --> 40:42.320] an exception handler, you make it where [40:42.320 --> 40:44.160] your code gets to handle the exception [40:44.160 --> 40:46.340] and then you can cleanly exit. [40:46.360 --> 40:48.380] So what we did is we, instead [40:48.380 --> 40:50.440] of just listing them all out like some plugins [40:50.440 --> 40:52.300] do, we applied very [40:52.300 --> 40:54.400] similar static disassembly to [40:54.400 --> 40:56.340] the function handlers, we looked [40:56.340 --> 40:58.380] at all the malicious techniques, we saw which [40:58.380 --> 41:00.440] registers they interacted with, which per- [41:00.440 --> 41:02.560] which actions they performed, and so [41:02.560 --> 41:04.480] instead of just listing out every vector [41:04.480 --> 41:06.480] exception handler, we apply [41:06.480 --> 41:08.560] the static disassembly, and then we only list [41:08.560 --> 41:10.440] out the malicious ones. And as [41:10.440 --> 41:12.380] you can see here, with our new plugin, [41:12.380 --> 41:14.440] we're catching mutation gate generically [41:14.440 --> 41:16.740] right away, because of how it interacts [41:16.740 --> 41:17.600] with it. [41:18.280 --> 41:20.260] There was also a cool project by [41:21.200 --> 41:22.320] Marcus Hutchins, where [41:22.320 --> 41:24.480] he wanted to bypass EDRs in the [41:24.480 --> 41:26.860] same way, instead of the [41:26.860 --> 41:28.460] vector exception handler, he [41:28.460 --> 41:30.020] used the higher level one, the [41:30.840 --> 41:32.660] unhandled exception filter. [41:32.660 --> 41:34.380] In this case, this is going to be the [41:34.380 --> 41:36.580] address of where he has his exception [41:36.580 --> 41:38.440] handler called, and then he's [41:38.440 --> 41:40.400] calling setThreadContext on what's an [41:40.400 --> 41:42.400] invalid address. So this is going [41:42.400 --> 41:44.500] to trigger the exception handler. [41:44.860 --> 41:46.860] So what we did here was very similar. [41:46.860 --> 41:49.160] We enumerate all the handlers, [41:49.160 --> 41:50.420] and then we make it- [41:50.420 --> 41:52.300] this keeps jumping a lot. We [41:52.300 --> 41:54.620] enumerate all the handlers, we apply our static [41:54.620 --> 41:56.480] disassembly, and then in this case [41:56.480 --> 41:58.320] we find his malicious process [41:58.320 --> 42:00.700] generically, because the exception [42:00.700 --> 42:02.480] handler is doing things that you would need [42:02.480 --> 42:04.260] to bypass an EDR. [42:04.800 --> 42:06.540] And then with the debug registers, the last [42:06.540 --> 42:08.500] thing we really show here, if [42:08.500 --> 42:10.500] you're familiar with AMSI bypasses, [42:10.500 --> 42:12.400] one of the things you need to do is, [42:12.400 --> 42:14.480] one of the functions you're probably going to tamper with [42:14.480 --> 42:16.580] is the scanBuffer1. In this [42:16.580 --> 42:18.420] case, they set a breakpoint on it, [42:18.420 --> 42:20.620] and they make it where that function doesn't [42:20.620 --> 42:22.760] get- anytime that function returns, [42:22.760 --> 42:24.580] it returns that the code is okay. [42:24.580 --> 42:26.480] So you can send whatever malicious PowerShell [42:26.480 --> 42:28.300] you want through, whatever malicious [42:28.300 --> 42:30.300] macros that you have, and [42:30.300 --> 42:32.400] with this code present, all of your [42:32.400 --> 42:34.440] EDRs are forced to say, hey yeah, this is [42:34.440 --> 42:36.200] clean, and then it gets to execute [42:36.200 --> 42:38.340] on the system. And you can see [42:38.340 --> 42:40.360] that here with our new plugin. [42:40.480 --> 42:42.280] So with the vector exception handler, [42:42.280 --> 42:44.280] we're catching it right away. The project [42:44.280 --> 42:46.400] that implements what you're seeing on these slides [42:46.400 --> 42:48.400] is called Patchless AMSI. [42:48.400 --> 42:50.320] So we're not only catching its vector [42:50.320 --> 42:52.380] exception handler, we're also catching [42:52.380 --> 42:53.940] its abuse of the debug registers [42:53.940 --> 42:56.220] so that it can be called whenever [42:56.220 --> 42:58.280] the code is going to get scanned by the [42:58.280 --> 42:59.960] AMSI subsystem. [43:00.380 --> 43:02.460] So the end result of our project is we documented [43:02.460 --> 43:04.380] and went through every single way that [43:04.380 --> 43:06.520] EDRs get bypassed in user land, [43:06.520 --> 43:08.440] and then we wrote a bunch of volatility plugins [43:08.440 --> 43:10.200] to automatically detect it. [43:10.200 --> 43:12.100] Two quick things before I break. [43:12.100 --> 43:14.480] We wrote a 19-page white paper about this. [43:14.480 --> 43:16.460] It should be on the DEF CON website by like now [43:16.460 --> 43:18.400] or tomorrow. Feel free to email me [43:18.400 --> 43:20.260] if not. Also, the slides. [43:20.260 --> 43:22.360] Don't try to take pictures of the next couple slides. [43:22.360 --> 43:24.380] These are all the references that you were seeing [43:24.380 --> 43:26.480] with the numbers at the top of the slides. [43:26.480 --> 43:28.440] We have like 45 references. It was a huge [43:28.440 --> 43:30.340] research effort. The slides are on the [43:30.340 --> 43:32.480] DEF CON website as well, or email me if you can't [43:32.480 --> 43:34.300] find them. But if you really want [43:34.300 --> 43:36.380] to understand in great detail, [43:36.380 --> 43:38.180] read the paper, and then read all the references [43:38.180 --> 43:40.260] as well. And again, thank you for coming [43:40.260 --> 43:41.200] to the talk. [43:42.860 --> 43:45.260] Thank you.