[00:00.000 --> 00:04.940] So thank you so much for coming. I know it's early on a Saturday at DEF CON. I talked to some [00:04.940 --> 00:08.860] people last night. They're like, when are you talking? It's at 11am. I don't get up until 3, [00:08.860 --> 00:15.760] sorry. So I appreciate the effort. Or maybe you're still up. So I want to move pretty [00:15.760 --> 00:19.840] quickly here. I've got a handheld mic. I might walk around a bit. I don't have a lapel mic [00:19.840 --> 00:25.220] because flippers and stuff like that. So we'll see what we do. But I've got a lot of slides and [00:25.220 --> 00:28.900] I want to make sure I get through everything. So I've got a quick agenda that I will start [00:28.900 --> 00:33.920] with. Let me quickly introduce myself for those of you who may not be familiar with who I am or [00:33.920 --> 00:40.200] my work. So my name is Stephen Sims. I've been a vulnerability researcher for going on 20 [00:40.200 --> 00:48.680] years now. I was lucky enough early on to have computers in the house and be able to have [00:48.680 --> 00:54.380] access to video gaming and all the fun things early on and using a hex editor and hacking. All [00:54.380 --> 00:58.020] the things you guys have already done. So let's move on beyond that. I've sold a lot of [00:58.020 --> 01:06.020] exploits over the past couple decades. I corrected myself there. I thought it was over 30 browser [01:06.020 --> 01:11.780] exploits but I didn't want to fib so I went back and counted and it ends up being 29 of them. [01:12.300 --> 01:16.920] Those are mostly used after free and type confusion vulnerabilities. I've always been someone [01:16.920 --> 01:24.900] who sells exploits. I don't typically disclose them publicly or through other programs. I will [01:24.900 --> 01:28.740] talk a little bit about that because obviously there are ethics associated with exploit sales. [01:28.740 --> 01:32.640] So I'll give you my position when we get there. I found a couple kernel vulnerabilities on [01:32.640 --> 01:38.240] Windows 1 RCE which you can get a lot of money for nowadays. Had I known a little bit more when [01:38.240 --> 01:41.720] I sold it, it would have been better. But lots of other vulnerabilities and different [01:41.720 --> 01:44.760] applications and hardware out there over the years have been lucky enough to have a lot of [01:44.760 --> 01:49.600] great relationships and such. I moved to San Francisco early on in the 2000s and lived on [01:49.600 --> 01:53.600] Treasure Island where we used to joke and call it Hacker Island because there were so many [01:53.600 --> 01:58.360] hackers there. People from Burning Man, people from all kinds of different backgrounds. But it [01:58.360 --> 02:02.620] was just a free for all and it was pretty incredible. Lots of people from CDC lived out [02:02.620 --> 02:08.320] there and others and you learn pretty early on to how to properly use a handle and not get [02:08.320 --> 02:13.760] yourself doxed out there. I'm also, like I said, a musician at the Sands Institute on the [02:13.760 --> 02:17.420] Offensive Operations Curriculum Lead and I have a couple courses there on advanced exploit [02:17.420 --> 02:21.560] development. I am one of the co-authors of Grey Hat Hacking, if you've heard of that book [02:21.560 --> 02:25.260] series. We're talking right now about doing a seventh edition so hopefully that comes to [02:25.260 --> 02:30.380] fruition. And then I also run a weekly stream you might have heard of called Off By One [02:30.380 --> 02:35.440] Security where I do my own stream solo and I also have a lot of guests on and I've been lucky [02:35.440 --> 02:40.760] enough to have some really amazing people on and that just makes it all great. I appreciate so [02:40.760 --> 02:44.100] many of you have come up and say thank you for the stream because that means a lot to me and [02:44.100 --> 02:47.280] that's what I do it for is to get back to the community. And if any of you are ever interested [02:47.280 --> 02:52.760] in being a guest, I'd love to hear from you. All right, so quick agenda. We're going to start [02:52.760 --> 02:58.220] off doing a quick history of mitigations. We're not going to cover all of them. There's dozens [02:58.220 --> 03:02.360] and dozens of them so we can't get through them all but we'll touch briefly on them, kind of [03:02.360 --> 03:07.440] show you where we were, where we are today. Microsoft MSRC was generous enough to get me some [03:07.440 --> 03:12.280] really cool cutting edge data that has not been published yet so you'll get to see some [03:12.280 --> 03:16.840] vulnerability information from Microsoft's perspective in relation to RCEs and local [03:16.840 --> 03:22.120] priv and other types of bugs. Then we'll quickly go through payouts. I did a stream last Friday [03:22.120 --> 03:27.700] on nothing but payouts and all the different types of buyers out there and I got a lot of hate [03:27.700 --> 03:32.980] and a lot of love from that one which I expected because again it involves your morals and it's [03:32.980 --> 03:40.120] very ethical considerations to have. We'll quickly look at the role of machine learning and AI in [03:40.120 --> 03:44.060] general in vulnerability research because that's obviously a hot topic as of late and will [03:44.060 --> 03:49.020] continue to be. And then we're going to switch over into being technical because I don't want to [03:49.020 --> 03:54.580] do a talk without being technical and we'll get into looking at one specific mitigation that is [03:54.580 --> 03:59.640] implemented in the Windows kernel. And my main point of wanting to show you that is so that if [03:59.640 --> 04:04.880] you yourself want to understand how a new mitigation works that comes out, if you want to [04:04.880 --> 04:09.360] figure out how to bypass it, how to work around it or other things or how effective it is if [04:09.360 --> 04:14.340] you're a defender, you need to go and debug it. It's really the only way you can learn other [04:14.340 --> 04:18.760] than taking other people's published information. So every time a new mitigation comes out I [04:18.760 --> 04:23.500] love to jump in to debuggers and disassemblers and go and understand it as best I can. And [04:23.500 --> 04:29.740] then we'll do some takeaways. That is the agenda. So the golden years, I'm not one, it's not my [04:29.740 --> 04:33.760] right to say what the golden years of hacking is but I have been doing it long enough and I [04:33.760 --> 04:39.160] remember reading, it was before my time, but I left one smash in the stack for fun and profit [04:39.160 --> 04:44.400] and other papers released around that time, open wall, work that Brad Spengler was doing, so [04:44.400 --> 04:50.360] many other brilliant researchers and when you, when I personally think about what the golden [04:50.360 --> 04:55.360] years is, it's before all these mitigations became really effective. You'll see on a diagram [04:55.360 --> 05:00.220] that I put together coming up in a moment that there are certain years where stuff got real [05:00.220 --> 05:05.220] serious and it's only gotten harder and harder since then. So I would say the golden years of [05:05.220 --> 05:10.620] memory corruption bugs is long over but still possible and those bugs are very valuable now [05:10.620 --> 05:16.800] and you'll see that in a moment. But you see here Windows up at the top and we can go way back [05:16.800 --> 05:22.280] to when trust from escape and wag that was what became Emmet or at least some of the controls [05:22.280 --> 05:26.600] and mitigations there became the enhanced mitigation experience tool kit which of course [05:26.600 --> 05:31.640] now today is exploit guard. But Windows it wasn't until XP service pack 2 where mitigations [05:31.640 --> 05:36.600] were a thing. I remember when that dropped and admins were freaking out because it was over a [05:36.600 --> 05:41.100] gigabyte update and there were a lot of new mitigations published. You can see them listed [05:41.100 --> 05:44.480] there. I'm not going to go through every one of them but notable ones like data execution [05:44.480 --> 05:50.620] prevention, that's huge. And in stack canaries. Linux down below, I was doing some research and [05:50.620 --> 05:55.300] thankfully Brad Spengler pointed me to some great talk from maybe a decade or so ago that [05:55.300 --> 06:02.240] really went through every single mitigation when it came out, the bug classes and gave credit [06:02.240 --> 06:06.960] where credit is due to all the brilliant researchers and that's a really hard thing to do. [06:06.960 --> 06:11.320] There's a lot of confusion when you go out there trying to find out who the original source was [06:11.320 --> 06:17.520] that published a technique for exploitation or some documentation and I try my best to give [06:17.520 --> 06:23.900] that credit. So the information there under Linux all the way back to 1997, I mean people [06:23.900 --> 06:29.820] were thinking about security way back in 1997 especially on the Linux side of the house which [06:29.820 --> 06:36.600] as expected is always first in that realm. But open wall was a big one for that one. Mac OS you [06:36.600 --> 06:41.800] can see was a bit late to the game. ASLR like randomization didn't come out until like 2011. [06:41.900 --> 06:47.040] That's way behind Vista even. So all the operating systems now though are at a pretty good [06:47.040 --> 06:53.420] state. Some notable mitigations, this is not complete by any means. I put this together, [06:53.420 --> 06:57.780] there's always possibilities, there's mistakes. A lot of times mitigations come out like [06:57.780 --> 07:03.040] before the official OS release of that mitigation. You might hear well low fragmentation heap [07:03.040 --> 07:07.920] that was around during XP service pack 2 or 3 but it didn't fully get implemented to replace [07:07.920 --> 07:12.720] the front end heap allocator until Windows Vista. And then they got rid of the look aside list [07:12.720 --> 07:17.100] except for in the kernel. So like a lot of this stuff can be fuzzy. So the arrows going back [07:17.100 --> 07:21.320] that means back ported. A lot of times mitigations come out, some of them get back ported, some [07:21.320 --> 07:25.400] of them don't get back ported. But you can see some other notable ones like Windows 10 [07:25.400 --> 07:30.140] obviously came out, control flow guard was a significant one. Microsoft was pretty proud of [07:30.140 --> 07:34.340] that one and made some pretty bold claims about it. But none of these mitigations by [07:34.340 --> 07:40.100] themselves are a one stop shop. They are complementary to one another. If there's one [07:40.100 --> 07:46.120] weak link in the chain, if one single mitigation is not working properly or if one library is [07:46.120 --> 07:51.480] not compiled to participate in a mitigation, it breaks the whole thing. So it can be [07:51.480 --> 07:56.920] difficult to get all of them there. I usually put up a Venn diagram that shows overlapping [07:56.920 --> 08:01.640] circles where you've got different categories of mitigations like those enforced by the [08:01.640 --> 08:06.700] operating system, those enforced by the compiler, those enforced by a tool kit like exploit [08:06.700 --> 08:11.560] guard or malware bytes or whatever you might be using. And if you get to the merged areas in [08:11.560 --> 08:15.620] the circles, you're taking advantage of multiple categories and that's where things become [08:15.620 --> 08:20.100] much more effective. Because depending on the type of exploit you're using or you're [08:20.100 --> 08:25.460] writing, a mitigation might not even matter. For example, font protection. Like they [08:25.460 --> 08:29.520] introduced font protection because I think it was Dooku or Stuxnet, it was a font based [08:29.520 --> 08:35.100] vulnerability. It was a sign extension bug and it affected the Windows kernel and was a [08:35.100 --> 08:41.800] brilliant exploit. That font mitigation just says you can't use any fonts unless it's in [08:41.920 --> 08:46.740] a system 32 fonts folder. So no third party fonts to come along. But obviously that only [08:46.740 --> 08:52.120] targets a very specific thing. So some of these mitigations don't matter when you're [08:52.120 --> 08:57.540] exploiting things. So this is not something we're going to walk through. It's a pretty ugly [08:57.540 --> 09:02.540] slide but it's something you can take a picture of. All it's showing is that with all of those [09:02.540 --> 09:08.260] mitigations and that was not comprehensive by any means, it's a cat and mouse game where [09:08.260 --> 09:15.020] you've got a mitigation that comes out due to a bug class or an exploit technique. For [09:15.020 --> 09:21.100] example, look at arbitrary code guard or export address table filtering. EAF specifically [09:21.100 --> 09:28.300] targets shell code and how it accesses the exports table inside libraries like kernel 32. So [09:28.300 --> 09:32.800] they target very specific things and it's that cat and mouse game because when a new exploit [09:32.800 --> 09:37.960] technique comes out or a new bug class, a mitigation goes in to try to kill it. And then a [09:37.960 --> 09:42.740] workaround comes out and then they update the mitigation. A perfect example is back in [09:42.740 --> 09:47.720] 2014 and I was just hanging out with Corlan Coder like a week ago in Amsterdam at a hack [09:47.720 --> 09:52.720] fest that we had out there. And he and I have something very in common with each other. [09:52.720 --> 09:57.060] Actually I'll show you in a diagram coming up very soon. It might be the next one. It is the [09:57.060 --> 10:02.760] next one. So this is the last version that Microsoft published outwardly that I've seen [10:02.760 --> 10:07.620] anyway from Matt Miller and other folks at MSRC. And you notice it only goes up to like [10:07.620 --> 10:14.660] 2013 or so. Or 2015, 16. I can't even see it. But what I want you to look at here is, and [10:14.660 --> 10:18.700] unfortunately I don't have a laser pointer on this thing, but look at the gray area to the [10:18.700 --> 10:24.300] right side and see how it's a very wide gap. And then all of a sudden after that it shrinks [10:24.300 --> 10:30.200] down. The reason that happened is because Microsoft in 2014 introduced a couple [10:30.200 --> 10:36.780] mitigations that really killed specific types of bug classes in the browser. Like type [10:36.780 --> 10:42.740] confusion, use after free. I brought up Core Lan Coder because he and I both were writing quite [10:42.920 --> 10:49.240] a few exploits per year against a browser and then all of a sudden in June, July 2014 they [10:49.240 --> 10:54.220] stopped working. The exploits stopped working. Because they put in deferred free, isolated [10:54.220 --> 10:59.460] heaps and then MemGC came shortly after. And I remember even seeing people like Skylines who [10:59.460 --> 11:05.420] was releasing lots of vulnerabilities or selling exploits or disclosing them, saying one [11:05.420 --> 11:09.840] time in a tweet, hey does anybody have a MemGC bypass? I'm literally sitting on a bunch of [11:09.840 --> 11:16.080] edge vulnerabilities that I can't exploit. So that's the job of the OS developers who work [11:16.080 --> 11:22.080] with mitigations is to identify and understand a specific exploit technique or bug class and [11:22.080 --> 11:28.460] try to kill it. Deferred free or MemGC I should say is so effective because it does [11:28.460 --> 11:34.320] validation of references. Microsoft used C++ smart pointers to do dynamic tracking of [11:34.320 --> 11:39.340] objects and reference tracking and the way in which they chose to track references allowed for [11:39.480 --> 11:44.560] a certain type of exploit to be quite possible. So by adding the MemGC control in deferred [11:44.560 --> 11:49.560] free, there's validation going on to make sure that there are no other references to the [11:49.560 --> 11:54.060] object that's about to get freed before giving it back to garbage collector for reuse to get [11:54.060 --> 11:59.700] recycled. And that's why it shrinks down so much. So Microsoft is very kind as I said [11:59.700 --> 12:06.020] before in getting me this diagram and the next one. This one is remote code execution CVEs by [12:06.020 --> 12:11.180] patch year. So you have to imagine that the majority of CVEs that come out are privately [12:11.180 --> 12:15.820] disclosed. Meaning that there is no public exploit code. And that's why there's a lot of [12:15.820 --> 12:22.000] exploit framework vendors out there like Rapid 7 with Metasploit and Core Impact and [12:22.000 --> 12:26.940] Immunity Canvas and Saint. There's all these different frameworks and what they want to be [12:26.940 --> 12:34.280] able to say is we have the most exploits for privately disclosed CVEs. Because if you're a [12:34.280 --> 12:39.180] red team or some other offensive group and you want to be able to break in obviously to [12:39.180 --> 12:46.500] targets, most companies are terrible about patching. So if we can get some really smart [12:46.500 --> 12:51.360] people to do things like patch diffing, identify the delta in the code and weaponize [12:51.360 --> 12:55.760] these end day vulnerabilities, then we're going to have a much more valuable framework [12:55.760 --> 13:00.600] because we're able to allow you to exploit things that no one else can. I would say close to [13:00.600 --> 13:07.940] like 90% of CVEs are privately disclosed. No public exploit code. So that is absolutely a [13:07.940 --> 13:12.800] profitable business to go and write or weaponize end day vulnerabilities. Because again [13:13.160 --> 13:16.800] organizations are terrible about patching. But you can see we're not going to walk through all [13:16.800 --> 13:20.360] the data. I'm going to tweet this afterward and the slides obviously will come out. But this [13:20.360 --> 13:25.160] is great stuff to use internally with your teams and your threat intel folks and SOC and [13:25.160 --> 13:30.420] everyone else to say hey these are some things we should be considering. How effective are [13:30.420 --> 13:34.700] the mitigations? What bug classes are the most popular right now? And this specifically is [13:34.700 --> 13:41.640] for RCE. And you can see the number in the middle. The next one here is overall CVEs by [13:41.640 --> 13:46.900] patch here. So this is not just memory safety or if you go back to that initial slide that I [13:46.900 --> 13:52.040] had up that was all memory corruption for the most part. All of it. And I remember some patch [13:52.040 --> 13:59.360] Tuesdays there would be like 50 patches coming out for Internet Explorer and Edge alone. It [13:59.360 --> 14:03.180] was a serious problem and they had to solve it with these mitigations and did quite an [14:03.180 --> 14:07.400] effective job. But this shows you memory corruption if you look at the left that's the [14:07.400 --> 14:11.740] big green one in the middle and if you look to the left it's getting less and less and [14:11.740 --> 14:16.620] sometimes it gets bigger and smaller but that is happening because obviously secured [14:16.620 --> 14:21.500] code initiatives, introducing rust into the kernel to protect critical components, the [14:21.500 --> 14:26.640] mitigations being very effective, that is what changes the trajectory here. And you can see [14:26.640 --> 14:30.920] things like deserialization and other types of bugs start to pop up and get more popular. [14:30.980 --> 14:35.680] Again, cat and mouse game and we're always trying to find new ways of getting in. So how [14:35.680 --> 14:39.280] mitigations have affected payouts? I'll quickly go through this one because again I want to [14:39.280 --> 14:43.700] make sure I have enough time. And if you want more information on this if you go to the [14:43.700 --> 14:48.240] off by one security channel on YouTube look at last week's stream I spent like two hours [14:48.240 --> 14:53.560] almost talking specifically about this process. But quickly going through there are [14:53.560 --> 14:58.140] different categories of buyers. You can always go to the vendor themselves like Microsoft, [14:58.140 --> 15:02.840] Google, Apple and they will pay you. Some companies have bounties, some don't. But they [15:02.840 --> 15:07.380] typically don't pay as much as third party buyers out there depending on where they sit on [15:07.380 --> 15:12.900] the realm of ethical boundaries. But they'll pay you and it's gotten better. Then you go a [15:12.900 --> 15:17.160] little bit further. Okay, we can go to ZDI, the Zero Day Initiative or go out to CanSecWest and [15:17.160 --> 15:22.000] participate in Pwn2Own or Bug Crowd, HackerOne, iDefense which I don't think are buying [15:22.000 --> 15:26.900] exploits anymore. But those are third parties who do work with the vendor and they get it [15:26.900 --> 15:32.440] patched. The exploit code never goes public. When you sell an exploit it's no longer your [15:32.440 --> 15:36.880] exploit. Typically they don't pay you. The money gets put into an escrow and you have to wait [15:36.880 --> 15:40.660] to get paid because they want to make sure you're not trying to double dip and sell it to [15:40.660 --> 15:45.340] multiple buyers out there until you build up a good trust. So we go out further and I'm not [15:45.340 --> 15:49.040] going to name any names because they get mad, but there are all kinds of different third [15:49.040 --> 15:54.440] party buyers on behalf of different intelligence agencies and governments around the world. [15:54.900 --> 15:59.660] Believe me, I've sat with them many times and they are looking for bugs from you. Now you [15:59.660 --> 16:03.760] typically don't go knock on the front door of the NSA, I don't advise that, but there are [16:03.760 --> 16:09.520] third parties out there and they will pay more than the below ones that we just talked about. [16:09.520 --> 16:14.100] How much? We'll talk about some money here in a moment. You go further than that, there are [16:14.100 --> 16:19.860] these third party companies that are exploit acquisition companies that refer to themselves [16:19.860 --> 16:24.100] as crowd fences, a relatively new one, you heard of Zerodium, I don't think they're buying [16:24.100 --> 16:27.940] anymore, they used to be Voopin. And there's Voln Point, I don't know anything about Voln [16:27.940 --> 16:34.800] Point, but there's some hefty amounts of money that you can make there. Millions, I think up to [16:34.800 --> 16:40.760] 9 million US dollars for an iOS bug. I mean full chain, obviously, it's got to be all the [16:40.760 --> 16:47.240] things. And then you've got kind of the most unethical place you can go, which are random [16:47.240 --> 16:51.100] people. This is where you've got to be really careful because you don't know who you're [16:51.100 --> 16:54.820] selling to and you don't know who they're selling it to. You don't know who the buyer is. [16:55.080 --> 17:00.480] But this could be over Tor, Telegram, people, if you start getting known for selling exploits [17:00.480 --> 17:05.180] or having the skills to find zero days and weaponize them, especially in today's climate [17:05.180 --> 17:09.700] with how hard it is, they will find you. But you've got to be really careful when you're [17:09.700 --> 17:14.240] selling this stuff to protect you and your family and other things. I really, again, [17:14.240 --> 17:17.880] recommend watching that stream if you're interested in that space because I go into some [17:17.880 --> 17:23.820] good detail about that. So examples of how much you get paid for some of this stuff. Now, [17:23.820 --> 17:29.180] this example is one for me personally. I've always sold things. I don't sell to unethical [17:29.180 --> 17:33.500] buyers, though. Personally, that's my choice. Yes, you get paid less, but that's, you know, [17:33.500 --> 17:41.180] your choice. So someone like iDefense or ZDI, back in 2014, before those mitigations I told [17:41.180 --> 17:45.900] you about dropped, you could expect to get $10,000 to $30,000 US dollars for like a USAPTA [17:45.900 --> 17:51.940] free exploit. And back then, you typically didn't need a big chain. Maybe one exploit or [17:51.940 --> 17:56.680] two, like an information disclosure bug to bypass ASLR if you needed it. But if anyone [17:56.680 --> 18:03.500] remembers, and I'm sure some of you do, JRE6, the Java Runtime Environment 6, MSVCR71.DLL. [18:03.500 --> 18:09.480] That made me a lot of money because they didn't add dynamic rebasing to that module. And it [18:09.480 --> 18:13.920] also had all the gadgets you need to get around data execution prevention. So it's a [18:13.920 --> 18:19.580] beautiful thing. So if you found one remote code execution, USAPTA free against the [18:19.580 --> 18:24.120] browser, that's all you needed. There was no sandboxing on Internet Explorer Edge back [18:24.120 --> 18:29.640] then. And so you could expect to get paid that amount. But now it's a lot harder. On the [18:29.640 --> 18:36.480] more unethical side of it, you can expect to get paid 10 to 20 times more. So you can see an [18:36.480 --> 18:41.640] example there from CrowdFence. They say offering up to $400,000. That's straight from the [18:41.640 --> 18:49.360] website. Another example is iOS. Zero click. Apple created something called Blastor to try to [18:49.360 --> 18:55.480] triage text messages coming in to make sure code execution isn't occurring. It's going to be a [18:55.480 --> 19:01.260] lot harder to jailbreak or root that phone because of Blastor. So you got to have like 4 to [19:01.260 --> 19:06.720] 6 zero days chained together at least. And it's not one person out there doing this anymore. [19:06.720 --> 19:12.760] Back in 2014, you and yourself could find enough to get around all the things and get code [19:12.760 --> 19:17.280] execution. But nowadays, especially in the kernel with HVCI and other cutting edge [19:17.280 --> 19:21.700] mitigations you could say, it's hard. The execute primitive is gone. You get read write [19:21.700 --> 19:25.160] opportunities but even that can be challenging with code signing and all kinds of other [19:25.160 --> 19:30.640] things. But that is why the price tag goes up so much. So you can see 2014, I remember [19:30.640 --> 19:35.640] Zerodium was offering up to $2 million, $2.5 million for iOS and Android full chain zero [19:35.640 --> 19:42.480] clicks. Now you can get up to $9 million with VulnPoint and CrowdFence I think I saw. And then [19:42.480 --> 19:47.320] this example here, if you've ever seen Operation Zero, it literally says on the Twitter page, [19:47.320 --> 19:53.080] on their home page, the only Russian backed exploit acquisition program. And it literally [19:53.080 --> 19:59.620] says, we are non-NATO friendly. But $20 million U.S. dollars, you could retire. That's [19:59.620 --> 20:03.560] amazing. But look who you're selling. You are literally doing treason at that point. I'll [20:03.560 --> 20:07.900] stop saying literally. And they will use that to attack your country. So I don't know if you [20:07.900 --> 20:13.160] want to be in that position, but it's an option for you. So we'll jump now into machine [20:13.160 --> 20:19.620] learning for vulnerability research. This one is one that I have a lot of interest in [20:19.620 --> 20:27.820] because it saves you time. You already know, but automation and machine learning, or the [20:27.820 --> 20:33.620] umbrella of AI in general, are things that aren't going away. And we don't want to fight it, we [20:33.620 --> 20:40.400] want to leverage it and use it to complement our skills. If you fight it, you will lose. When [20:41.080 --> 20:47.420] chat GPT was made public, I think it was November or December 2022, shortly after that [20:47.420 --> 20:54.060] spring, I believe, Project Zero started an initiative, of course, to go and see how AI in [20:54.060 --> 20:59.340] general, machine learning, can help with vulnerability research, specifically for memory [20:59.340 --> 21:07.440] corruption bugs. If you remember a long time ago, DARPA, back in like 2016, they had a [21:07.440 --> 21:12.780] challenge. And they paid, I think, 2 or 3 million U.S. dollars to the winning team, and the [21:12.780 --> 21:19.580] challenge was, we want you to write basically machine wars, automated hacking, automated [21:19.580 --> 21:23.100] detection and defense, where the machines are fighting each other, almost like a capture [21:23.100 --> 21:27.940] the flag. And back then there was a lot of universities looking into very basic exploitation [21:27.940 --> 21:33.040] techniques, like stack overflows. That's a pretty easy thing to weaponize. Okay, the buffer [21:33.040 --> 21:38.780] is overrun and you overwrite a return point, that's very basic. So it's not so hard to write [21:39.400 --> 21:45.080] something that will do that for you automatically. But when you're getting into harder bug [21:45.080 --> 21:50.260] classes, I gave a couple examples, like type confusion, those are difficult to find. Static [21:50.260 --> 21:54.620] analysis, dynamic analysis, manual code inspection, it doesn't matter. Those are tough to [21:54.620 --> 22:01.200] find. Because as a developer, you can't possibly get your code into the context or every [22:01.200 --> 22:06.520] possible situation where it might be run. Different libraries, different patch levels, [22:06.520 --> 22:11.360] different things people do to their computers, a developer can't anticipate what that code [22:11.360 --> 22:16.920] might run into in the future. So these vulnerabilities manifest thanks to things like C++. [22:17.420 --> 22:21.420] A lot of people ask, well, why aren't we already on Rust? Why isn't the Windows kernel [22:21.420 --> 22:28.040] rewritten entirely in Rust? I can't answer that 100% but I can give my opinion, which is, [22:28.040 --> 22:39.740] wow, theirs is louder than mine, that's amazing. All right, okay. Cutting me off. So Rust, [22:39.740 --> 22:45.100] remember when H.D. Moore and the Metasploit team, they were on Perl early on? Metasploit came [22:45.100 --> 22:49.980] out in 2003. And at one point they said, we need to get off Perl because the language wasn't [22:49.980 --> 22:53.820] growing at the same pace that they needed it to. And so they were going to choose between [22:54.520 --> 23:00.520] Python and what's the other one? Ruby, right? And they chose Ruby. And I remember talking to [23:00.520 --> 23:04.780] H.D. Moore at DEF CON a long time ago and I believe it was the Ruby developers were willing [23:04.780 --> 23:10.760] to work with that project because it became the largest open source Ruby project to improve [23:10.760 --> 23:15.400] the language to meet the needs of the developers. So the language developers working with the [23:15.820 --> 23:22.760] framework. I imagine it's a similar thing where C++ has been around for a long time. It's very [23:22.760 --> 23:27.860] mature, it's very powerful. So a couple things you get from that. You've got developers with [23:27.860 --> 23:32.900] decades of experience who can't just overnight over to Rust and you've got limitations in the [23:32.900 --> 23:39.120] language that might not allow it to do the things that C++ can do. And yes, Rust is mimicking [23:39.120 --> 23:43.580] like low level behavior with the speed and the power of being able to directly manipulate [23:43.580 --> 23:49.660] processor registers and memory, but unsafe languages tend to be extremely powerful. So [23:50.660 --> 23:54.720] it's those memory corruption bugs, they're difficult to squash and it's not going to be [23:54.720 --> 23:58.520] overnight where we replace everything. But it is slowly happening. I believe the first thing [23:58.520 --> 24:02.860] you saw in the Windows kernel was Win32K.SysDriver. Some implementation of that got put [24:02.860 --> 24:07.260] over to Rust. So anyway, from a high level, because I can't really go into what Google is [24:07.260 --> 24:11.160] doing at Naptime, I read the paper, that's what they called it, was Project Naptime. And I [24:11.160 --> 24:15.160] have been working on a similar thing, but as a single person, so they've got a team of people. [24:15.160 --> 24:19.820] I've also talked to multiple other teams out there who are doing the same thing. And that is, [24:19.820 --> 24:25.680] how do we create agents, different agents that serve different roles, they do different [24:25.680 --> 24:31.540] things. Because just like humans, if you try to give AI in general, and again that's an umbrella [24:31.540 --> 24:37.380] encompassing term for everything underneath it, if you ask a single agent or LLM to do [24:37.820 --> 24:42.200] everything for you, it's not going to do a great job. But if you break it down, just like [24:42.200 --> 24:47.860] humans, don't ask one developer to go rewrite Microsoft Office Suite, that's too much. Break [24:47.860 --> 24:51.500] it down into different groups, different agents and roles, it's going to be a lot more [24:51.500 --> 24:57.580] possible. And the gist of that, they did make some really impressive progress and they're [24:57.580 --> 25:02.680] going to continue working on it of course, but said, as it quotes on the slide, there's still a [25:02.680 --> 25:06.140] long way to go. We're not going to be replaced any time soon because there's so much nuance [25:06.680 --> 25:13.260] that it can't have, like humans can have, the way we think. It'll get better of course. But [25:13.260 --> 25:17.440] going into that a little bit more, this is an example of something called crew AI, if you've [25:17.440 --> 25:22.640] heard of that, there's multiple frameworks out there for such, open source, and it has this [25:22.640 --> 25:26.700] concept of the agents and these roles that things serve. So you can see on the right, we're [25:26.700 --> 25:31.840] saying we want you to be a threat intelligence analyst, this is what your job is. And you feed [25:31.840 --> 25:37.460] it information, it uses rag and other cool technology to ingest all kinds of threat intel [25:37.460 --> 25:43.960] data and other, and then it does a thing. And to put that in like a chain, you've got over on [25:43.960 --> 25:49.680] the left, like an agent that is the threat intel agent, and it's ingesting things like PDF [25:49.680 --> 25:54.500] documents and just threat intel data, everything it can get its hands on. And then the result [25:54.500 --> 25:59.280] of that, the output, like the list of MITRE attack TTPs as an example, because everyone [25:59.280 --> 26:04.320] knows that one, gets fed into two other agents, one's the red team side and one's the blue [26:04.320 --> 26:09.820] team side. One's doing detection engineering and generating Sigma or some kind of other [26:09.820 --> 26:15.360] rules out there, and the red team side is using it for continuous automated red teaming and [26:15.360 --> 26:19.320] pen testing. So they're consuming and ingesting the same data, using it for different [26:19.320 --> 26:23.860] purposes. A lot of companies are getting into this now, a lot of managed socks out there are [26:23.860 --> 26:28.100] doing exactly that. Here's your Yara rules, here's your Sigma rules, whatever, from it. [26:28.880 --> 26:33.200] This is a pretty ugly slide, but it's one that I put together because this is what I'm [26:33.200 --> 26:38.740] working on personally and I have been for some time now. I am not anywhere close to where I [26:38.740 --> 26:43.140] want to be, and if Google's not getting the best results in the world, like meaning it can [26:43.140 --> 26:48.440] replace humans with VR or the other way around, then I'm certainly not going to be able to do [26:48.440 --> 26:53.760] it alone. But I have made some good progress, which is I feed into an LLM all the different [26:53.760 --> 27:00.200] CVEs, all the project zero or other public research out there, all GitHub, anything I can [27:00.200 --> 27:07.720] feed it around exploits and patch diffing, binary diffing and all that data. So one thing I [27:07.720 --> 27:13.520] do a lot is end day vulnerability weaponization. I download on patch Tuesday unless I don't [27:13.520 --> 27:18.340] have time. You get used to looking at this stuff, you look at all the CVEs, you look at the [27:18.340 --> 27:23.540] knowledge base articles, you try to figure out which ones are most likely exploitable. You [27:23.540 --> 27:27.060] probably still wrong, and you learn a lot, so you have to keep telling yourself, because it's [27:27.060 --> 27:31.080] very frustrating when you spend two weeks looking at a patch vulnerability that you realize [27:31.080 --> 27:36.960] you cannot weaponize, because of mitigations or some other factors. Because even if a [27:36.960 --> 27:42.540] mitigation can 100% stop a vulnerability from being exploitable, they're still going to [27:42.540 --> 27:50.540] patch it. Because what if somebody turns a mitigation off? It's a good habit to clean that [27:50.540 --> 27:55.320] stuff up. So when you do a patch diff and you look at the delta of the code, use [27:55.320 --> 28:02.000] something like diaphora or bin diff, and you take a look at the changes at the function or the [28:02.000 --> 28:08.080] code level, you can give that information to the LLM and teach it how and why it's a certain [28:08.080 --> 28:13.000] type of vulnerability. And then the output from that can go into the next agent, which is [28:13.000 --> 28:17.900] really doing the patch diffing for new vulnerabilities that got patched. So it's taking [28:17.900 --> 28:22.680] the patch, it's extracting it, or grabbing it from Winbindex, doing the diffing, and it's [28:22.680 --> 28:28.480] looking at the delta. And it's knowledge of all the prior diffs that it has learned about and [28:28.480 --> 28:33.700] all the information about exploits that are public or private. It's using that to make a good [28:33.700 --> 28:39.400] guess as to what most likely is the vulnerability type. And then we have a corpus [28:39.400 --> 28:44.200] generation agent, which is trying to generate trigger files that you can then feed to [28:44.200 --> 28:48.360] whatever it is and hopefully trigger the vulnerability. And then of course you would have [28:48.360 --> 28:54.120] to go in and see if you can actually weaponize it. So it's automating the process of binary [28:54.120 --> 29:00.300] diffing and trying to find where the bug is and trying to help you generate malformed [29:00.300 --> 29:04.800] documents or whatever you need to send to the target to try and get it to crash. I've got this [29:04.800 --> 29:10.500] working pretty good, it's not great, but it's saving me a ton of time. I would say probably [29:10.500 --> 29:17.500] like 10 to 20 times it's saving me on that research effort, which is pretty damn good for me [29:17.500 --> 29:21.660] anyway. So understanding how mitigations work, we're going to jump into the more technical [29:21.660 --> 29:28.000] part now. There's so many mitigations, so I just chose one random one. And also on my [29:28.000 --> 29:32.380] channel I do a lot of exploit mitigation reversing, if you're interested in that stuff, [29:32.380 --> 29:37.380] there's videos on that. But a lot of these mitigations, especially the more classic ones [29:37.380 --> 29:43.020] that came out with emits and the initial exploit guard, what they do is they will hook [29:43.020 --> 29:47.580] something. So for example, there are things called critical functions on Windows. Critical [29:47.580 --> 29:51.700] function of one type will be any function that can change permissions in memory, like [29:51.700 --> 29:57.060] virtual alloc, virtual protect, heap create, write process memory, those are critical APIs. [29:57.200 --> 30:01.980] So we want to monitor those. So if we understand things about different bug classes out [30:01.980 --> 30:07.160] there and different ways in which people exploit vulnerabilities, then we can hook the [30:07.160 --> 30:12.080] flow of execution and before we allow the function to be called that will in fact change [30:12.080 --> 30:17.380] permissions in memory, we inspect it. And they can do that, you could do that by overwriting [30:17.380 --> 30:21.560] an entry in the imports table, so when it calls that function where it's linked, it'll [30:21.560 --> 30:26.540] actually call your code first, or more likely they're going to hot patch or put a patch in [30:26.540 --> 30:31.420] the very beginning of the function entry point, and it will first jump to another location, [30:31.420 --> 30:35.640] execute some code, typically points into something called payload restrictions dot DLL, [30:35.640 --> 30:40.460] and it evaluates the environment to make sure things look good. I'll give you one simple [30:40.460 --> 30:45.160] example, if you've heard of stack pivoting before, Microsoft had the blue hat challenge, [30:45.160 --> 30:51.360] and that was 2012, that was a long time ago, but they paid over a million dollars U.S. to [30:51.360 --> 30:56.980] the first place winner, and then they had three places, first, second, third, and what they [30:56.980 --> 31:01.700] were looking for is help from the community to stop return oriented programming. And one [31:01.700 --> 31:06.780] of the main things that we would do in use after free exploits on browsers, is we would [31:06.780 --> 31:11.720] pivot the stack pointer out to the heap, because the stack pointer is a register that only is [31:11.720 --> 31:15.360] supposed to point to the current thread stack at the top of it, let's not get into speculative [31:15.360 --> 31:19.580] execution and such, but you know what I mean, and we like the stack pointer because of three [31:19.580 --> 31:24.120] powerful instructions, push, pop, rep. That's the only register that those instructions [31:24.120 --> 31:30.480] exist for. So that power, we want that in other places in memory, so what we would do is use [31:30.480 --> 31:35.140] an exchange gadget and it would exchange or pivot the stack pointer with another register [31:35.140 --> 31:39.320] like the accumulator register. That would make it so the stack pointer points out on the [31:39.320 --> 31:44.340] heap somewhere, where maybe our ROP chain is, our exploit code is. So great, it works. So [31:44.340 --> 31:50.820] anti-ROP, which came out right before Blue Hat, was on Windows 8, all it did was it looked at [31:50.820 --> 31:54.940] something called the thread information block at the stack boundaries, the stack high and [31:54.940 --> 31:59.860] stack low limits, to make sure that the stack pointer points where it's supposed to before [31:59.860 --> 32:05.500] allowing a critical API to be called. Very simple thing and it was very easy to get around, but it [32:05.500 --> 32:10.740] showed you Microsoft was taking return oriented programming seriously. And then after that a [32:10.740 --> 32:16.960] whole suite of mitigations came out, like 6, 7, 8, simulate the execution flow, just many [32:16.960 --> 32:23.340] others. So again, a lot of these hook and then they inspect and you move on. Not all of them [32:23.340 --> 32:27.760] though, some of them are enforced in user LAN, some of them are enforced in the kernel, and [32:27.760 --> 32:34.700] other factors. So let's look at one more closely. So create process, a little C++ program I put [32:34.700 --> 32:41.240] together, lifted code of course too, and all it does is it calls create process. There was a [32:41.240 --> 32:48.220] mitigation that Microsoft came out with called, do not allow child processes. And that was [32:48.220 --> 32:52.900] called the calculator killer, because obviously a lot of times people would use shell code to [32:53.040 --> 32:57.360] pop a calculator to prove that it worked. Well this mitigation would kill that and prevent it [32:57.360 --> 33:02.560] from happening. So a lot of times if you're exploiting like Microsoft Word or a browser or [33:02.560 --> 33:08.320] anything else, you want to create a new process. This mitigation would stop you from being able [33:08.320 --> 33:14.380] to do it. So when I first saw the mitigation, I just assumed that it hooked create process in [33:14.380 --> 33:19.060] user LAN, somewhere around NTDLL or something, it grabbed it, and then payload restrictions [33:19.060 --> 33:23.000] would just inspect it and it would just prevent you from being able to do it. But this one [33:23.000 --> 33:29.200] ended up being a kernel in force protection. So first off, this is the code, you compile it, and [33:29.200 --> 33:44.400] great, simple. When you run it, so I'll make sure this seems to be acting weird here. All right, [33:44.400 --> 33:49.260] there we go. So when you run it, you can see on command line right there, a calculator pops up. [33:49.420 --> 33:53.760] Exciting, right? But that's what it's job was. That's what it was supposed to do, is just pass [33:53.760 --> 33:58.060] in an argument and it executes and creates a process with that argument. Simple. Then I go [33:58.060 --> 34:03.880] into exploit guard, that's a little snippet on the top right, and I turn that specific [34:03.880 --> 34:08.400] mitigation on. You can see there's audit mode and then there's enabled mode, and I just [34:08.400 --> 34:12.440] enabled it. And then when we try to run it, you can see the command prompt in the middle, it [34:12.440 --> 34:17.700] said create process failed. Okay, the mitigation is working. Down at the bottom, you can see [34:17.700 --> 34:22.520] that as a defender, you want to watch these things. So here's one thing, I'll take a step [34:22.520 --> 34:27.320] back. A lot of administrators are afraid to turn on these mitigations, the ones that aren't [34:27.320 --> 34:32.300] turned on by default by Microsoft. And Microsoft's kind of in a catch-22 situation because if [34:32.300 --> 34:36.000] they turn all the mitigations on that are available, they might break your applications. [34:36.040 --> 34:40.360] Because some of your developers have to adhere to the way in which these mitigations work. [34:40.360 --> 34:44.180] But if they don't turn them on, then you're mad at them because they didn't protect you. So [34:44.180 --> 34:48.600] they're kind of in a bad spot. So they wait until things are mature enough. A perfect example [34:48.600 --> 34:53.340] would be shadow stacks. If you've heard of shadow stack, it's a relatively newer mitigation [34:53.340 --> 34:58.900] though not in theory. Early 2000's someone mentioned the idea of that. It creates a copy of [34:58.900 --> 35:07.200] return pointers and it requires at least an Intel Tiger Lake CPU. So obviously not everybody's [35:07.200 --> 35:11.080] running one of the newest processors and they're not just going to turn that on by default. So [35:11.080 --> 35:15.520] they have to wait. So a lot of these, you do have to go on and turn them on. I remember [35:15.520 --> 35:20.100] Microsoft released a paper a long time ago and said the adoption rate for the enhanced [35:20.100 --> 35:26.560] mitigation experience tool kit, Emmet, was under 5%. So under 5% of organizations were [35:26.560 --> 35:32.160] actually using Emmet in any way shape or form. Because the admins maybe don't understand how [35:32.160 --> 35:35.800] the mitigations work at a very technical level and they don't want to do the screen test. [35:35.800 --> 35:40.220] There's also performance hits associated with these mitigations. One nice thing you can do [35:40.220 --> 35:44.500] though is turn on that audit mode. It's almost like an intrusion detection versus intrusion [35:44.500 --> 35:50.420] prevention where it tells you about a potential problem but it doesn't actually block it. So [35:50.420 --> 35:54.620] you've got the power to do that and then you can look in the event logs. There's a specific [35:54.620 --> 35:59.480] event log area for user LAN mitigations and kernel LAN mitigations. And that's what you're [35:59.480 --> 36:04.420] seeing at the bottom there. When I ran that program to execute the calculator, that new log [36:04.420 --> 36:09.300] popped up that said a mitigation was blocking it. That's right there what told me it was [36:09.300 --> 36:15.900] kernel enforced. So looking at the NTOS kernel here, when I set a break point on create [36:15.900 --> 36:21.540] process and let it continue, it went straight into the kernel. So it told me right there, [36:21.540 --> 36:26.320] validated that this is not a kernel, sorry user LAN enforced mitigation. So I went into [36:26.320 --> 36:32.500] hex, I used hex rays obviously and I used wind debug and went in and set some break points on [36:32.500 --> 36:41.020] those functions right there. Like PSP get no child process restricted policy or SC token is no [36:41.020 --> 36:46.180] child process restriction enforced. These are by symbol name because thankfully Microsoft [36:46.180 --> 36:51.180] gives us the symbols, the PDB files. We can go and look for things that look like they might be [36:51.180 --> 36:55.440] associated with the mitigation that we're curious about. So I set the break points on there [36:55.440 --> 37:01.700] and then we run it, it immediately gets hit. But look where it gets hit. It gets hit when I'm [37:01.700 --> 37:08.160] in the command prompt trying to start that C++ wrapper program, the create process program. [37:08.360 --> 37:14.060] Because that's the program we turned exploit guard mitigation on in the settings as you saw [37:14.060 --> 37:20.980] in the last slide. So it makes sense. So we hit a break point on the setting API, the one that [37:20.980 --> 37:25.500] sets the mitigation. Over on the right there, if you're not familiar with the Virgilious [37:25.500 --> 37:30.760] project, it's everybody I know's go to if you're looking at kernel structures. It is a [37:30.760 --> 37:35.720] brilliant resource and every single Windows version, kernel version, every build, every [37:35.720 --> 37:40.080] creator's update, whatever, is tracked there. Because a lot of times when you're doing [37:40.080 --> 37:44.680] things like token stealing in the kernel, you need to make sure that your offsets are [37:44.680 --> 37:49.740] correct. There might be a structure like E process or K process, K thread, E thread and you [37:49.740 --> 37:54.160] need to make sure that what you think like AP links at a certain offset is still there [37:54.160 --> 37:57.840] depending on the kernel version. So you can look at these structures, look at the members [37:57.840 --> 38:03.600] and you can update your shellcode accordingly. But either way, I saw an instruction and you [38:03.600 --> 38:09.140] can see in the code in the top middle, in the white area, it says move into racks, GS [38:09.140 --> 38:15.020] segment register, offset 188 hex. So the GS register, while under the context of the [38:15.020 --> 38:19.160] kernel, points to a structure called the kernel processor control region, a very large [38:19.160 --> 38:23.940] kernel structure. And nested inside of that is something called KPRCB, the kernel [38:23.940 --> 38:28.320] processor region control block, which is a mega structure. What it's telling us at [38:28.320 --> 38:34.380] offset 8 within that nested structure is what we're dereferencing. It ends up being the [38:34.380 --> 38:40.320] K thread pointer. K thread and E thread and K process and E process are kernel things. If [38:40.320 --> 38:44.940] you've ever heard of the process environment block in user land, the PEB, E process is [38:44.940 --> 38:48.140] like the equivalent in the kernel. If you've ever heard of the TIB, the thread information [38:48.140 --> 38:53.260] block, K thread, E thread, the executive and kernel thread, those are the relative entries [38:53.260 --> 38:57.860] in the kernel. Not 1 to 1, but it's pretty close. So either way, we're dereferencing and [38:57.860 --> 39:04.080] grabbing the K thread pointer for the current thread. So let me go in further and we're [39:04.080 --> 39:09.080] checking out our progress here. You can see that I run this fancy window bug command and [39:09.080 --> 39:12.980] we're basically saying, what is our current process? And it tells us that the current [39:12.980 --> 39:19.280] process is the, uh, which one, command.exe. That's not the process I want to be in. So we [39:19.280 --> 39:23.720] let it continue. We hit the break point again and then we look at the current process and now [39:23.720 --> 39:28.420] we're in the create process C++ program where we want to be. So now we know where we want to [39:28.420 --> 39:31.940] be, where we're at, where we want to be. It's important to mention that because when you set [39:31.940 --> 39:36.760] these types of break points, they will get hit often unless you set process specific break [39:36.760 --> 39:40.680] points as a kernel debugging session. So you want to make sure you understand what context [39:40.680 --> 39:47.020] you're under for each, you know, process. And then we hit our break point on the SC token [39:47.020 --> 39:52.600] set no child process restricted function. So this means that we're under the context of the [39:52.600 --> 39:59.220] create process C++ program and that mitigation function has just been called and it says set no [39:59.220 --> 40:05.740] child process restricted. So you go into hex rays and you decompile it and you say, hey, let's [40:05.740 --> 40:09.100] take a look at this function and that's what you're seeing on the right there. I know it's [40:09.100 --> 40:13.460] kind of small, again slides will be released. Put some circles around some variables because [40:13.460 --> 40:17.460] we don't know what those variables are. Thankfully we get symbols from Microsoft. [40:17.460 --> 40:22.300] Thankfully hex rays and IDA pro are brilliant, it's a brilliant disassembler and we get the [40:22.300 --> 40:26.500] function prototype data. As long as you know what the structure is, you can say, hey, I know [40:26.500 --> 40:31.580] this is a token structure because MSDN told me on the left, on the top there. And then once you [40:31.580 --> 40:38.420] do that, you see that it's able to then go in and add all the symbols, define everything that [40:38.420 --> 40:43.580] you want to see. On the right there, I did a stream a while ago on documenting undocumented [40:43.580 --> 40:49.260] structures and it was all about looking at different bit masks in the kernel and E process [40:49.260 --> 40:53.720] and the token structure to understand what the mitigation bits are and to show you kind of how [40:53.720 --> 40:58.900] to do that. This is a reference from Google that shows us that these different bit mask [40:58.900 --> 41:03.660] numbers, you'll see lots of booleans like ands and ors and those are either turning on or [41:03.660 --> 41:08.280] clearing bits in the bit mask so that the mitigation flags are set to the state that they're [41:08.280 --> 41:12.660] supposed to be in. So I went through here and I added a bunch of comments because obviously [41:12.660 --> 41:16.980] it's helpful especially if you're not used to debugging or disassembling and decompiling [41:16.980 --> 41:21.980] kernel structures. But that defines everything that's happening. Basically we're getting a [41:21.980 --> 41:26.740] token or acquiring a lock on the token. We're initializing a variable which ends up being the [41:26.740 --> 41:31.680] token, the current token. And then we're going in and we're checking bits that are set in the [41:31.680 --> 41:37.860] bit mask. And these bit masks bits are things like, is it in audit only mode? Should it be [41:37.860 --> 41:42.920] turned on and enforced? Is the low box token thing associated with it? What setting should I [41:42.920 --> 41:48.300] do? And through the boolean operations it turns on the appropriate bit which then sets the [41:48.300 --> 41:54.000] mitigation on. That is pretty much how that mitigation works and that's why it's being [41:54.000 --> 41:59.440] blocked because the next thing that would have happened had we kept going, the get function [41:59.440 --> 42:03.800] would have gotten called and it would have checked that bit to see if that program has the [42:03.800 --> 42:08.640] authority to spawn a new process. So that's kind of what we learned by going through that and [42:08.640 --> 42:13.120] that's how easy it can be to understand mitigations to see if you can get around them. So from [42:13.120 --> 42:19.200] that you're like, well then can I get around this somehow? Obviously the first thing you want [42:19.200 --> 42:24.440] to do is Google, go to chat GPT or your favorite AI LLM whatever and say, hey can you tell me [42:24.440 --> 42:28.500] about any bypass techniques that may be publicly available? But if there are no publicly [42:28.500 --> 42:32.420] available ones, hey you've got a great opportunity to do some cool research and make it [42:32.420 --> 42:38.440] public if you can find something. Some examples down there towards the bottom, there was a [42:38.440 --> 42:42.420] technique, I forget who discovered it but I put the link there where you can impersonate the [42:42.420 --> 42:46.360] anonymous token to get around the mitigation and spawn a new process. I don't think that [42:46.360 --> 42:51.840] still works but it was an option. You can use WMI like if you're in the context of Microsoft [42:52.820 --> 42:57.780] Office and you can use some cool PowerShell or WMI to get around the mitigation that way. [42:57.780 --> 43:02.000] There's process migration potentially, you can use reflexive DLL loading where you load [43:02.000 --> 43:07.800] from memory, something into memory. That also gets you around other mitigations like CIT, [43:07.800 --> 43:12.880] ones that are preventing you from loading an unsigned DLL from your Windows box. And [43:12.880 --> 43:18.660] again, setting it accordingly, enforcing the protection and getting around it with things [43:18.660 --> 43:21.960] like reflexive DLL. So, there's a bunch of ways we could potentially get around it and [43:21.960 --> 43:26.200] that's why it's so important that you put a bunch of these together. That you're not just [43:26.200 --> 43:30.880] relying on any one mitigation. I remember Microsoft made a pretty bold claim, somebody [43:30.880 --> 43:36.800] there, said CFG, control flow guard, should be a strong enough mitigation that it can [43:36.800 --> 43:42.440] prevent the majority of exploitation techniques where Emmet may not be needed as much. That [43:42.440 --> 43:46.080] ends up not being entirely true because CFG is another one you could potentially get [43:46.080 --> 43:53.780] around. People have demonstrated that even with V8 on Chrome. So, this right here, I just [43:53.780 --> 43:59.360] wanted to point it out. There are two fields and rest in peace to Jeff Chappelle, brilliant [43:59.360 --> 44:03.560] individual who passed away recently, sadly. But he maintained this site and I hope it [44:03.560 --> 44:09.260] stays up forever because every time Microsoft would make a structural change or add a new [44:09.260 --> 44:13.360] mitigation, like if you can see the ones towards the bottom on the right, mitigation flags [44:13.360 --> 44:18.180] too, you see things like control flow enforcement technology and shadow stacks. Those are [44:18.180 --> 44:23.600] relatively new mitigations. And these are bit masks that are set as a member of the [44:23.800 --> 44:28.180] e-process structure. And those are the things that are being checked. That's why a lot of [44:28.180 --> 44:31.780] times you might hear people getting around SMEP, like supervisor mode execution [44:31.780 --> 44:36.980] prevention, by setting a bit or flipping a bit inside a control register while under a [44:36.980 --> 44:42.120] certain context. Getting around patch guard by doing it fast and doing a race condition. So, [44:42.120 --> 44:46.680] the more you understand from an offensive perspective about these mitigations, the more [44:46.680 --> 44:50.520] you'll be able to get around them potentially or know when to call it a day. For me, it's [44:50.520 --> 44:55.120] all about saving time. If I know a mitigation is likely on and I'm doing a patch dip or [44:55.120 --> 44:59.500] find a zero day and I think it's not going to be fruitful for me to continue down that path, [44:59.500 --> 45:03.920] you got to pay your dues though. You will have those harsh, frustrating days. I still have [45:03.920 --> 45:09.460] them all the time. From a defensive perspective, it really helps you to understand how these [45:09.460 --> 45:13.800] mitigations work so that if you don't want to turn all of them on, you know which ones are [45:13.800 --> 45:19.560] going to be more beneficial, which ones have less overhead, which ones actually do stop an [45:19.560 --> 45:24.720] exploit technique and which ones are pretty useless. So, some takeaways, I think I went [45:24.720 --> 45:31.140] through some already, but it's a lot of nuance and I think that that gives us power where AI [45:31.140 --> 45:36.360] won't take over our jobs anytime soon because the circumstances in which you will be doing [45:36.360 --> 45:41.840] your research requires something that machine learning just can't do right now. And there's [45:41.840 --> 45:46.180] synergy there as well when working with other researchers. The golden years of binary [45:46.180 --> 45:50.740] exploitation can be behind us, but it's not going away anytime soon. People ask me, they [45:50.740 --> 45:54.140] probably ask you all the time, for how much longer am I going to be able to do this? [45:54.960 --> 45:58.960] As long as it's possible. People are going to keep doing it. It's a lot harder now, but I use [45:58.960 --> 46:03.660] an analogy like Tony Hawk, the skateboarder. What he was doing in the 1990s, there's like an [46:03.660 --> 46:08.000] eight-year-old kid able to do that today. We're just, all this information is out there to get [46:08.000 --> 46:13.380] you up to speed from all the research done in the past, fast, so that you can then go and bring [46:13.380 --> 46:18.220] about novel exploitation techniques and new zero days. And the ethical considerations are [46:18.220 --> 46:23.260] something that you have to understand and think about. There's new acts and new legislation [46:23.260 --> 46:29.860] out there, like Paul Maul and such, that we have to worry about. But as you probably know, the [46:29.860 --> 46:34.000] more you push researchers and say you can't do something, the more likely they're going to go [46:34.000 --> 46:40.300] unethical route and sell it on the dark net and make money that way. So, mitigations are a real [46:40.300 --> 46:45.820] thing. They're hard, but they're not going away and you just have to deal with it. You have to [46:45.820 --> 46:51.640] think about it as if there's always a way around it. And the prize will continue to grow. What [46:51.640 --> 46:58.300] was $10,000 is $500,000 now. So it is worth your time putting months into research. So [46:58.300 --> 47:02.600] references and thanks, there's always more people than I can remember to thank, but lots of [47:02.600 --> 47:06.280] researchers out there in the past. Jeremy Tinder, just a shout out to him for getting me those [47:06.280 --> 47:10.460] Microsoft documents or those updated charts, which is cool. Brad Spangler helped me out with [47:10.460 --> 47:14.420] going over some things, so I'm not going to go through everyone. Harun Mir is the individual I [47:14.420 --> 47:19.900] said that did a talk from 2010 that went through every single mitigation that ever came out. It's [47:20.040 --> 47:24.600] a beautiful document. Definitely check that one out. And a lot of other folks as well. Thanks [47:24.600 --> 47:29.700] to DEF CON for selecting a talk. That is it. I think I'm right on time here. I'm happy to, you [47:29.700 --> 47:32.920] know, chat out in the hall because I know I've got to make way if you have any questions, but [47:32.920 --> 47:35.300] thank you so much for coming to my talk. I really appreciate it.