1 00:00:00,000 --> 00:00:01,740 So thank you so much for coming. 2 00:00:01,740 --> 00:00:04,300 I know it's early on a Saturday at DEF CON. 3 00:00:04,300 --> 00:00:05,700 I talked to some people last night. 4 00:00:05,700 --> 00:00:06,920 They're like, when are you talking? 5 00:00:06,920 --> 00:00:07,740 It's at 11am. 6 00:00:07,740 --> 00:00:09,500 I don't get up until 3, sorry. 7 00:00:09,600 --> 00:00:11,960 So I appreciate the effort. 8 00:00:12,300 --> 00:00:13,660 Or maybe you're still up. 9 00:00:13,840 --> 00:00:16,820 So I want to move pretty quickly here. 10 00:00:16,820 --> 00:00:17,880 I've got a handheld mic. 11 00:00:17,880 --> 00:00:18,900 I might walk around a bit. 12 00:00:18,900 --> 00:00:21,620 I don't have a lapel mic because flippers and stuff like that. 13 00:00:21,620 --> 00:00:23,500 So we'll see what we do. 14 00:00:23,720 --> 00:00:26,760 But I've got a lot of slides and I want to make sure I get through everything. 15 00:00:26,760 --> 00:00:29,220 So I've got a quick agenda that I will start with. 16 00:00:29,220 --> 00:00:34,740 Let me quickly introduce myself for those of you who may not be familiar with who I am or my work. 17 00:00:35,440 --> 00:00:37,000 So my name is Stephen Sims. 18 00:00:37,000 --> 00:00:41,660 I've been a vulnerability researcher for going on 20 years now. 19 00:00:41,900 --> 00:00:54,260 I was lucky enough early on to have computers in the house and be able to have access to video gaming and all the fun things early on and using a hex editor and hacking. 20 00:00:54,260 --> 00:00:55,680 All the things you guys have already done. 21 00:00:55,680 --> 00:00:57,300 So let's move on beyond that. 22 00:00:57,300 --> 00:01:02,600 I've sold a lot of exploits over the past couple decades. 23 00:01:02,600 --> 00:01:04,220 I corrected myself there. 24 00:01:04,220 --> 00:01:11,780 I thought it was over 30 browser exploits but I didn't want to fib so I went back and counted and it ends up being 29 of them. 25 00:01:12,300 --> 00:01:16,020 Those are mostly used after free and type confusion vulnerabilities. 26 00:01:16,020 --> 00:01:18,900 I've always been someone who sells exploits. 27 00:01:18,900 --> 00:01:24,400 I don't typically disclose them publicly or through other programs. 28 00:01:24,420 --> 00:01:28,740 I will talk a little bit about that because obviously there are ethics associated with exploit sales. 29 00:01:28,740 --> 00:01:30,580 So I'll give you my position when we get there. 30 00:01:30,620 --> 00:01:36,780 I found a couple kernel vulnerabilities on Windows 1 RCE which you can get a lot of money for nowadays. 31 00:01:37,160 --> 00:01:39,720 Had I known a little bit more when I sold it, it would have been better. 32 00:01:40,060 --> 00:01:46,240 But lots of other vulnerabilities and different applications and hardware out there over the years have been lucky enough to have a lot of great relationships and such. 33 00:01:46,240 --> 00:01:54,480 I moved to San Francisco early on in the 2000s and lived on Treasure Island where we used to joke and call it Hacker Island because there were so many hackers there. 34 00:01:54,480 --> 00:01:57,540 People from Burning Man, people from all kinds of different backgrounds. 35 00:01:57,780 --> 00:02:00,900 But it was just a free for all and it was pretty incredible. 36 00:02:00,900 --> 00:02:10,060 Lots of people from CDC lived out there and others and you learn pretty early on to how to properly use a handle and not get yourself doxed out there. 37 00:02:10,520 --> 00:02:18,300 I'm also, like I said, a musician at the Sands Institute on the Offensive Operations Curriculum Lead and I have a couple courses there on advanced exploit development. 38 00:02:18,720 --> 00:02:22,180 I am one of the co-authors of Grey Hat Hacking, if you've heard of that book series. 39 00:02:22,260 --> 00:02:25,900 We're talking right now about doing a seventh edition so hopefully that comes to fruition. 40 00:02:26,540 --> 00:02:39,820 And then I also run a weekly stream you might have heard of called Off By One Security where I do my own stream solo and I also have a lot of guests on and I've been lucky enough to have some really amazing people on and that just makes it all great. 41 00:02:39,820 --> 00:02:46,160 I appreciate so many of you have come up and say thank you for the stream because that means a lot to me and that's what I do it for is to get back to the community. 42 00:02:46,320 --> 00:02:50,300 And if any of you are ever interested in being a guest, I'd love to hear from you. 43 00:02:50,940 --> 00:02:52,320 All right, so quick agenda. 44 00:02:52,320 --> 00:02:56,360 We're going to start off doing a quick history of mitigations. 45 00:02:56,360 --> 00:02:57,540 We're not going to cover all of them. 46 00:02:57,540 --> 00:03:04,380 There's dozens and dozens of them so we can't get through them all but we'll touch briefly on them, kind of show you where we were, where we are today. 47 00:03:04,760 --> 00:03:18,840 Microsoft MSRC was generous enough to get me some really cool cutting edge data that has not been published yet so you'll get to see some vulnerability information from Microsoft's perspective in relation to RCEs and local priv and other types of bugs. 48 00:03:19,020 --> 00:03:20,620 Then we'll quickly go through payouts. 49 00:03:20,620 --> 00:03:36,520 I did a stream last Friday on nothing but payouts and all the different types of buyers out there and I got a lot of hate and a lot of love from that one which I expected because again it involves your morals and it's very ethical considerations to have. 50 00:03:37,100 --> 00:03:45,120 We'll quickly look at the role of machine learning and AI in general in vulnerability research because that's obviously a hot topic as of late and will continue to be. 51 00:03:45,400 --> 00:03:56,340 And then we're going to switch over into being technical because I don't want to do a talk without being technical and we'll get into looking at one specific mitigation that is implemented in the Windows kernel. 52 00:03:56,480 --> 00:04:10,480 And my main point of wanting to show you that is so that if you yourself want to understand how a new mitigation works that comes out, if you want to figure out how to bypass it, how to work around it or other things or how effective it is if you're a defender, 53 00:04:10,480 --> 00:04:12,680 you need to go and debug it. 54 00:04:12,680 --> 00:04:16,720 It's really the only way you can learn other than taking other people's published information. 55 00:04:16,720 --> 00:04:23,180 So every time a new mitigation comes out I love to jump in to debuggers and disassemblers and go and understand it as best I can. 56 00:04:23,380 --> 00:04:24,440 And then we'll do some takeaways. 57 00:04:24,440 --> 00:04:25,860 That is the agenda. 58 00:04:26,320 --> 00:04:41,720 So the golden years, I'm not one, it's not my right to say what the golden years of hacking is but I have been doing it long enough and I remember reading, it was before my time, but I left one smash in the stack for fun and profit and other papers released around that time, 59 00:04:41,720 --> 00:04:54,220 open wall, work that Brad Spengler was doing, so many other brilliant researchers and when you, when I personally think about what the golden years is, it's before all these mitigations became really effective. 60 00:04:54,340 --> 00:05:03,760 You'll see on a diagram that I put together coming up in a moment that there are certain years where stuff got real serious and it's only gotten harder and harder since then. 61 00:05:03,760 --> 00:05:12,300 So I would say the golden years of memory corruption bugs is long over but still possible and those bugs are very valuable now and you'll see that in a moment. 62 00:05:13,280 --> 00:05:28,420 But you see here Windows up at the top and we can go way back to when trust from escape and wag that was what became Emmet or at least some of the controls and mitigations there became the enhanced mitigation experience tool kit which of course now today is exploit guard. 63 00:05:28,420 --> 00:05:32,660 But Windows it wasn't until XP service pack 2 where mitigations were a thing. 64 00:05:32,820 --> 00:05:39,820 I remember when that dropped and admins were freaking out because it was over a gigabyte update and there were a lot of new mitigations published. 65 00:05:40,180 --> 00:05:41,100 You can see them listed there. 66 00:05:41,100 --> 00:05:45,380 I'm not going to go through every one of them but notable ones like data execution prevention, that's huge. 67 00:05:45,380 --> 00:05:46,680 And in stack canaries. 68 00:05:46,920 --> 00:06:06,960 Linux down below, I was doing some research and thankfully Brad Spengler pointed me to some great talk from maybe a decade or so ago that really went through every single mitigation when it came out, the bug classes and gave credit where credit is due to all the brilliant researchers and that's a really hard thing to do. 69 00:06:06,960 --> 00:06:18,500 There's a lot of confusion when you go out there trying to find out who the original source was that published a technique for exploitation or some documentation and I try my best to give that credit. 70 00:06:18,800 --> 00:06:32,800 So the information there under Linux all the way back to 1997, I mean people were thinking about security way back in 1997 especially on the Linux side of the house which as expected is always first in that realm. 71 00:06:33,660 --> 00:06:35,740 But open wall was a big one for that one. 72 00:06:35,740 --> 00:06:38,240 Mac OS you can see was a bit late to the game. 73 00:06:38,420 --> 00:06:41,800 ASLR like randomization didn't come out until like 2011. 74 00:06:41,900 --> 00:06:43,660 That's way behind Vista even. 75 00:06:43,820 --> 00:06:47,840 So all the operating systems now though are at a pretty good state. 76 00:06:49,000 --> 00:06:52,400 Some notable mitigations, this is not complete by any means. 77 00:06:52,400 --> 00:06:55,640 I put this together, there's always possibilities, there's mistakes. 78 00:06:55,640 --> 00:07:01,140 A lot of times mitigations come out like before the official OS release of that mitigation. 79 00:07:01,240 --> 00:07:10,880 You might hear well low fragmentation heap that was around during XP service pack 2 or 3 but it didn't fully get implemented to replace the front end heap allocator until Windows Vista. 80 00:07:11,420 --> 00:07:13,740 And then they got rid of the look aside list except for in the kernel. 81 00:07:13,740 --> 00:07:15,840 So like a lot of this stuff can be fuzzy. 82 00:07:15,900 --> 00:07:18,480 So the arrows going back that means back ported. 83 00:07:18,480 --> 00:07:22,920 A lot of times mitigations come out, some of them get back ported, some of them don't get back ported. 84 00:07:23,040 --> 00:07:29,000 But you can see some other notable ones like Windows 10 obviously came out, control flow guard was a significant one. 85 00:07:29,000 --> 00:07:32,740 Microsoft was pretty proud of that one and made some pretty bold claims about it. 86 00:07:32,740 --> 00:07:36,920 But none of these mitigations by themselves are a one stop shop. 87 00:07:36,920 --> 00:07:39,460 They are complementary to one another. 88 00:07:39,460 --> 00:07:50,440 If there's one weak link in the chain, if one single mitigation is not working properly or if one library is not compiled to participate in a mitigation, it breaks the whole thing. 89 00:07:51,000 --> 00:07:53,540 So it can be difficult to get all of them there. 90 00:07:53,540 --> 00:08:09,740 I usually put up a Venn diagram that shows overlapping circles where you've got different categories of mitigations like those enforced by the operating system, those enforced by the compiler, those enforced by a tool kit like exploit guard or malware bytes or whatever you might be using. 91 00:08:09,880 --> 00:08:17,120 And if you get to the merged areas in the circles, you're taking advantage of multiple categories and that's where things become much more effective. 92 00:08:17,420 --> 00:08:22,980 Because depending on the type of exploit you're using or you're writing, a mitigation might not even matter. 93 00:08:22,980 --> 00:08:25,180 For example, font protection. 94 00:08:25,180 --> 00:08:30,240 Like they introduced font protection because I think it was Dooku or Stuxnet, it was a font based vulnerability. 95 00:08:30,240 --> 00:08:36,140 It was a sign extension bug and it affected the Windows kernel and was a brilliant exploit. 96 00:08:37,280 --> 00:08:43,680 That font mitigation just says you can't use any fonts unless it's in a system 32 fonts folder. 97 00:08:43,840 --> 00:08:45,860 So no third party fonts to come along. 98 00:08:45,860 --> 00:08:49,300 But obviously that only targets a very specific thing. 99 00:08:49,420 --> 00:08:53,480 So some of these mitigations don't matter when you're exploiting things. 100 00:08:54,420 --> 00:08:56,900 So this is not something we're going to walk through. 101 00:08:56,900 --> 00:09:00,240 It's a pretty ugly slide but it's something you can take a picture of. 102 00:09:00,280 --> 00:09:14,860 All it's showing is that with all of those mitigations and that was not comprehensive by any means, it's a cat and mouse game where you've got a mitigation that comes out due to a bug class or an exploit technique. 103 00:09:14,880 --> 00:09:19,860 For example, look at arbitrary code guard or export address table filtering. 104 00:09:19,860 --> 00:09:28,000 EAF specifically targets shell code and how it accesses the exports table inside libraries like kernel 32. 105 00:09:28,140 --> 00:09:37,580 So they target very specific things and it's that cat and mouse game because when a new exploit technique comes out or a new bug class, a mitigation goes in to try to kill it. 106 00:09:37,580 --> 00:09:40,820 And then a workaround comes out and then they update the mitigation. 107 00:09:40,900 --> 00:09:49,180 A perfect example is back in 2014 and I was just hanging out with Corlan Coder like a week ago in Amsterdam at a hack fest that we had out there. 108 00:09:49,360 --> 00:09:52,720 And he and I have something very in common with each other. 109 00:09:52,720 --> 00:09:54,700 Actually I'll show you in a diagram coming up very soon. 110 00:09:54,700 --> 00:09:56,020 It might be the next one. 111 00:09:56,380 --> 00:09:57,800 It is the next one. 112 00:09:57,800 --> 00:10:05,740 So this is the last version that Microsoft published outwardly that I've seen anyway from Matt Miller and other folks at MSRC. 113 00:10:05,960 --> 00:10:09,640 And you notice it only goes up to like 2013 or so. 114 00:10:09,640 --> 00:10:10,940 Or 2015, 16. 115 00:10:10,940 --> 00:10:12,100 I can't even see it. 116 00:10:12,260 --> 00:10:21,840 But what I want you to look at here is, and unfortunately I don't have a laser pointer on this thing, but look at the gray area to the right side and see how it's a very wide gap. 117 00:10:22,180 --> 00:10:25,120 And then all of a sudden after that it shrinks down. 118 00:10:25,360 --> 00:10:36,520 The reason that happened is because Microsoft in 2014 introduced a couple mitigations that really killed specific types of bug classes in the browser. 119 00:10:36,520 --> 00:10:38,660 Like type confusion, use after free. 120 00:10:39,080 --> 00:10:50,100 I brought up Core Lan Coder because he and I both were writing quite a few exploits per year against a browser and then all of a sudden in June, July 2014 they stopped working. 121 00:10:50,100 --> 00:10:51,440 The exploits stopped working. 122 00:10:51,440 --> 00:10:57,200 Because they put in deferred free, isolated heaps and then MemGC came shortly after. 123 00:10:57,340 --> 00:11:08,240 And I remember even seeing people like Skylines who was releasing lots of vulnerabilities or selling exploits or disclosing them, saying one time in a tweet, hey does anybody have a MemGC bypass? 124 00:11:08,240 --> 00:11:12,780 I'm literally sitting on a bunch of edge vulnerabilities that I can't exploit. 125 00:11:12,960 --> 00:11:23,560 So that's the job of the OS developers who work with mitigations is to identify and understand a specific exploit technique or bug class and try to kill it. 126 00:11:23,900 --> 00:11:30,400 Deferred free or MemGC I should say is so effective because it does validation of references. 127 00:11:30,400 --> 00:11:41,980 Microsoft used C++ smart pointers to do dynamic tracking of objects and reference tracking and the way in which they chose to track references allowed for a certain type of exploit to be quite possible. 128 00:11:42,060 --> 00:11:54,960 So by adding the MemGC control in deferred free, there's validation going on to make sure that there are no other references to the object that's about to get freed before giving it back to garbage collector for reuse to get recycled. 129 00:11:55,260 --> 00:11:57,380 And that's why it shrinks down so much. 130 00:11:57,480 --> 00:12:02,760 So Microsoft is very kind as I said before in getting me this diagram and the next one. 131 00:12:02,860 --> 00:12:07,380 This one is remote code execution CVEs by patch year. 132 00:12:07,860 --> 00:12:12,220 So you have to imagine that the majority of CVEs that come out are privately disclosed. 133 00:12:12,220 --> 00:12:14,660 Meaning that there is no public exploit code. 134 00:12:14,660 --> 00:12:24,040 And that's why there's a lot of exploit framework vendors out there like Rapid 7 with Metasploit and Core Impact and Immunity Canvas and Saint. 135 00:12:24,040 --> 00:12:33,260 There's all these different frameworks and what they want to be able to say is we have the most exploits for privately disclosed CVEs. 136 00:12:33,260 --> 00:12:41,640 Because if you're a red team or some other offensive group and you want to be able to break in obviously to targets , most companies are terrible about patching. 137 00:12:42,380 --> 00:12:59,440 So if we can get some really smart people to do things like patch diffing, identify the delta in the code and weaponize these end day vulnerabilities, then we're going to have a much more valuable framework because we're able to allow you to exploit things that no one else can. 138 00:12:59,640 --> 00:13:04,120 I would say close to like 90% of CVEs are privately disclosed. 139 00:13:04,120 --> 00:13:05,720 No public exploit code. 140 00:13:05,720 --> 00:13:12,160 So that is absolutely a profitable business to go and write or weaponize end day vulnerabilities. 141 00:13:12,160 --> 00:13:14,780 Because again organizations are terrible about patching. 142 00:13:14,880 --> 00:13:17,280 But you can see we're not going to walk through all the data. 143 00:13:17,280 --> 00:13:20,080 I'm going to tweet this afterward and the slides obviously will come out. 144 00:13:20,080 --> 00:13:29,500 But this is great stuff to use internally with your teams and your threat intel folks and SOC and everyone else to say hey these are some things we should be considering. 145 00:13:29,540 --> 00:13:31,300 How effective are the mitigations? 146 00:13:31,300 --> 00:13:33,740 What bug classes are the most popular right now? 147 00:13:33,780 --> 00:13:35,740 And this specifically is for RCE. 148 00:13:35,740 --> 00:13:38,180 And you can see the number in the middle. 149 00:13:38,400 --> 00:13:42,460 The next one here is overall CVEs by patch here. 150 00:13:42,460 --> 00:13:49,920 So this is not just memory safety or if you go back to that initial slide that I had up that was all memory corruption for the most part. 151 00:13:49,920 --> 00:13:50,860 All of it. 152 00:13:50,900 --> 00:13:59,120 And I remember some patch Tuesdays there would be like 50 patches coming out for Internet Explorer and Edge alone. 153 00:13:59,200 --> 00:14:04,380 It was a serious problem and they had to solve it with these mitigations and did quite an effective job. 154 00:14:04,580 --> 00:14:17,820 But this shows you memory corruption if you look at the left that's the big green one in the middle and if you look to the left it's getting less and less and sometimes it gets bigger and smaller but that is happening because obviously secured code initiatives, 155 00:14:17,820 --> 00:14:25,720 introducing rust into the kernel to protect critical components, the mitigations being very effective, that is what changes the trajectory here. 156 00:14:26,120 --> 00:14:30,920 And you can see things like deserialization and other types of bugs start to pop up and get more popular. 157 00:14:30,980 --> 00:14:34,420 Again, cat and mouse game and we're always trying to find new ways of getting in. 158 00:14:35,120 --> 00:14:37,420 So how mitigations have affected payouts? 159 00:14:37,420 --> 00:14:40,800 I'll quickly go through this one because again I want to make sure I have enough time. 160 00:14:41,220 --> 00:14:51,660 And if you want more information on this if you go to the off by one security channel on YouTube look at last week's stream I spent like two hours almost talking specifically about this process. 161 00:14:51,860 --> 00:14:54,740 But quickly going through there are different categories of buyers. 162 00:14:54,740 --> 00:15:00,340 You can always go to the vendor themselves like Microsoft, Google, Apple and they will pay you. 163 00:15:00,340 --> 00:15:02,580 Some companies have bounties, some don't. 164 00:15:02,580 --> 00:15:09,140 But they typically don't pay as much as third party buyers out there depending on where they sit on the realm of ethical boundaries. 165 00:15:09,440 --> 00:15:11,400 But they'll pay you and it's gotten better. 166 00:15:12,240 --> 00:15:13,420 Then you go a little bit further. 167 00:15:13,420 --> 00:15:23,180 Okay, we can go to ZDI, the Zero Day Initiative or go out to CanSecWest and participate in Pwn2Own or Bug Crowd, HackerOne, iDefense which I don't think are buying exploits anymore. 168 00:15:23,360 --> 00:15:27,500 But those are third parties who do work with the vendor and they get it patched. 169 00:15:27,500 --> 00:15:29,500 The exploit code never goes public. 170 00:15:30,240 --> 00:15:33,160 When you sell an exploit it's no longer your exploit. 171 00:15:33,160 --> 00:15:34,540 Typically they don't pay you. 172 00:15:34,540 --> 00:15:44,020 The money gets put into an escrow and you have to wait to get paid because they want to make sure you're not trying to double dip and sell it to multiple buyers out there until you build up a good trust. 173 00:15:44,140 --> 00:15:54,440 So we go out further and I'm not going to name any names because they get mad, but there are all kinds of different third party buyers on behalf of different intelligence agencies and governments around the world. 174 00:15:54,900 --> 00:15:59,180 Believe me, I've sat with them many times and they are looking for bugs from you. 175 00:15:59,240 --> 00:16:09,520 Now you typically don't go knock on the front door of the NSA, I don't advise that, but there are third parties out there and they will pay more than the below ones that we just talked about. 176 00:16:09,520 --> 00:16:10,440 How much? 177 00:16:10,440 --> 00:16:12,180 We'll talk about some money here in a moment. 178 00:16:12,660 --> 00:16:25,680 You go further than that, there are these third party companies that are exploit acquisition companies that refer to themselves as crowd fences, a relatively new one, you heard of Zerodium, I don't think they're buying anymore, they used to be Voopin. 179 00:16:25,680 --> 00:16:33,760 And there's Voln Point, I don't know anything about Voln Point, but there's some hefty amounts of money that you can make there. 180 00:16:33,820 --> 00:16:38,160 Millions, I think up to 9 million US dollars for an iOS bug. 181 00:16:38,240 --> 00:16:41,440 I mean full chain, obviously, it's got to be all the things. 182 00:16:41,820 --> 00:16:48,140 And then you've got kind of the most unethical place you can go, which are random people. 183 00:16:48,400 --> 00:16:53,360 This is where you've got to be really careful because you don't know who you're selling to and you don't know who they're selling it to. 184 00:16:53,360 --> 00:16:54,820 You don't know who the buyer is. 185 00:16:55,080 --> 00:17:08,140 But this could be over Tor, Telegram, people, if you start getting known for selling exploits or having the skills to find zero days and weaponize them, especially in today's climate with how hard it is, they will find you. 186 00:17:08,140 --> 00:17:13,160 But you've got to be really careful when you're selling this stuff to protect you and your family and other things. 187 00:17:13,160 --> 00:17:19,900 I really, again, recommend watching that stream if you're interested in that space because I go into some good detail about that. 188 00:17:20,140 --> 00:17:23,600 So examples of how much you get paid for some of this stuff. 189 00:17:23,600 --> 00:17:26,340 Now, this example is one for me personally. 190 00:17:26,960 --> 00:17:28,180 I've always sold things. 191 00:17:28,180 --> 00:17:29,980 I don't sell to unethical buyers, though. 192 00:17:29,980 --> 00:17:31,520 Personally, that's my choice. 193 00:17:31,520 --> 00:17:34,440 Yes, you get paid less, but that's, you know, your choice. 194 00:17:34,520 --> 00:17:47,420 So someone like iDefense or ZDI, back in 2014, before those mitigations I told you about dropped, you could expect to get $10,000 to $30,000 US dollars for like a USAPTA free exploit. 195 00:17:47,520 --> 00:17:50,660 And back then, you typically didn't need a big chain. 196 00:17:50,660 --> 00:17:56,220 Maybe one exploit or two, like an information disclosure bug to bypass ASLR if you needed it. 197 00:17:56,220 --> 00:18:03,500 But if anyone remembers, and I'm sure some of you do, JRE6, the Java Runtime Environment 6, MSVCR71.DLL. 198 00:18:03,500 --> 00:18:09,300 That made me a lot of money because they didn't add dynamic rebasing to that module. 199 00:18:09,300 --> 00:18:13,440 And it also had all the gadgets you need to get around data execution prevention. 200 00:18:13,440 --> 00:18:14,560 So it's a beautiful thing. 201 00:18:14,560 --> 00:18:21,420 So if you found one remote code execution, USAPTA free against the browser , that's all you needed. 202 00:18:21,420 --> 00:18:24,860 There was no sandboxing on Internet Explorer Edge back then. 203 00:18:25,000 --> 00:18:27,200 And so you could expect to get paid that amount. 204 00:18:27,200 --> 00:18:28,800 But now it's a lot harder. 205 00:18:29,040 --> 00:18:35,640 On the more unethical side of it, you can expect to get paid 10 to 20 times more. 206 00:18:35,860 --> 00:18:39,220 So you can see an example there from CrowdFence. 207 00:18:39,220 --> 00:18:41,160 They say offering up to $400,000. 208 00:18:41,160 --> 00:18:42,460 That's straight from the website. 209 00:18:43,140 --> 00:18:45,140 Another example is iOS. 210 00:18:45,160 --> 00:18:46,440 Zero click. 211 00:18:46,740 --> 00:18:54,560 Apple created something called Blastor to try to triage text messages coming in to make sure code execution isn't occurring. 212 00:18:54,560 --> 00:18:59,320 It's going to be a lot harder to jailbreak or root that phone because of Blastor. 213 00:18:59,320 --> 00:19:03,700 So you got to have like 4 to 6 zero days chained together at least. 214 00:19:03,700 --> 00:19:06,540 And it's not one person out there doing this anymore. 215 00:19:06,540 --> 00:19:13,280 Back in 2014, you and yourself could find enough to get around all the things and get code execution . 216 00:19:13,280 --> 00:19:19,660 But nowadays, especially in the kernel with HVCI and other cutting edge mitigations you could say, it's hard. 217 00:19:19,660 --> 00:19:21,120 The execute primitive is gone. 218 00:19:21,120 --> 00:19:25,880 You get read write opportunities but even that can be challenging with code signing and all kinds of other things. 219 00:19:25,880 --> 00:19:28,280 But that is why the price tag goes up so much. 220 00:19:28,700 --> 00:19:36,480 So you can see 2014, I remember Zerodium was offering up to $2 million, $2.5 million for iOS and Android full chain zero clicks. 221 00:19:36,760 --> 00:19:42,280 Now you can get up to $9 million with VulnPoint and CrowdFence I think I saw. 222 00:19:42,280 --> 00:19:52,260 And then this example here, if you've ever seen Operation Zero, it literally says on the Twitter page, on their home page, the only Russian backed exploit acquisition program. 223 00:19:52,260 --> 00:19:55,540 And it literally says, we are non-NATO friendly. 224 00:19:56,680 --> 00:19:58,180 But $20 million U.S. 225 00:19:58,180 --> 00:19:59,440 dollars, you could retire. 226 00:19:59,440 --> 00:20:00,500 That's amazing. 227 00:20:00,500 --> 00:20:01,320 But look who you're selling. 228 00:20:01,320 --> 00:20:03,420 You are literally doing treason at that point. 229 00:20:03,420 --> 00:20:04,580 I'll stop saying literally. 230 00:20:04,580 --> 00:20:07,160 And they will use that to attack your country. 231 00:20:07,160 --> 00:20:10,540 So I don't know if you want to be in that position, but it's an option for you. 232 00:20:11,560 --> 00:20:16,320 So we'll jump now into machine learning for vulnerability research. 233 00:20:16,320 --> 00:20:22,860 This one is one that I have a lot of interest in because it saves you time. 234 00:20:23,380 --> 00:20:32,080 You already know, but automation and machine learning, or the umbrella of AI in general, are things that aren't going away. 235 00:20:32,080 --> 00:20:36,840 And we don't want to fight it, we want to leverage it and use it to complement our skills. 236 00:20:36,840 --> 00:20:38,780 If you fight it, you will lose. 237 00:20:39,940 --> 00:21:00,680 When chat GPT was made public, I think it was November or December 2022, shortly after that spring, I believe, Project Zero started an initiative, of course, to go and see how AI in general, machine learning, can help with vulnerability research, specifically for memory corruption bugs. 238 00:21:00,860 --> 00:21:07,920 If you remember a long time ago, DARPA, back in like 2016, they had a challenge . 239 00:21:08,120 --> 00:21:10,540 And they paid, I think, 2 or 3 million U.S. 240 00:21:10,540 --> 00:21:23,900 dollars to the winning team, and the challenge was, we want you to write basically machine wars, automated hacking, automated detection and defense, where the machines are fighting each other, almost like a capture the flag. 241 00:21:23,900 --> 00:21:30,120 And back then there was a lot of universities looking into very basic exploitation techniques, like stack overflows. 242 00:21:30,120 --> 00:21:32,380 That's a pretty easy thing to weaponize. 243 00:21:32,380 --> 00:21:36,780 Okay, the buffer is overrun and you overwrite a return point, that's very basic. 244 00:21:36,940 --> 00:21:41,940 So it's not so hard to write something that will do that for you automatically. 245 00:21:41,940 --> 00:21:49,900 But when you're getting into harder bug classes, I gave a couple examples, like type confusion, those are difficult to find. 246 00:21:49,900 --> 00:21:53,840 Static analysis, dynamic analysis, manual code inspection, it doesn't matter. 247 00:21:53,840 --> 00:21:55,280 Those are tough to find. 248 00:21:55,280 --> 00:22:04,420 Because as a developer, you can't possibly get your code into the context or every possible situation where it might be run. 249 00:22:04,420 --> 00:22:13,100 Different libraries, different patch levels, different things people do to their computers, a developer can't anticipate what that code might run into in the future. 250 00:22:13,140 --> 00:22:16,920 So these vulnerabilities manifest thanks to things like C++. 251 00:22:17,420 --> 00:22:20,360 A lot of people ask, well, why aren't we already on Rust? 252 00:22:20,360 --> 00:22:23,440 Why isn't the Windows kernel rewritten entirely in Rust? 253 00:22:23,700 --> 00:22:32,480 I can't answer that 100% but I can give my opinion, which is, wow, theirs is louder than mine, that's amazing. 254 00:22:32,620 --> 00:22:34,160 All right, okay. 255 00:22:35,700 --> 00:22:36,960 Cutting me off. 256 00:22:36,980 --> 00:22:41,120 So Rust, remember when H.D. 257 00:22:41,120 --> 00:22:44,560 Moore and the Metasploit team, they were on Perl early on? 258 00:22:44,560 --> 00:22:46,460 Metasploit came out in 2003. 259 00:22:46,580 --> 00:22:52,440 And at one point they said, we need to get off Perl because the language wasn't growing at the same pace that they needed it to. 260 00:22:52,580 --> 00:22:57,320 And so they were going to choose between Python and what's the other one? 261 00:22:57,340 --> 00:22:58,240 Ruby, right? 262 00:22:58,240 --> 00:22:59,420 And they chose Ruby. 263 00:22:59,460 --> 00:23:00,840 And I remember talking to H.D. 264 00:23:00,840 --> 00:23:13,340 Moore at DEF CON a long time ago and I believe it was the Ruby developers were willing to work with that project because it became the largest open source Ruby project to improve the language to meet the needs of the developers. 265 00:23:13,420 --> 00:23:16,600 So the language developers working with the framework. 266 00:23:17,180 --> 00:23:22,380 I imagine it's a similar thing where C++ has been around for a long time. 267 00:23:22,380 --> 00:23:24,880 It's very mature, it's very powerful. 268 00:23:24,880 --> 00:23:26,660 So a couple things you get from that. 269 00:23:26,660 --> 00:23:36,600 You've got developers with decades of experience who can't just overnight over to Rust and you've got limitations in the language that might not allow it to do the things that C++ can do. 270 00:23:36,720 --> 00:23:49,320 And yes, Rust is mimicking like low level behavior with the speed and the power of being able to directly manipulate processor registers and memory, but unsafe languages tend to be extremely powerful. 271 00:23:49,640 --> 00:23:56,280 So it's those memory corruption bugs, they're difficult to squash and it's not going to be overnight where we replace everything. 272 00:23:56,280 --> 00:23:57,720 But it is slowly happening. 273 00:23:57,720 --> 00:24:01,360 I believe the first thing you saw in the Windows kernel was Win32K.SysDriver. 274 00:24:01,360 --> 00:24:03,840 Some implementation of that got put over to Rust. 275 00:24:04,360 --> 00:24:10,800 So anyway, from a high level, because I can't really go into what Google is doing at Naptime, I read the paper, that's what they called it, was Project Naptime. 276 00:24:10,880 --> 00:24:15,160 And I have been working on a similar thing, but as a single person, so they've got a team of people. 277 00:24:15,160 --> 00:24:19,080 I've also talked to multiple other teams out there who are doing the same thing. 278 00:24:19,220 --> 00:24:26,100 And that is, how do we create agents, different agents that serve different roles, they do different things. 279 00:24:26,100 --> 00:24:40,800 Because just like humans, if you try to give AI in general, and again that's an umbrella encompassing term for everything underneath it, if you ask a single agent or LLM to do everything for you, it's not going to do a great job. 280 00:24:40,800 --> 00:24:47,560 But if you break it down, just like humans, don't ask one developer to go rewrite Microsoft Office Suite, that's too much. 281 00:24:47,560 --> 00:24:52,320 Break it down into different groups, different agents and roles, it's going to be a lot more possible. 282 00:24:52,700 --> 00:25:03,180 And the gist of that, they did make some really impressive progress and they're going to continue working on it of course, but said, as it quotes on the slide, there's still a long way to go. 283 00:25:03,180 --> 00:25:10,800 We're not going to be replaced any time soon because there's so much nuance that it can't have, like humans can have, the way we think. 284 00:25:10,800 --> 00:25:12,200 It'll get better of course. 285 00:25:13,080 --> 00:25:25,240 But going into that a little bit more, this is an example of something called crew AI, if you've heard of that, there's multiple frameworks out there for such, open source, and it has this concept of the agents and these roles that things serve. 286 00:25:25,240 --> 00:25:30,900 So you can see on the right, we're saying we want you to be a threat intelligence analyst, this is what your job is. 287 00:25:31,080 --> 00:25:40,620 And you feed it information, it uses rag and other cool technology to ingest all kinds of threat intel data and other, and then it does a thing. 288 00:25:40,800 --> 00:25:53,420 And to put that in like a chain, you've got over on the left, like an agent that is the threat intel agent, and it's ingesting things like PDF documents and just threat intel data, everything it can get its hands on. 289 00:25:53,420 --> 00:26:05,280 And then the result of that, the output, like the list of MITRE attack TTPs as an example, because everyone knows that one, gets fed into two other agents, one's the red team side and one's the blue team side. 290 00:26:05,280 --> 00:26:16,360 One's doing detection engineering and generating Sigma or some kind of other rules out there, and the red team side is using it for continuous automated red teaming and pen testing. 291 00:26:16,540 --> 00:26:20,160 So they're consuming and ingesting the same data, using it for different purposes. 292 00:26:20,160 --> 00:26:25,160 A lot of companies are getting into this now, a lot of managed socks out there are doing exactly that. 293 00:26:25,160 --> 00:26:28,100 Here's your Yara rules, here's your Sigma rules, whatever, from it. 294 00:26:28,880 --> 00:26:35,880 This is a pretty ugly slide, but it's one that I put together because this is what I'm working on personally and I have been for some time now. 295 00:26:36,880 --> 00:26:48,980 I am not anywhere close to where I want to be, and if Google's not getting the best results in the world, like meaning it can replace humans with VR or the other way around, then I'm certainly not going to be able to do it alone. 296 00:26:48,980 --> 00:27:06,940 But I have made some good progress, which is I feed into an LLM all the different CVEs, all the project zero or other public research out there, all GitHub, anything I can feed it around exploits and patch diffing, binary diffing and all that data. 297 00:27:07,160 --> 00:27:11,760 So one thing I do a lot is end day vulnerability weaponization. 298 00:27:11,760 --> 00:27:14,440 I download on patch Tuesday unless I don't have time. 299 00:27:14,800 --> 00:27:23,460 You get used to looking at this stuff, you look at all the CVEs, you look at the knowledge base articles, you try to figure out which ones are most likely exploitable. 300 00:27:23,460 --> 00:27:35,340 You probably still wrong, and you learn a lot, so you have to keep telling yourself, because it's very frustrating when you spend two weeks looking at a patch vulnerability that you realize you cannot weaponize, because of mitigations or some other factors. 301 00:27:35,560 --> 00:27:43,300 Because even if a mitigation can 100% stop a vulnerability from being exploitable, they're still going to patch it. 302 00:27:43,780 --> 00:27:46,320 Because what if somebody turns a mitigation off? 303 00:27:46,680 --> 00:27:51,380 It's a good habit to clean that stuff up. 304 00:27:51,560 --> 00:28:09,240 So when you do a patch diff and you look at the delta of the code, use something like diaphora or bin diff, and you take a look at the changes at the function or the code level, you can give that information to the LLM and teach it how and why it's a certain type of vulnerability. 305 00:28:09,340 --> 00:28:17,220 And then the output from that can go into the next agent, which is really doing the patch diffing for new vulnerabilities that got patched. 306 00:28:17,220 --> 00:28:23,740 So it's taking the patch, it's extracting it, or grabbing it from Winbindex, doing the diffing, and it's looking at the delta. 307 00:28:23,740 --> 00:28:32,000 And it's knowledge of all the prior diffs that it has learned about and all the information about exploits that are public or private. 308 00:28:32,000 --> 00:28:37,980 It's using that to make a good guess as to what most likely is the vulnerability type. 309 00:28:37,980 --> 00:28:47,640 And then we have a corpus generation agent, which is trying to generate trigger files that you can then feed to whatever it is and hopefully trigger the vulnerability. 310 00:28:47,640 --> 00:28:50,660 And then of course you would have to go in and see if you can actually weaponize it. 311 00:28:51,020 --> 00:29:04,140 So it's automating the process of binary diffing and trying to find where the bug is and trying to help you generate malformed documents or whatever you need to send to the target to try and get it to crash. 312 00:29:04,200 --> 00:29:09,780 I've got this working pretty good, it's not great, but it's saving me a ton of time. 313 00:29:09,780 --> 00:29:18,220 I would say probably like 10 to 20 times it's saving me on that research effort, which is pretty damn good for me anyway. 314 00:29:19,020 --> 00:29:22,800 So understanding how mitigations work, we're going to jump into the more technical part now. 315 00:29:23,720 --> 00:29:27,200 There's so many mitigations, so I just chose one random one. 316 00:29:27,200 --> 00:29:33,680 And also on my channel I do a lot of exploit mitigation reversing, if you're interested in that stuff, there's videos on that. 317 00:29:33,720 --> 00:29:44,100 But a lot of these mitigations, especially the more classic ones that came out with emits and the initial exploit guard, what they do is they will hook something. 318 00:29:44,100 --> 00:29:47,400 So for example, there are things called critical functions on Windows. 319 00:29:47,400 --> 00:29:57,060 Critical function of one type will be any function that can change permissions in memory, like virtual alloc, virtual protect, heap create, write process memory, those are critical APIs. 320 00:29:57,200 --> 00:29:59,180 So we want to monitor those. 321 00:29:59,240 --> 00:30:13,460 So if we understand things about different bug classes out there and different ways in which people exploit vulnerabilities, then we can hook the flow of execution and before we allow the function to be called that will in fact change permissions in memory, 322 00:30:13,460 --> 00:30:14,920 we inspect it. 323 00:30:14,960 --> 00:30:29,020 And they can do that, you could do that by overwriting an entry in the imports table, so when it calls that function where it's linked, it'll actually call your code first, or more likely they're going to hot patch or put a patch in the very beginning of the function entry point, 324 00:30:29,020 --> 00:30:39,760 and it will first jump to another location, execute some code, typically points into something called payload restrictions dot DLL, and it evaluates the environment to make sure things look good. 325 00:30:39,760 --> 00:30:51,020 I'll give you one simple example, if you've heard of stack pivoting before, Microsoft had the blue hat challenge, and that was 2012, that was a long time ago, but they paid over a million dollars U.S. 326 00:30:51,020 --> 00:31:01,400 to the first place winner, and then they had three places, first, second, third, and what they were looking for is help from the community to stop return oriented programming. 327 00:31:01,400 --> 00:31:14,400 And one of the main things that we would do in use after free exploits on browsers, is we would pivot the stack pointer out to the heap, because the stack pointer is a register that only is supposed to point to the current thread stack at the top of it, 328 00:31:14,400 --> 00:31:22,140 let's not get into speculative execution and such, but you know what I mean, and we like the stack pointer because of three powerful instructions, push, pop, rep. 329 00:31:22,160 --> 00:31:25,240 That's the only register that those instructions exist for. 330 00:31:25,280 --> 00:31:37,160 So that power, we want that in other places in memory, so what we would do is use an exchange gadget and it would exchange or pivot the stack pointer with another register like the accumulator register. 331 00:31:37,180 --> 00:31:43,280 That would make it so the stack pointer points out on the heap somewhere, where maybe our ROP chain is, our exploit code is. 332 00:31:43,280 --> 00:31:44,340 So great, it works. 333 00:31:44,340 --> 00:32:02,320 So anti-ROP, which came out right before Blue Hat, was on Windows 8, all it did was it looked at something called the thread information block at the stack boundaries, the stack high and stack low limits, to make sure that the stack pointer points where it's supposed to before allowing a critical API to be called. 334 00:32:02,320 --> 00:32:09,240 Very simple thing and it was very easy to get around, but it showed you Microsoft was taking return oriented programming seriously. 335 00:32:09,260 --> 00:32:17,440 And then after that a whole suite of mitigations came out, like 6, 7, 8, simulate the execution flow, just many others . 336 00:32:17,740 --> 00:32:22,220 So again, a lot of these hook and then they inspect and you move on. 337 00:32:22,240 --> 00:32:28,500 Not all of them though , some of them are enforced in user LAN, some of them are enforced in the kernel, and other factors. 338 00:32:28,500 --> 00:32:30,960 So let's look at one more closely. 339 00:32:31,760 --> 00:32:40,340 So create process, a little C++ program I put together, lifted code of course too, and all it does is it calls create process. 340 00:32:40,340 --> 00:32:47,120 There was a mitigation that Microsoft came out with called, do not allow child processes. 341 00:32:47,420 --> 00:32:55,040 And that was called the calculator killer, because obviously a lot of times people would use shell code to pop a calculator to prove that it worked. 342 00:32:55,040 --> 00:32:58,280 Well this mitigation would kill that and prevent it from happening. 343 00:32:58,380 --> 00:33:05,400 So a lot of times if you're exploiting like Microsoft Word or a browser or anything else, you want to create a new process. 344 00:33:05,700 --> 00:33:09,220 This mitigation would stop you from being able to do it. 345 00:33:09,220 --> 00:33:22,440 So when I first saw the mitigation, I just assumed that it hooked create process in user LAN, somewhere around NTDLL or something, it grabbed it, and then payload restrictions would just inspect it and it would just prevent you from being able to do it. 346 00:33:22,440 --> 00:33:25,420 But this one ended up being a kernel in force protection. 347 00:33:25,860 --> 00:33:30,520 So first off, this is the code, you compile it, and great, simple. 348 00:33:30,560 --> 00:33:32,960 When you run it, 349 00:33:36,340 --> 00:33:39,980 so I'll make sure this seems to be acting weird here. 350 00:33:44,100 --> 00:33:45,140 All right, there we go. 351 00:33:45,580 --> 00:33:49,260 So when you run it, you can see on command line right there, a calculator pops up. 352 00:33:49,420 --> 00:33:50,340 Exciting, right? 353 00:33:50,340 --> 00:33:52,040 But that's what it's job was. 354 00:33:52,040 --> 00:33:56,780 That's what it was supposed to do, is just pass in an argument and it executes and creates a process with that argument. 355 00:33:56,780 --> 00:33:57,440 Simple. 356 00:33:57,560 --> 00:34:05,140 Then I go into exploit guard, that's a little snippet on the top right, and I turn that specific mitigation on. 357 00:34:05,140 --> 00:34:09,240 You can see there's audit mode and then there's enabled mode, and I just enabled it. 358 00:34:09,440 --> 00:34:14,300 And then when we try to run it, you can see the command prompt in the middle, it said create process failed. 359 00:34:14,420 --> 00:34:16,240 Okay, the mitigation is working. 360 00:34:16,440 --> 00:34:21,200 Down at the bottom, you can see that as a defender, you want to watch these things. 361 00:34:21,200 --> 00:34:23,160 So here's one thing, I'll take a step back. 362 00:34:23,160 --> 00:34:29,180 A lot of administrators are afraid to turn on these mitigations, the ones that aren't turned on by default by Microsoft. 363 00:34:29,540 --> 00:34:36,000 And Microsoft's kind of in a catch-22 situation because if they turn all the mitigations on that are available, they might break your applications. 364 00:34:36,040 --> 00:34:40,360 Because some of your developers have to adhere to the way in which these mitigations work. 365 00:34:40,360 --> 00:34:44,000 But if they don't turn them on, then you're mad at them because they didn't protect you. 366 00:34:44,000 --> 00:34:45,660 So they're kind of in a bad spot. 367 00:34:45,660 --> 00:34:47,820 So they wait until things are mature enough. 368 00:34:47,820 --> 00:34:50,180 A perfect example would be shadow stacks. 369 00:34:50,180 --> 00:34:54,760 If you've heard of shadow stack, it's a relatively newer mitigation though not in theory. 370 00:34:55,000 --> 00:34:57,780 Early 2000's someone mentioned the idea of that. 371 00:34:57,780 --> 00:35:05,460 It creates a copy of return pointers and it requires at least an Intel Tiger Lake CPU. 372 00:35:05,940 --> 00:35:10,920 So obviously not everybody's running one of the newest processors and they're not just going to turn that on by default. 373 00:35:10,920 --> 00:35:12,220 So they have to wait. 374 00:35:12,260 --> 00:35:15,100 So a lot of these, you do have to go on and turn them on. 375 00:35:15,100 --> 00:35:23,800 I remember Microsoft released a paper a long time ago and said the adoption rate for the enhanced mitigation experience tool kit, Emmet, was under 5%. 376 00:35:23,800 --> 00:35:29,240 So under 5% of organizations were actually using Emmet in any way shape or form. 377 00:35:29,240 --> 00:35:35,800 Because the admins maybe don't understand how the mitigations work at a very technical level and they don't want to do the screen test. 378 00:35:35,800 --> 00:35:39,020 There's also performance hits associated with these mitigations. 379 00:35:39,120 --> 00:35:42,080 One nice thing you can do though is turn on that audit mode. 380 00:35:42,080 --> 00:35:50,200 It's almost like an intrusion detection versus intrusion prevention where it tells you about a potential problem but it doesn't actually block it. 381 00:35:50,300 --> 00:35:53,940 So you've got the power to do that and then you can look in the event logs. 382 00:35:53,940 --> 00:35:59,040 There's a specific event log area for user LAN mitigations and kernel LAN mitigations. 383 00:35:59,040 --> 00:36:00,860 And that's what you're seeing at the bottom there. 384 00:36:00,860 --> 00:36:07,720 When I ran that program to execute the calculator, that new log popped up that said a mitigation was blocking it. 385 00:36:07,820 --> 00:36:10,520 That's right there what told me it was kernel enforced. 386 00:36:11,160 --> 00:36:20,480 So looking at the NTOS kernel here, when I set a break point on create process and let it continue, it went straight into the kernel. 387 00:36:20,480 --> 00:36:25,560 So it told me right there, validated that this is not a kernel, sorry user LAN enforced mitigation. 388 00:36:25,780 --> 00:36:34,300 So I went into hex, I used hex rays obviously and I used wind debug and went in and set some break points on those functions right there. 389 00:36:34,300 --> 00:36:43,080 Like PSP get no child process restricted policy or SC token is no child process restriction enforced. 390 00:36:43,080 --> 00:36:48,840 These are by symbol name because thankfully Microsoft gives us the symbols, the PDB files. 391 00:36:48,840 --> 00:36:53,860 We can go and look for things that look like they might be associated with the mitigation that we're curious about. 392 00:36:53,860 --> 00:36:58,480 So I set the break points on there and then we run it, it immediately gets hit. 393 00:36:58,480 --> 00:37:00,000 But look where it gets hit. 394 00:37:00,000 --> 00:37:08,160 It gets hit when I'm in the command prompt trying to start that C++ wrapper program, the create process program. 395 00:37:08,360 --> 00:37:15,180 Because that's the program we turned exploit guard mitigation on in the settings as you saw in the last slide. 396 00:37:15,460 --> 00:37:16,680 So it makes sense. 397 00:37:16,800 --> 00:37:22,820 So we hit a break point on the setting API, the one that sets the mitigation. 398 00:37:23,300 --> 00:37:30,180 Over on the right there, if you're not familiar with the Virgilious project, it's everybody I know's go to if you're looking at kernel structures. 399 00:37:30,260 --> 00:37:38,760 It is a brilliant resource and every single Windows version, kernel version, every build, every creator's update, whatever, is tracked there. 400 00:37:38,760 --> 00:37:45,440 Because a lot of times when you're doing things like token stealing in the kernel, you need to make sure that your offsets are correct. 401 00:37:45,580 --> 00:37:55,900 There might be a structure like E process or K process, K thread, E thread and you need to make sure that what you think like AP links at a certain offset is still there depending on the kernel version. 402 00:37:55,900 --> 00:38:00,240 So you can look at these structures, look at the members and you can update your shellcode accordingly. 403 00:38:00,560 --> 00:38:12,080 But either way, I saw an instruction and you can see in the code in the top middle, in the white area, it says move into racks, GS segment register, offset 188 hex. 404 00:38:12,120 --> 00:38:20,340 So the GS register, while under the context of the kernel, points to a structure called the kernel processor control region, a very large kernel structure. 405 00:38:20,400 --> 00:38:27,040 And nested inside of that is something called KPRCB, the kernel processor region control block, which is a mega structure. 406 00:38:27,280 --> 00:38:33,260 What it's telling us at offset 8 within that nested structure is what we're dereferencing. 407 00:38:33,260 --> 00:38:35,740 It ends up being the K thread pointer. 408 00:38:36,020 --> 00:38:40,240 K thread and E thread and K process and E process are kernel things. 409 00:38:40,240 --> 00:38:46,360 If you've ever heard of the process environment block in user land, the PEB, E process is like the equivalent in the kernel. 410 00:38:46,360 --> 00:38:54,100 If you've ever heard of the TIB, the thread information block, K thread, E thread, the executive and kernel thread, those are the relative entries in the kernel. 411 00:38:54,100 --> 00:38:56,100 Not 1 to 1, but it's pretty close. 412 00:38:56,200 --> 00:39:01,140 So either way, we're dereferencing and grabbing the K thread pointer for the current thread. 413 00:39:02,220 --> 00:39:05,580 So let me go in further and we're checking out our progress here. 414 00:39:05,580 --> 00:39:11,660 You can see that I run this fancy window bug command and we're basically saying, what is our current process? 415 00:39:11,740 --> 00:39:17,460 And it tells us that the current process is the, uh, which one, command.exe. 416 00:39:17,460 --> 00:39:18,940 That's not the process I want to be in. 417 00:39:18,940 --> 00:39:20,300 So we let it continue. 418 00:39:20,400 --> 00:39:26,940 We hit the break point again and then we look at the current process and now we're in the create process C++ program where we want to be. 419 00:39:26,940 --> 00:39:30,060 So now we know where we want to be, where we're at, where we want to be. 420 00:39:30,120 --> 00:39:38,740 It's important to mention that because when you set these types of break points, they will get hit often unless you set process specific break points as a kernel debugging session. 421 00:39:38,740 --> 00:39:42,720 So you want to make sure you understand what context you're under for each, you know, process. 422 00:39:43,060 --> 00:39:49,620 And then we hit our break point on the SC token set no child process restricted function. 423 00:39:49,960 --> 00:40:00,820 So this means that we're under the context of the create process C++ program and that mitigation function has just been called and it says set no child process restricted. 424 00:40:01,100 --> 00:40:08,860 So you go into hex rays and you decompile it and you say, hey, let's take a look at this function and that's what you're seeing on the right there. 425 00:40:08,860 --> 00:40:11,260 I know it's kind of small, again slides will be released. 426 00:40:11,380 --> 00:40:15,440 Put some circles around some variables because we don't know what those variables are. 427 00:40:15,480 --> 00:40:17,460 Thankfully we get symbols from Microsoft. 428 00:40:17,460 --> 00:40:23,700 Thankfully hex rays and IDA pro are brilliant, it's a brilliant disassembler and we get the function prototype data. 429 00:40:23,700 --> 00:40:30,940 As long as you know what the structure is, you can say, hey, I know this is a token structure because MSDN told me on the left, on the top there. 430 00:40:30,980 --> 00:40:39,480 And then once you do that, you see that it's able to then go in and add all the symbols, define everything that you want to see. 431 00:40:39,480 --> 00:40:54,520 On the right there, I did a stream a while ago on documenting undocumented structures and it was all about looking at different bit masks in the kernel and E process and the token structure to understand what the mitigation bits are and to show you kind of how to do that. 432 00:40:54,520 --> 00:41:09,500 This is a reference from Google that shows us that these different bit mask numbers, you'll see lots of booleans like ands and ors and those are either turning on or clearing bits in the bit mask so that the mitigation flags are set to the state that they're supposed to be in. 433 00:41:09,720 --> 00:41:18,260 So I went through here and I added a bunch of comments because obviously it's helpful especially if you're not used to debugging or disassembling and decompiling kernel structures. 434 00:41:18,440 --> 00:41:20,880 But that defines everything that's happening. 435 00:41:20,880 --> 00:41:23,980 Basically we're getting a token or acquiring a lock on the token. 436 00:41:23,980 --> 00:41:28,120 We're initializing a variable which ends up being the token , the current token. 437 00:41:28,140 --> 00:41:32,340 And then we're going in and we're checking bits that are set in the bit mask. 438 00:41:32,340 --> 00:41:37,260 And these bit masks bits are things like, is it in audit only mode? 439 00:41:37,260 --> 00:41:39,300 Should it be turned on and enforced? 440 00:41:39,300 --> 00:41:41,620 Is the low box token thing associated with it? 441 00:41:41,620 --> 00:41:43,560 What setting should I do? 442 00:41:43,560 --> 00:41:49,720 And through the boolean operations it turns on the appropriate bit which then sets the mitigation on. 443 00:41:50,560 --> 00:42:06,180 That is pretty much how that mitigation works and that's why it's being blocked because the next thing that would have happened had we kept going, the get function would have gotten called and it would have checked that bit to see if that program has the authority to spawn a new process. 444 00:42:06,660 --> 00:42:12,520 So that's kind of what we learned by going through that and that's how easy it can be to understand mitigations to see if you can get around them. 445 00:42:12,520 --> 00:42:17,440 So from that you're like, well then can I get around this somehow? 446 00:42:18,040 --> 00:42:27,160 Obviously the first thing you want to do is Google, go to chat GPT or your favorite AI LLM whatever and say, hey can you tell me about any bypass techniques that may be publicly available? 447 00:42:27,160 --> 00:42:34,460 But if there are no publicly available ones, hey you've got a great opportunity to do some cool research and make it public if you can find something. 448 00:42:34,720 --> 00:42:45,420 Some examples down there towards the bottom, there was a technique , I forget who discovered it but I put the link there where you can impersonate the anonymous token to get around the mitigation and spawn a new process. 449 00:42:45,420 --> 00:42:47,860 I don't think that still works but it was an option. 450 00:42:48,020 --> 00:42:57,540 You can use WMI like if you're in the context of Microsoft Office and you can use some cool PowerShell or WMI to get around the mitigation that way. 451 00:42:57,540 --> 00:43:03,780 There's process migration potentially, you can use reflexive DLL loading where you load from memory, something into memory. 452 00:43:03,780 --> 00:43:12,660 That also gets you around other mitigations like CIT, ones that are preventing you from loading an unsigned DLL from your Windows box. 453 00:43:12,820 --> 00:43:19,540 And again, setting it accordingly, enforcing the protection and getting around it with things like reflexive DLL. 454 00:43:19,540 --> 00:43:25,360 So, there's a bunch of ways we could potentially get around it and that's why it's so important that you put a bunch of these together. 455 00:43:25,360 --> 00:43:28,340 That you're not just relying on any one mitigation. 456 00:43:28,340 --> 00:43:42,240 I remember Microsoft made a pretty bold claim, somebody there, said CFG, control flow guard, should be a strong enough mitigation that it can prevent the majority of exploitation techniques where Emmet may not be needed as much. 457 00:43:42,240 --> 00:43:46,660 That ends up not being entirely true because CFG is another one you could potentially get around. 458 00:43:46,660 --> 00:43:50,800 People have demonstrated that even with V8 on Chrome. 459 00:43:52,280 --> 00:43:55,060 So, this right here, I just wanted to point it out. 460 00:43:55,240 --> 00:44:01,720 There are two fields and rest in peace to Jeff Chappelle, brilliant individual who passed away recently, sadly. 461 00:44:01,780 --> 00:44:17,940 But he maintained this site and I hope it stays up forever because every time Microsoft would make a structural change or add a new mitigation, like if you can see the ones towards the bottom on the right, mitigation flags too, you see things like control flow enforcement technology and shadow stacks. 462 00:44:17,940 --> 00:44:19,860 Those are relatively new mitigations. 463 00:44:19,860 --> 00:44:25,240 And these are bit masks that are set as a member of the e-process structure. 464 00:44:25,300 --> 00:44:27,560 And those are the things that are being checked. 465 00:44:27,560 --> 00:44:38,060 That's why a lot of times you might hear people getting around SMEP, like supervisor mode execution prevention, by setting a bit or flipping a bit inside a control register while under a certain context. 466 00:44:38,440 --> 00:44:41,500 Getting around patch guard by doing it fast and doing a race condition. 467 00:44:41,640 --> 00:44:49,800 So, the more you understand from an offensive perspective about these mitigations, the more you'll be able to get around them potentially or know when to call it a day. 468 00:44:49,800 --> 00:44:51,580 For me, it's all about saving time. 469 00:44:51,580 --> 00:45:00,840 If I know a mitigation is likely on and I'm doing a patch dip or find a zero day and I think it's not going to be fruitful for me to continue down that path, you got to pay your dues though. 470 00:45:00,840 --> 00:45:03,500 You will have those harsh, frustrating days. 471 00:45:03,500 --> 00:45:04,900 I still have them all the time. 472 00:45:05,200 --> 00:45:22,100 From a defensive perspective, it really helps you to understand how these mitigations work so that if you don't want to turn all of them on, you know which ones are going to be more beneficial, which ones have less overhead, which ones actually do stop an exploit technique and which ones are pretty useless. 473 00:45:23,300 --> 00:45:41,000 So, some takeaways, I think I went through some already, but it's a lot of nuance and I think that that gives us power where AI won't take over our jobs anytime soon because the circumstances in which you will be doing your research requires something that machine learning just can't do right now. 474 00:45:41,520 --> 00:45:44,720 And there's synergy there as well when working with other researchers. 475 00:45:45,140 --> 00:45:49,800 The golden years of binary exploitation can be behind us, but it's not going away anytime soon. 476 00:45:49,800 --> 00:45:54,140 People ask me, they probably ask you all the time, for how much longer am I going to be able to do this? 477 00:45:54,960 --> 00:45:56,500 As long as it's possible. 478 00:45:56,500 --> 00:45:57,680 People are going to keep doing it. 479 00:45:57,680 --> 00:46:01,280 It's a lot harder now, but I use an analogy like Tony Hawk, the skateboarder. 480 00:46:01,280 --> 00:46:05,460 What he was doing in the 1990s, there's like an eight-year-old kid able to do that today. 481 00:46:05,460 --> 00:46:16,660 We're just, all this information is out there to get you up to speed from all the research done in the past, fast, so that you can then go and bring about novel exploitation techniques and new zero days. 482 00:46:16,900 --> 00:46:21,100 And the ethical considerations are something that you have to understand and think about. 483 00:46:21,520 --> 00:46:28,060 There's new acts and new legislation out there, like Paul Maul and such, that we have to worry about. 484 00:46:28,320 --> 00:46:37,720 But as you probably know, the more you push researchers and say you can't do something, the more likely they're going to go unethical route and sell it on the dark net and make money that way. 485 00:46:38,120 --> 00:46:40,740 So, mitigations are a real thing. 486 00:46:40,740 --> 00:46:44,640 They're hard, but they're not going away and you just have to deal with it. 487 00:46:44,860 --> 00:46:48,900 You have to think about it as if there's always a way around it. 488 00:46:48,900 --> 00:46:51,400 And the prize will continue to grow. 489 00:46:51,400 --> 00:46:54,600 What was $10,000 is $500,000 now. 490 00:46:54,600 --> 00:46:57,140 So it is worth your time putting months into research. 491 00:46:58,120 --> 00:47:04,200 So references and thanks, there's always more people than I can remember to thank, but lots of researchers out there in the past. 492 00:47:04,200 --> 00:47:09,300 Jeremy Tinder, just a shout out to him for getting me those Microsoft documents or those updated charts, which is cool. 493 00:47:09,300 --> 00:47:12,860 Brad Spangler helped me out with going over some things, so I'm not going to go through everyone. 494 00:47:12,860 --> 00:47:19,720 Harun Mir is the individual I said that did a talk from 2010 that went through every single mitigation that ever came out. 495 00:47:19,720 --> 00:47:21,460 It's a beautiful document. 496 00:47:21,520 --> 00:47:23,060 Definitely check that one out. 497 00:47:23,100 --> 00:47:24,440 And a lot of other folks as well. 498 00:47:24,440 --> 00:47:26,200 Thanks to DEF CON for selecting a talk. 499 00:47:26,440 --> 00:47:27,520 That is it. 500 00:47:27,520 --> 00:47:29,000 I think I'm right on time here. 501 00:47:29,000 --> 00:47:34,240 I'm happy to, you know, chat out in the hall because I know I've got to make way if you have any questions, but thank you so much for coming to my talk. 502 00:47:34,240 --> 00:47:35,300 I really appreciate it.