1 00:00:00,000 --> 00:00:07,680 All right, so I'm going to be talking about drive-bys, automatic browser fingerprinting, 2 00:00:07,680 --> 00:00:09,940 and exploitation with the Metasploit framework. 3 00:00:10,320 --> 00:00:16,440 The tool itself is called Browser Autopone, and it's an auxiliary module for the Metasploit framework. 4 00:00:17,640 --> 00:00:22,820 There are exploit modules that everybody, I'm sure, is familiar with, and also auxiliary modules, 5 00:00:23,000 --> 00:00:24,120 and that's what Browser Autopone is. 6 00:00:24,640 --> 00:00:29,500 The first thing it does is it fingerprints a client to try to determine what exploits might work. 7 00:00:30,000 --> 00:00:36,900 And I started this tool almost a year ago, and when I first wrote it, it sucked, and now I think it doesn't. 8 00:00:40,900 --> 00:00:44,140 So this is a basic guide to what I'm going to be saying today. 9 00:00:45,060 --> 00:00:49,340 A bunch of boring intro stuff, then we're talking about cluster bombs, some guided missiles, 10 00:00:49,580 --> 00:00:52,860 and that's broken down into fingerprinting and targeting. 11 00:00:53,800 --> 00:00:54,800 Then some stealth. 12 00:00:55,500 --> 00:00:56,800 Hopefully the demos won't break. 13 00:00:57,040 --> 00:00:59,820 And I'll compare Browser Autopone to... 14 00:01:00,000 --> 00:01:02,480 some other things that I think suck more. 15 00:01:05,480 --> 00:01:08,260 So I'm James Lee. I'm also known as Egypt. 16 00:01:08,420 --> 00:01:14,760 I'm co-founder of Teardrop Security, which is a consulting company 17 00:01:15,420 --> 00:01:18,880 focused on penetration testing and forensics analysis. 18 00:01:19,660 --> 00:01:25,080 I'm also a developer for the Metasploit project, and I'm a member of ATT&CK Research. 19 00:01:26,900 --> 00:01:29,320 I started submitting patches, and... 20 00:01:30,000 --> 00:01:32,520 I sent bug reports to Metasploit in 2007. 21 00:01:34,340 --> 00:01:38,940 HD thought that my stuff didn't suck that much, so he put it in, put some of it in, 22 00:01:39,100 --> 00:01:44,500 and eventually gave me commit access in 2008, when I promptly broke the repository. 23 00:01:48,200 --> 00:01:50,820 So, I think I've gotten better, but no guarantees. 24 00:01:53,880 --> 00:01:58,200 Originally Metasploit was a game. It was an Encursus-based game that you could play anywhere. 25 00:02:00,000 --> 00:02:07,800 It later became a full-fledged exploitation framework written in Perl, but Ruby is a lot better. 26 00:02:08,020 --> 00:02:16,020 So in 2005, HD and the core dev team at the time, Scape and SpoonM, rewrote the whole thing in Ruby, 27 00:02:16,860 --> 00:02:18,380 which of course is way better than Python. 28 00:02:20,060 --> 00:02:23,240 It's an extensible framework, and it's more than just using exploits. 29 00:02:23,400 --> 00:02:28,580 It makes it a lot easier to write exploits, and there's a lot of non-exploit tools available within Metasploit. 30 00:02:29,180 --> 00:02:30,800 We'll talk about some of that a little bit later. 31 00:02:33,140 --> 00:02:37,360 I love Metasploit. It's part of the reason I started submitting patches. 32 00:02:37,600 --> 00:02:42,140 Part of the reason I wanted to make it better is because I know how awesome it can be. 33 00:02:44,000 --> 00:02:50,920 One of the biggest advantages to having a framework like Metasploit is that all of the payloads and encoders are modular. 34 00:02:51,120 --> 00:02:57,120 So you can write an exploit and then use any of these other payloads that are already available. 35 00:02:59,820 --> 00:03:09,140 So in the olden days, back in 2000, everybody just hard-coded their shellcode at the top of their big ugly C file, 36 00:03:09,340 --> 00:03:10,840 and that was a real pain in the ass. 37 00:03:11,280 --> 00:03:18,040 So if you wanted to use different shellcode, you didn't know if the code you had would work with this exploit until you tried it, 38 00:03:18,180 --> 00:03:24,040 and it wasn't modular, it wasn't extensible, and Metasploit replaced all of that with something much better. 39 00:03:25,160 --> 00:03:30,700 There are a bunch of protocols that already work in Metasploit. 40 00:03:30,820 --> 00:03:38,940 So you don't have to do all of the boilerplate crap to make HTTP or SMTP or whatever work with your exploit. 41 00:03:39,100 --> 00:03:42,740 You don't have to go through all of the effort of writing that code because it's already there. 42 00:03:43,760 --> 00:03:52,380 There's also stuff for finding vulnerabilities and for taking crashpox to a real exploit 43 00:03:52,380 --> 00:03:57,080 using some of the pattern offset things. 44 00:03:57,620 --> 00:04:02,620 And there's a few other tools that are there to make writing exploits a lot easier. 45 00:04:03,700 --> 00:04:09,760 And Metasploit supports the traditional server-side exploits and also client-sides, 46 00:04:09,900 --> 00:04:11,360 which is what we're going to be talking about today. 47 00:04:13,200 --> 00:04:18,940 And if you don't believe me that client-sides are important, then talk to Chris Gates. 48 00:04:19,160 --> 00:04:22,360 He's done a whole bunch of stuff about that. 49 00:04:22,900 --> 00:04:23,620 Client-sides. 50 00:04:23,840 --> 00:04:27,160 I won't beat this into the ground too much, but any time you can get in the middle, 51 00:04:27,660 --> 00:04:29,960 browser exploits become incredibly interesting. 52 00:04:30,520 --> 00:04:32,000 So Car Metasploit does that for us. 53 00:04:33,320 --> 00:04:38,700 Dragorne is working on integrating Airpone, which gives you basically the same stuff. 54 00:04:39,120 --> 00:04:42,440 And as soon as you get in the middle, it's basically game over. 55 00:04:43,640 --> 00:04:46,460 And if you can't get in the middle, users still suck. 56 00:04:47,880 --> 00:04:52,360 So just send an email or put an iframe in their account. 57 00:04:52,360 --> 00:04:53,900 Or corporate web server or whatever. 58 00:04:54,580 --> 00:04:55,840 That part doesn't really matter. 59 00:04:55,980 --> 00:04:58,780 As long as you can get them somehow to talk to my web server, then we win. 60 00:05:02,020 --> 00:05:05,740 Client exploits in Metasploit are relatively easy to write. 61 00:05:05,960 --> 00:05:07,500 There's extensive HTTP support. 62 00:05:08,000 --> 00:05:09,340 All of that stuff is already there. 63 00:05:09,480 --> 00:05:11,880 There's heap spray in two lines of code. 64 00:05:12,140 --> 00:05:13,700 That's a fairly complex technique. 65 00:05:14,160 --> 00:05:16,080 And you can do it in two lines of code in Metasploit. 66 00:05:16,900 --> 00:05:20,020 There's also support for other more complicated stuff. 67 00:05:20,260 --> 00:05:21,560 Sauterovs.net, DLL. 68 00:05:21,560 --> 00:05:23,920 And heap feng shui stuff are both integrated. 69 00:05:24,980 --> 00:05:27,160 And it's fairly easy to use them. 70 00:05:27,220 --> 00:05:33,200 It's a lot easier than having to write it yourself and crapping out some big ugly HTML file. 71 00:05:33,500 --> 00:05:34,540 Everything is in Ruby. 72 00:05:34,660 --> 00:05:35,520 It's a lot easier to read. 73 00:05:35,820 --> 00:05:37,700 And in general, much better. 74 00:05:38,560 --> 00:05:42,300 There's also a lot of protocol level IDS evasion. 75 00:05:42,640 --> 00:05:45,740 It's very easy to randomize HTML and JavaScript. 76 00:05:46,200 --> 00:05:51,540 All of that stuff is very easy to just mangle around. 77 00:05:51,560 --> 00:05:52,860 And make it look different. 78 00:05:53,020 --> 00:05:54,940 So it's harder for IDS guys to trigger on it. 79 00:05:55,340 --> 00:05:58,460 And you can write a simple exploit in around ten lines of code. 80 00:05:59,160 --> 00:06:00,400 This is what one looks like. 81 00:06:00,680 --> 00:06:02,300 This one is kind of a contrived example. 82 00:06:02,960 --> 00:06:07,960 So you've got some class ID, some active X control with a vulnerable method. 83 00:06:08,860 --> 00:06:15,240 And so we've got, you know, I've elided the class ID here. 84 00:06:15,380 --> 00:06:16,520 Because it doesn't really exist. 85 00:06:16,760 --> 00:06:20,080 But we set up the heap spray. 86 00:06:20,080 --> 00:06:21,840 We spray with this little chunk of code. 87 00:06:23,840 --> 00:06:25,680 We spray the heap with our shell code. 88 00:06:26,100 --> 00:06:26,840 That's this guy. 89 00:06:28,740 --> 00:06:31,000 And the place where we want to go. 90 00:06:32,420 --> 00:06:33,740 And a block size. 91 00:06:34,280 --> 00:06:35,500 And it just does it all for you. 92 00:06:36,240 --> 00:06:39,000 Then we trigger whatever the heap corruption is. 93 00:06:39,180 --> 00:06:40,740 And it gives us a shell. 94 00:06:43,880 --> 00:06:45,680 Or it can be arbitrarily complex. 95 00:06:46,240 --> 00:06:50,060 For example, ANI load image chunk size is 581. 96 00:06:50,880 --> 00:06:52,360 It's got to build up an image. 97 00:06:52,580 --> 00:06:56,680 It's currently our biggest HTTP exploit. 98 00:06:57,320 --> 00:06:58,760 So it's got to build up an image. 99 00:06:58,920 --> 00:07:02,220 It's got to throw the payload in there. 100 00:07:02,400 --> 00:07:03,260 Randomize some stuff. 101 00:07:03,740 --> 00:07:05,800 And it's a fairly complicated exploit. 102 00:07:06,600 --> 00:07:11,800 And as of June 28th, Metasploit has 85 browser exploit modules. 103 00:07:12,160 --> 00:07:14,620 That's changed in the last couple of weeks. 104 00:07:14,720 --> 00:07:18,680 There's been a few O days in Internet Explorer and Firefox. 105 00:07:18,680 --> 00:07:21,240 And we have support for all of those. 106 00:07:23,760 --> 00:07:25,540 So we've got 85 exploits. 107 00:07:25,660 --> 00:07:28,500 Or something like 87, 88 now. 108 00:07:30,300 --> 00:07:31,420 What do you do? 109 00:07:31,460 --> 00:07:33,700 How do you figure out which one to send? 110 00:07:33,960 --> 00:07:36,120 The problem is one of scale. 111 00:07:36,360 --> 00:07:38,760 You've got a bunch of people connecting up to you. 112 00:07:39,280 --> 00:07:40,500 Which exploit do you send? 113 00:07:40,600 --> 00:07:43,080 If you send one Internet Explorer exploit. 114 00:07:43,280 --> 00:07:46,740 And all your people connect up with a vulnerable version of Firefox. 115 00:07:46,940 --> 00:07:47,820 You're missing out on shells. 116 00:07:48,680 --> 00:07:49,420 And everybody loves shells. 117 00:07:49,520 --> 00:07:50,380 You don't want to miss out on them. 118 00:07:52,480 --> 00:07:56,260 So the solution and the first thing that I tried was sort of a cluster bomb approach. 119 00:07:56,920 --> 00:07:58,340 For those of you playing at home. 120 00:07:58,440 --> 00:08:05,900 This is an MK44 lazy dog cluster bomb used in Vietnam. 121 00:08:13,680 --> 00:08:18,040 So this approach was basically using a user agent match. 122 00:08:18,680 --> 00:08:20,100 If it's Internet Explorer. 123 00:08:20,380 --> 00:08:23,120 You send all of our Internet Explorer exploits. 124 00:08:23,420 --> 00:08:26,380 And it's, you know, it's effective in a lot of ways. 125 00:08:26,480 --> 00:08:28,260 But it has a lot of downsides too. 126 00:08:30,160 --> 00:08:39,580 And originally the browser auto-pwn module had all of the exploits basically inside the auto-pwn module itself. 127 00:08:40,060 --> 00:08:43,240 And so it was sort of a pain in the ass when new exploits came out. 128 00:08:43,620 --> 00:08:47,920 And you couldn't easily remove or add new exploits. 129 00:08:49,560 --> 00:08:50,480 So that's changed. 130 00:08:51,360 --> 00:08:54,060 Now there's another big problem with that one. 131 00:08:54,620 --> 00:08:57,680 If you send all of the Internet Explorer exploits. 132 00:08:58,580 --> 00:09:01,780 And only one of them is going to work. 133 00:09:02,260 --> 00:09:05,080 If another one crashes it before that one runs. 134 00:09:05,220 --> 00:09:06,180 You don't get your shell. 135 00:09:06,560 --> 00:09:08,620 And like I said, everybody loves shells. 136 00:09:08,720 --> 00:09:09,780 And you don't want to miss your shells. 137 00:09:11,820 --> 00:09:16,260 So the solution here is a GBU Paveway Bunker Buster. 138 00:09:18,860 --> 00:09:20,820 Laser guided missile for blowing up bridges. 139 00:09:21,320 --> 00:09:21,940 Freaking cool. 140 00:09:24,860 --> 00:09:30,220 So the first thing you need for a laser guided missile is to know what to point the laser at. 141 00:09:30,400 --> 00:09:31,840 You've got to know what the client is. 142 00:09:31,980 --> 00:09:34,800 What the OS fingerprinting or what the OS is running. 143 00:09:35,300 --> 00:09:38,000 And we use JavaScript fingerprinting to do all of that. 144 00:09:38,360 --> 00:09:42,380 And once we figure out what the target is, we're much less likely to crash or hang it. 145 00:09:42,460 --> 00:09:46,940 Or get that stupid little dialogue that says, you know, this script has been running too long. 146 00:09:47,080 --> 00:09:48,160 Please don't give me my shell. 147 00:09:51,780 --> 00:09:54,800 So we only send exploits that are likely to succeed. 148 00:09:54,920 --> 00:09:57,640 It doesn't make sense to send Firefox exploits to IE. 149 00:09:57,760 --> 00:09:59,580 Or IE6 exploits to IE7. 150 00:09:59,980 --> 00:10:06,820 So having fingerprinting gives us a much more granular way of deciding which exploits to send. 151 00:10:09,800 --> 00:10:18,200 And most of the available stuff for detecting what a browser is uses the user agent string. 152 00:10:18,200 --> 00:10:22,020 Which is just a string that goes in the headers of an HTTP request. 153 00:10:22,800 --> 00:10:26,000 That supposedly uniquely identifies any given browser. 154 00:10:27,140 --> 00:10:29,260 The problem is that it's really easy to spoof. 155 00:10:29,500 --> 00:10:37,800 And in fact, Firefox, Opera, and Safari all have things that allow you to change the user agent to look like IE. 156 00:10:37,960 --> 00:10:41,480 Because a lot of websites are stupid and broken. 157 00:10:41,860 --> 00:10:44,840 And you have to look like IE for their website to work. 158 00:10:45,500 --> 00:10:48,180 So they provide a way for you to eat. 159 00:10:48,180 --> 00:10:49,240 You can easily change your user agent. 160 00:10:49,480 --> 00:10:51,480 And this totally breaks all of that detection. 161 00:10:52,460 --> 00:10:55,480 It's also easy for a proxy to change or just completely remove. 162 00:10:57,000 --> 00:11:05,840 So if you've got some corporate proxy and everybody has to funnel through that proxy, the proxy can change anything in the way. 163 00:11:06,820 --> 00:11:08,840 And that makes it much harder for us to detect. 164 00:11:10,580 --> 00:11:13,940 Now, all of this is harder to change in JavaScript. 165 00:11:14,560 --> 00:11:17,060 There are ways to do some of it. 166 00:11:17,060 --> 00:11:30,120 So for example, Firefox using the user agent switcher add-on will also change all of the JavaScript objects that tell you the stuff that's in the user agent. 167 00:11:30,580 --> 00:11:38,960 And so if you use user agent switcher to change to IE7, then the JavaScript objects also look like IE7. 168 00:11:39,080 --> 00:11:40,860 With a couple of exceptions that we'll see in a minute. 169 00:11:42,720 --> 00:11:46,040 In Internet Explorer, there's basically no way to change that. 170 00:11:46,040 --> 00:11:49,980 All of that shows up in, as JavaScript, it's really JavaScript. 171 00:11:50,400 --> 00:11:51,760 Or it's really the right thing. 172 00:11:53,520 --> 00:11:56,780 But it doesn't matter anyway with Internet Explorer, as we'll see in a minute. 173 00:11:59,820 --> 00:12:06,080 So for figuring out what the client is, we've got a number of JavaScript objects that only exist in a given browser. 174 00:12:07,780 --> 00:12:10,040 Examples, window.opera only exists in Opera. 175 00:12:11,160 --> 00:12:12,260 That one sort of makes sense. 176 00:12:12,440 --> 00:12:16,020 Who the hell would make something called window.opera if you weren't doing that? 177 00:12:16,040 --> 00:12:16,720 Opera. 178 00:12:18,900 --> 00:12:21,240 Array.every only exists in Firefox. 179 00:12:22,760 --> 00:12:26,600 And some of these things only exist in certain versions. 180 00:12:26,920 --> 00:12:35,160 So these are new features that have been added since 1.0 only had these objects and now 1.5 has these objects as well. 181 00:12:35,500 --> 00:12:41,620 So an example of this is window.createpopup only exists in IE 5.5 and newer. 182 00:12:42,060 --> 00:12:45,920 Array.every only exists in Firefox, I believe 1.5 and newer. 183 00:12:47,660 --> 00:13:01,780 Another way, another sort of method for figuring out what the client is, is used often by web developers, is IE's conditional comments, parser bugs, rendering differences. 184 00:13:02,300 --> 00:13:14,620 So there's an example in IE 6 or older, you could put a backslash in front of the star of the end of a comment. 185 00:13:14,620 --> 00:13:21,260 And IE 5.5 would not treat that as the end of a comment. 186 00:13:21,400 --> 00:13:29,300 So you could have a bigger comment for IE 5 than for everybody else and use that to determine that it's definitely IE 5. 187 00:13:29,920 --> 00:13:33,420 The problem with this is it's not really precise. 188 00:13:33,880 --> 00:13:41,320 It's reliable and it'll definitely tell us that it's IE 5.5 or older, but it's not precise. 189 00:13:41,440 --> 00:13:42,660 It only tells us that. 190 00:13:42,660 --> 00:13:51,760 Luckily, Internet Explorer gives us these awesome functions called script engine major version, script engine minor version, and script engine build version. 191 00:13:57,640 --> 00:14:05,260 The great thing about these three functions is they're almost unique across all combinations of OS and client. 192 00:14:05,580 --> 00:14:11,320 So if we have the output of these three functions, we can reliably and accurately determine, 193 00:14:11,320 --> 00:14:18,080 not only the browser, but the browser version, the operating system it's running on, the flavor of operating system, 194 00:14:18,220 --> 00:14:23,360 so XP or 2000 or whatever, as well as the service pack level of the operating system. 195 00:14:26,600 --> 00:14:30,280 Opera gives us a nice little win here that's got a function called opera.version. 196 00:14:31,600 --> 00:14:32,900 Hey, that's all I need. 197 00:14:36,240 --> 00:14:38,560 Firefox doesn't have anything awesome like that. 198 00:14:38,660 --> 00:14:41,300 It just gives us the simple ways of using it. 199 00:14:41,320 --> 00:14:44,740 Using object detection to determine that it is Firefox. 200 00:14:45,080 --> 00:14:49,900 And we can get sort of a high-level version this way. 201 00:14:50,100 --> 00:14:55,880 So you can tell for sure that this is Firefox 3.0 by the existence of document.getElementsByClassName. 202 00:14:56,100 --> 00:14:59,940 Nobody else uses that, and it only shows up in 3.0 and newer. 203 00:15:01,740 --> 00:15:06,440 So we can use that and check the user agent and see if the user agent is lying. 204 00:15:06,680 --> 00:15:10,320 So if the user agent says it's Firefox 3.0, 205 00:15:10,320 --> 00:15:13,560 and I know for sure that it's Firefox 3.0 because of my object detection, 206 00:15:13,880 --> 00:15:16,580 then I can be fairly certain, not 100%, 207 00:15:17,120 --> 00:15:20,860 but fairly certain that the user agent is not lying. 208 00:15:21,300 --> 00:15:26,800 And once I know that, I can use the more precise value that's in the user agent, 3.08 or whatever. 209 00:15:28,660 --> 00:15:30,620 Safari is still sort of a work in progress. 210 00:15:30,860 --> 00:15:33,740 I haven't spent a lot of time trying to fingerprint it yet. 211 00:15:34,460 --> 00:15:38,780 We don't have any relatively new exploits for Safari yet. 212 00:15:39,360 --> 00:15:40,300 I'm working on that. 213 00:15:42,300 --> 00:15:45,280 But there's a couple of objects that exist in Safari, 214 00:15:46,460 --> 00:15:51,600 but it's mostly pre-standards compliant in this regard in JavaScript implementation. 215 00:15:52,320 --> 00:15:57,180 There's not many extensions to the JavaScript, the standard JavaScript libraries. 216 00:15:58,700 --> 00:16:01,820 So that's kind of a pain in the ass in Safari. 217 00:16:02,020 --> 00:16:05,620 You can't really tell much more than that it is Safari at this point. 218 00:16:06,380 --> 00:16:08,420 It's possible that I'll find some other stuff later, 219 00:16:08,540 --> 00:16:10,140 but for right now, all I can tell is that 220 00:16:10,320 --> 00:16:10,880 it is Safari. 221 00:16:14,460 --> 00:16:17,400 Now fingerprinting the OS from the server side 222 00:16:17,400 --> 00:16:20,040 using the traditional user agent string matching 223 00:16:20,040 --> 00:16:26,700 is subject to the same problems for fingerprinting the client in the same way. 224 00:16:27,060 --> 00:16:29,540 And we could also use something like P0F 225 00:16:29,540 --> 00:16:34,360 for a passive fingerprinting using TCP artifacts 226 00:16:34,360 --> 00:16:38,540 and things that are different about any given operating system from others. 227 00:16:38,540 --> 00:16:40,880 But that sounds like work. 228 00:16:44,780 --> 00:16:46,980 So we've got JavaScript, 229 00:16:47,060 --> 00:16:49,780 and JavaScript gives us a lot of stuff. 230 00:16:51,400 --> 00:16:52,800 Like I said with Internet Explorer, 231 00:16:53,180 --> 00:16:54,480 it basically gives us everything. 232 00:16:54,680 --> 00:16:56,960 We know the operating system, 233 00:16:57,180 --> 00:16:59,260 what version of the operating system it is, 234 00:16:59,380 --> 00:17:01,020 and what service pack level it's running. 235 00:17:01,380 --> 00:17:04,040 So I can tell reliably the difference between 236 00:17:05,060 --> 00:17:06,720 XP service pack 0 and 1, 237 00:17:06,820 --> 00:17:08,520 XP service pack 1, 238 00:17:08,520 --> 00:17:08,880 and 2. 239 00:17:10,860 --> 00:17:14,720 Well, 2003 is the sort of outlier. 240 00:17:14,960 --> 00:17:17,160 It has a couple of overlaps with XP. 241 00:17:17,480 --> 00:17:19,380 So I can't always tell the difference between 242 00:17:19,380 --> 00:17:21,260 2003 and XP, 243 00:17:21,980 --> 00:17:23,980 but the service pack levels are the same, 244 00:17:24,080 --> 00:17:24,660 so it's okay. 245 00:17:28,480 --> 00:17:30,720 Opera doesn't really give us anything awesome, 246 00:17:31,450 --> 00:17:33,400 but it does give us this function called 247 00:17:33,400 --> 00:17:34,520 opera.buildnumber. 248 00:17:34,960 --> 00:17:37,460 And that's basically unique amongst 249 00:17:37,460 --> 00:17:39,000 operating systems. 250 00:17:39,280 --> 00:17:41,240 It doesn't give us the version of the operating system 251 00:17:41,240 --> 00:17:46,300 or the service pack level, 252 00:17:46,480 --> 00:17:48,040 but it does give us the platform. 253 00:17:48,300 --> 00:17:49,620 And that's enough to tell us, 254 00:17:49,680 --> 00:17:52,700 with a certain degree of likelihood, 255 00:17:52,940 --> 00:17:56,160 that the user agent is not lying. 256 00:17:56,360 --> 00:17:58,560 So we can use sort of that same hybrid approach 257 00:17:58,560 --> 00:18:00,020 that we used for Firefox earlier 258 00:18:01,040 --> 00:18:03,260 to determine the operating system using Opera. 259 00:18:05,320 --> 00:18:05,800 Firefox, 260 00:18:05,800 --> 00:18:07,920 like I said, 261 00:18:08,000 --> 00:18:09,640 has the navigator.platform, 262 00:18:09,840 --> 00:18:11,120 navigator.useragent, 263 00:18:11,240 --> 00:18:13,280 and all of those things are affected by 264 00:18:13,680 --> 00:18:14,680 the user agent string. 265 00:18:15,000 --> 00:18:17,080 So if someone changes the user agent string 266 00:18:17,080 --> 00:18:18,620 using user agent switcher 267 00:18:18,620 --> 00:18:19,760 or going through the about config, 268 00:18:21,720 --> 00:18:23,520 all of that will change too. 269 00:18:23,800 --> 00:18:24,820 And that sucks. 270 00:18:25,480 --> 00:18:26,000 But, 271 00:18:26,780 --> 00:18:28,600 we've got navigator.oscpu, 272 00:18:28,860 --> 00:18:29,840 which doesn't change. 273 00:18:30,060 --> 00:18:32,240 It's completely independent as far as I can tell 274 00:18:32,240 --> 00:18:33,900 from the user agent string itself. 275 00:18:34,500 --> 00:18:35,440 And again, 276 00:18:35,440 --> 00:18:36,560 this only gives us the platform, 277 00:18:37,480 --> 00:18:38,460 but on Windows, 278 00:18:38,560 --> 00:18:40,080 it gives us the platform and the version. 279 00:18:40,260 --> 00:18:41,120 So we can tell using 280 00:18:43,280 --> 00:18:44,660 this simple little object, 281 00:18:44,780 --> 00:18:46,560 we can tell that it's Windows XP. 282 00:18:46,900 --> 00:18:48,240 We can't tell the service pack level, 283 00:18:48,400 --> 00:18:49,420 but most of the time, 284 00:18:49,420 --> 00:18:49,820 that's okay. 285 00:18:52,280 --> 00:18:54,420 It's interesting that the Linux versions 286 00:18:54,420 --> 00:18:56,100 also give us the CPU, 287 00:18:56,840 --> 00:18:57,860 which is totally cool, 288 00:18:57,960 --> 00:19:00,640 because now it means it's Linux on Intel, 289 00:19:00,880 --> 00:19:03,460 so I don't send any PPC shellcode with it, 290 00:19:04,580 --> 00:19:05,240 saving me, 291 00:19:05,440 --> 00:19:05,720 a shell. 292 00:19:09,060 --> 00:19:10,800 Since I don't really do anything specific 293 00:19:11,240 --> 00:19:12,540 for anybody else, 294 00:19:12,840 --> 00:19:14,100 all we're left with at this point 295 00:19:14,100 --> 00:19:14,740 is the user agent. 296 00:19:15,760 --> 00:19:16,640 For the most part, 297 00:19:16,660 --> 00:19:17,080 that's okay. 298 00:19:18,040 --> 00:19:19,940 Most people don't lie about their user agent. 299 00:19:20,140 --> 00:19:21,160 If they are lying, 300 00:19:22,020 --> 00:19:23,740 it's likely that they're patched anyway. 301 00:19:24,060 --> 00:19:25,500 People that change their user agent 302 00:19:25,500 --> 00:19:26,860 are people that, 303 00:19:26,920 --> 00:19:27,420 you know, 304 00:19:27,440 --> 00:19:29,120 kind of know things about computers. 305 00:19:32,000 --> 00:19:34,060 And it doesn't necessarily mean that 306 00:19:34,060 --> 00:19:35,480 they're not lying, 307 00:19:35,600 --> 00:19:37,720 or that they're patched, 308 00:19:37,740 --> 00:19:38,900 just because they lie. 309 00:19:39,960 --> 00:19:41,720 But I think there's probably 310 00:19:41,720 --> 00:19:43,600 a really strong correlation there. 311 00:19:44,400 --> 00:19:47,220 The advantage of a user agent string matching 312 00:19:47,220 --> 00:19:49,300 is that it's completely generic, 313 00:19:49,380 --> 00:19:52,340 and it works on everybody, basically. 314 00:19:54,000 --> 00:19:56,220 Of course, the downside is that it can be spoofed, 315 00:19:56,240 --> 00:19:57,800 but sometimes that's okay. 316 00:20:00,000 --> 00:20:01,900 Right now, we're not doing any fingerprinting 317 00:20:01,900 --> 00:20:03,460 on third-party stuff. 318 00:20:04,060 --> 00:20:04,780 QuickTime, Adobe, 319 00:20:05,060 --> 00:20:07,180 other plug-ins and whatnot. 320 00:20:08,940 --> 00:20:10,620 That's sort of planned for the future, 321 00:20:10,760 --> 00:20:12,400 but with ActiveX, 322 00:20:12,620 --> 00:20:13,780 it doesn't matter, 323 00:20:13,920 --> 00:20:15,460 because for an exploit, 324 00:20:15,560 --> 00:20:17,300 we have to know the ActiveX class ID 325 00:20:17,900 --> 00:20:19,520 or the ActiveX class name anyway. 326 00:20:21,820 --> 00:20:23,980 So we don't necessarily have to do 327 00:20:23,980 --> 00:20:25,180 any fingerprinting to determine, 328 00:20:25,320 --> 00:20:26,140 you know, 329 00:20:26,160 --> 00:20:28,120 is Foxit Reader installed, 330 00:20:28,260 --> 00:20:31,920 because there's an ActiveX class ID. 331 00:20:32,060 --> 00:20:32,520 We just say, 332 00:20:32,520 --> 00:20:33,820 is this class ID installed? 333 00:20:35,900 --> 00:20:37,300 The easy way to do that is 334 00:20:37,300 --> 00:20:38,240 if you've got a class name, 335 00:20:38,280 --> 00:20:39,780 you can just call new ActiveX object, 336 00:20:40,040 --> 00:20:41,500 and if it doesn't throw an exception, 337 00:20:41,840 --> 00:20:42,600 you're good to go, 338 00:20:42,660 --> 00:20:43,760 and you can go ahead and try the exploit. 339 00:20:45,240 --> 00:20:47,180 Unfortunately, if you've only got a class ID 340 00:20:47,180 --> 00:20:48,400 and you don't have the class name, 341 00:20:50,220 --> 00:20:52,040 writing it out using document.write 342 00:20:52,040 --> 00:20:54,920 or creating it with document.createElement 343 00:20:55,440 --> 00:20:56,900 gives you a DOM object 344 00:20:56,900 --> 00:20:58,460 instead of an ActiveX object. 345 00:20:59,160 --> 00:21:00,920 Well, that's kind of a pain in the ass. 346 00:21:03,320 --> 00:21:06,100 Having a DOM object means that it is an object, 347 00:21:06,260 --> 00:21:07,320 and it evaluates to true, 348 00:21:07,400 --> 00:21:09,620 so we can't just check it for existence. 349 00:21:10,660 --> 00:21:12,220 And the only way to tell 350 00:21:12,220 --> 00:21:14,180 is to try to run a method 351 00:21:14,180 --> 00:21:16,880 or access a property of that object 352 00:21:17,300 --> 00:21:18,880 that only exists in the ActiveX control 353 00:21:18,880 --> 00:21:20,460 and not in a regular DOM object. 354 00:21:22,940 --> 00:21:24,320 Fortunately, for an exploit, 355 00:21:24,540 --> 00:21:25,660 we already have to know that. 356 00:21:26,680 --> 00:21:30,580 So to exploit some vulnerable method, 357 00:21:31,300 --> 00:21:32,500 you have to know the name of that object. 358 00:21:32,520 --> 00:21:35,020 So all we have to do 359 00:21:35,020 --> 00:21:40,020 is check the type of that method on the object. 360 00:21:40,200 --> 00:21:41,040 If it's a DOM object, 361 00:21:41,600 --> 00:21:43,240 the method isn't going to exist, 362 00:21:43,500 --> 00:21:46,700 and we end up with an undefined type. 363 00:21:48,380 --> 00:21:49,560 For anything else, 364 00:21:49,600 --> 00:21:52,400 if it's an ActiveX method, 365 00:21:52,760 --> 00:21:54,720 then it'll come back as an unknown type, 366 00:21:54,940 --> 00:21:56,820 which I think is a little weird, 367 00:21:56,900 --> 00:21:58,680 but suits our purposes well enough 368 00:21:58,680 --> 00:21:59,920 as long as it's not undefined. 369 00:22:00,980 --> 00:22:02,500 The other possibility 370 00:22:02,520 --> 00:22:06,180 is that it comes back as some regular JavaScript type, 371 00:22:06,320 --> 00:22:08,120 like integer or string or whatever. 372 00:22:08,880 --> 00:22:10,260 At that point, I don't really care, 373 00:22:10,260 --> 00:22:11,560 just as long as it's not undefined. 374 00:22:13,620 --> 00:22:15,820 So now we've figured out what the target is. 375 00:22:15,980 --> 00:22:17,380 We know what we're looking at. 376 00:22:17,440 --> 00:22:18,220 We know what we're up against. 377 00:22:19,100 --> 00:22:21,800 Now we need to figure out what it's vulnerable to. 378 00:22:22,600 --> 00:22:25,160 We can do sort of a course determination server side, 379 00:22:25,360 --> 00:22:27,340 and this is how Browser Autopone implements it. 380 00:22:27,800 --> 00:22:30,000 First, we build the fingerprint using JavaScript. 381 00:22:30,320 --> 00:22:32,280 We send all that to the client, 382 00:22:32,520 --> 00:22:34,780 the client runs it for us, 383 00:22:34,820 --> 00:22:36,100 tells us what it is, 384 00:22:36,200 --> 00:22:37,640 sends that back to the server. 385 00:22:37,900 --> 00:22:40,240 The server takes this, dumps it into a database, 386 00:22:41,100 --> 00:22:43,120 figures out which exploits might match 387 00:22:43,120 --> 00:22:46,160 this combination of OS and client, 388 00:22:46,800 --> 00:22:49,060 and throws it back to the client. 389 00:22:49,620 --> 00:22:51,780 So then on the client side, 390 00:22:51,980 --> 00:22:54,060 we've got all of these exploits, 391 00:22:54,120 --> 00:22:55,980 and we can make a fine determination 392 00:22:56,520 --> 00:22:58,620 of which ones might work. 393 00:22:58,780 --> 00:23:02,380 So the example here is Mozilla Navigator Java, 394 00:23:02,380 --> 00:23:07,360 requires the Java plug-in to be enabled. 395 00:23:10,400 --> 00:23:12,940 So the test for that is very simple. 396 00:23:13,020 --> 00:23:15,740 You just make sure that Java is enabled, 397 00:23:17,760 --> 00:23:19,440 and then go ahead and try the exploit. 398 00:23:19,660 --> 00:23:21,440 If it's not enabled, then don't bother. 399 00:23:21,620 --> 00:23:23,700 You don't want to do a heap spray for no reason. 400 00:23:27,140 --> 00:23:30,780 So now we've sorted all of this stuff. 401 00:23:30,880 --> 00:23:32,360 We figured out that we know what the client needs, 402 00:23:32,380 --> 00:23:32,680 what the client is, 403 00:23:32,860 --> 00:23:36,240 and we can try to pick out a missile. 404 00:23:38,080 --> 00:23:40,180 If you're interested in this sort of thing, 405 00:23:40,320 --> 00:23:45,740 this is an array of Iranian and North Korean missiles. 406 00:23:47,940 --> 00:23:50,660 I especially like, and I would like to point out to you, 407 00:23:51,360 --> 00:23:55,480 the No Dong. 408 00:23:56,800 --> 00:23:57,280 . 409 00:24:01,720 --> 00:24:03,700 I also think it's slightly ironic 410 00:24:03,700 --> 00:24:05,340 that it's much shorter than all the others. 411 00:24:11,260 --> 00:24:12,400 So now we've picked a missile. 412 00:24:13,220 --> 00:24:14,120 There's another problem. 413 00:24:14,740 --> 00:24:15,120 AV. 414 00:24:15,960 --> 00:24:16,580 AV sucks. 415 00:24:17,560 --> 00:24:20,200 It sucks for a couple of reasons. 416 00:24:20,800 --> 00:24:23,140 You know, if a user is browsing along 417 00:24:23,140 --> 00:24:25,700 and they go to all the effort of clicking on your link for you, 418 00:24:25,840 --> 00:24:27,080 they go to your evil web server, 419 00:24:27,800 --> 00:24:29,340 the AV catches you, 420 00:24:30,580 --> 00:24:32,080 they don't click on your link anymore. 421 00:24:33,460 --> 00:24:35,200 I like people clicking on my links. 422 00:24:35,660 --> 00:24:37,140 I want people to give me shells. 423 00:24:37,780 --> 00:24:39,240 AV stops my shells. 424 00:24:40,020 --> 00:24:42,700 So the solution here is some stealth. 425 00:24:43,220 --> 00:24:46,180 And if we don't look like we're evil, 426 00:24:46,360 --> 00:24:49,600 then AV will let our shells come back. 427 00:24:49,800 --> 00:24:51,800 And everybody likes shells. 428 00:24:54,820 --> 00:24:56,100 And the way we do that 429 00:24:56,100 --> 00:24:58,100 is largely through obfuscation. 430 00:24:58,320 --> 00:25:00,360 We can randomize identifiers in JavaScript. 431 00:25:00,720 --> 00:25:01,760 That's relatively easy. 432 00:25:02,980 --> 00:25:06,800 All we have to do is know the names of all of our identifiers, 433 00:25:07,140 --> 00:25:09,500 randomize them up into ASCII strings, 434 00:25:11,420 --> 00:25:14,420 and that makes it a lot more difficult to fingerprint. 435 00:25:15,140 --> 00:25:18,760 Secondly, we can build strings out of things that build, 436 00:25:18,920 --> 00:25:20,160 that become strings. 437 00:25:20,360 --> 00:25:25,500 So string.fromcharcode can take a bunch of hex digits 438 00:25:25,500 --> 00:25:28,340 and turn them into their ASCII equivalents. 439 00:25:28,520 --> 00:25:29,480 We can use that. 440 00:25:29,480 --> 00:25:30,860 We can use unescape. 441 00:25:31,900 --> 00:25:34,120 There's a number of different ways of building a string 442 00:25:34,120 --> 00:25:36,520 from things that aren't strings and won't trigger AV. 443 00:25:37,880 --> 00:25:39,900 Another solution is using Ajax 444 00:25:39,900 --> 00:25:41,900 to send a little bit of it at a time. 445 00:25:42,160 --> 00:25:44,000 So you go download some with Ajax, 446 00:25:44,020 --> 00:25:45,400 some JavaScript with Ajax, 447 00:25:46,080 --> 00:25:47,020 you run it, 448 00:25:47,120 --> 00:25:48,480 you go download some more, 449 00:25:48,640 --> 00:25:49,420 you run it, 450 00:25:49,480 --> 00:25:50,440 you go download some more. 451 00:25:50,580 --> 00:25:52,620 So now we're getting little chunks of the payload, 452 00:25:52,800 --> 00:25:54,480 and it doesn't look quite as evil. 453 00:25:55,600 --> 00:25:57,900 The downside to obfuscation is, of course, 454 00:25:57,940 --> 00:25:58,560 that it's not crypto. 455 00:25:58,920 --> 00:26:00,140 It's just obfuscation. 456 00:26:00,800 --> 00:26:03,060 And a human would be able to figure this out 457 00:26:03,060 --> 00:26:04,280 relatively easily. 458 00:26:06,020 --> 00:26:09,640 We're not really targeting a human to, 459 00:26:10,560 --> 00:26:12,820 a human that might want to figure out what we're doing, 460 00:26:14,540 --> 00:26:16,680 because basically all we want to do is get around AV. 461 00:26:17,160 --> 00:26:20,080 If a real person starts looking at our JavaScript, 462 00:26:20,300 --> 00:26:23,460 then, well, they've already determined that we're malicious. 463 00:26:24,540 --> 00:26:26,820 And we would like to avoid that, 464 00:26:26,920 --> 00:26:28,260 if possible, beforehand. 465 00:26:29,320 --> 00:26:31,780 So, like I said, obfuscation is not crypto, 466 00:26:32,000 --> 00:26:33,280 but encryption is crypto. 467 00:26:33,520 --> 00:26:34,180 That's cool. 468 00:26:36,320 --> 00:26:38,180 So we can put a key, 469 00:26:38,360 --> 00:26:40,120 like an XOR key or whatever kind of key, 470 00:26:40,280 --> 00:26:42,000 in the URL, 471 00:26:42,240 --> 00:26:43,960 and reference it via JavaScript. 472 00:26:44,500 --> 00:26:50,060 So now, if somebody W gets our evil JavaScript, 473 00:26:50,140 --> 00:26:52,760 but doesn't save the URL that they downloaded it from, 474 00:26:52,760 --> 00:26:54,080 they can't decrypt it. 475 00:26:56,320 --> 00:26:58,240 And using this, a simple XOR is enough 476 00:26:58,240 --> 00:27:00,020 to beat all the AVs, all the nids. 477 00:27:00,900 --> 00:27:02,960 And the best part is, if they figure it out, 478 00:27:03,060 --> 00:27:04,580 it's really easy to just make it better, 479 00:27:05,040 --> 00:27:07,480 and, you know, use RC4 instead of XOR, 480 00:27:07,580 --> 00:27:08,920 or use something like that. 481 00:27:11,080 --> 00:27:13,780 The problem is, this is sort of a DRM solution. 482 00:27:14,300 --> 00:27:15,820 You know, we have to have the key 483 00:27:15,820 --> 00:27:19,160 on the client side someplace for the, 484 00:27:20,380 --> 00:27:21,720 so it can be unencrypted, 485 00:27:21,720 --> 00:27:24,900 and so that it can run our evil. 486 00:27:27,280 --> 00:27:28,560 I think that's okay, though. 487 00:27:30,060 --> 00:27:31,520 So now I'm going to try some demonstrations, 488 00:27:31,620 --> 00:27:34,940 and I hope they don't break. 489 00:27:40,340 --> 00:27:45,120 So first, we've got several, 490 00:27:45,660 --> 00:27:47,080 let me cat that file. 491 00:27:51,720 --> 00:27:55,200 First, we've got several actions with browser Autopwn. 492 00:27:55,400 --> 00:27:57,100 The first is defanged detection. 493 00:27:57,540 --> 00:28:01,900 And all this does is show which browser 494 00:28:01,900 --> 00:28:03,320 is connecting up to you. 495 00:28:03,480 --> 00:28:06,880 And all of this shows up on the browser itself. 496 00:28:07,140 --> 00:28:08,620 So this is not something you'd want to do 497 00:28:08,620 --> 00:28:09,440 in an actual engagement. 498 00:28:10,320 --> 00:28:14,400 But it's useful for making sure all the detection works. 499 00:28:16,360 --> 00:28:19,600 And it stores it all in a database for us. 500 00:28:19,600 --> 00:28:21,620 So we can see we set up a database. 501 00:28:22,620 --> 00:28:23,760 We set our serve port, 502 00:28:24,000 --> 00:28:26,660 which is where the browser will connect to. 503 00:28:27,320 --> 00:28:28,540 Setting debug equals true 504 00:28:29,920 --> 00:28:31,400 doesn't randomize any of the JavaScript, 505 00:28:31,540 --> 00:28:33,280 and it prints more stuff. 506 00:28:33,420 --> 00:28:35,460 So we can see exactly what's going on. 507 00:28:38,220 --> 00:28:41,520 So the first step here is fire up IE6. 508 00:28:45,460 --> 00:28:46,400 Hey, look at that. 509 00:28:46,480 --> 00:28:48,760 We know that it's IE6 on XP. 510 00:28:48,760 --> 00:28:50,160 Service pack zero. 511 00:28:50,780 --> 00:28:51,300 English. 512 00:28:52,380 --> 00:28:53,700 On an x86 architecture. 513 00:28:54,660 --> 00:28:55,460 It's IE. 514 00:28:56,060 --> 00:28:57,280 And it's 6.0. 515 00:28:58,080 --> 00:28:59,960 So all of that is pretty straightforward. 516 00:29:00,300 --> 00:29:00,940 Fairly simple. 517 00:29:04,660 --> 00:29:07,700 Now Firefox from the same box. 518 00:29:08,080 --> 00:29:10,360 Now I think this is interesting because 519 00:29:10,980 --> 00:29:12,320 since I'm using VirtualBox, 520 00:29:12,580 --> 00:29:14,340 it appears to browser Autopwn that everybody 521 00:29:14,340 --> 00:29:15,860 is coming from the same IP address. 522 00:29:16,240 --> 00:29:17,000 I'm natting through. 523 00:29:17,220 --> 00:29:18,520 So it looks like all of these 524 00:29:18,760 --> 00:29:20,080 browsers are coming from the same IP address. 525 00:29:20,640 --> 00:29:23,080 The difference is at this point 526 00:29:23,080 --> 00:29:25,880 that they've got different user agents. 527 00:29:26,780 --> 00:29:27,220 So... 528 00:29:34,000 --> 00:29:36,380 And we can see here it's Windows XP. 529 00:29:36,760 --> 00:29:38,940 We can't figure out the service pack level 530 00:29:38,940 --> 00:29:41,000 on Firefox, but that's okay. 531 00:29:41,360 --> 00:29:42,820 Because we still know that it's Firefox 532 00:29:42,820 --> 00:29:44,000 and we know that it's 1.0. 533 00:29:45,720 --> 00:29:46,500 Close that guy. 534 00:29:50,340 --> 00:29:51,960 See if we can have two versions of Firefox 535 00:29:51,960 --> 00:29:52,640 at the same time. 536 00:29:53,000 --> 00:29:53,900 Yeah, yeah, shut up. 537 00:29:59,140 --> 00:29:59,940 So here we go. 538 00:30:01,060 --> 00:30:01,780 Same thing. 539 00:30:01,880 --> 00:30:02,500 Windows XP. 540 00:30:03,120 --> 00:30:04,200 Firefox 3.5. 541 00:30:07,220 --> 00:30:08,820 Where is my user agent switcher? 542 00:30:09,340 --> 00:30:09,980 There we go. 543 00:30:12,280 --> 00:30:13,280 This I think is fun. 544 00:30:16,040 --> 00:30:17,460 Now we've changed our user agent. 545 00:30:17,460 --> 00:30:19,100 We look exactly like IE did. 546 00:30:20,400 --> 00:30:20,900 Right? 547 00:30:21,260 --> 00:30:22,220 Same user agent. 548 00:30:22,840 --> 00:30:23,600 Different detection. 549 00:30:23,860 --> 00:30:25,080 This is Firefox 3.5. 550 00:30:34,100 --> 00:30:36,000 Opera, for some strange reason, 551 00:30:36,040 --> 00:30:37,260 runs all my JavaScript twice. 552 00:30:37,420 --> 00:30:38,000 Thank you. 553 00:30:41,540 --> 00:30:43,980 So it's not exactly the same user agent. 554 00:30:44,100 --> 00:30:46,280 We've got this little EN tacked on to the end. 555 00:30:46,280 --> 00:30:49,460 But it's very similar to the Internet Explorer 556 00:30:49,460 --> 00:30:50,840 user agent we saw earlier. 557 00:30:51,080 --> 00:30:52,220 I still know it's Opera. 558 00:30:52,420 --> 00:30:53,560 I still know it's 9.0. 559 00:30:55,320 --> 00:30:56,280 So all that's fun. 560 00:30:58,600 --> 00:30:59,900 We can also do it. 561 00:30:59,940 --> 00:31:00,640 Yeah, yeah, go away. 562 00:31:02,540 --> 00:31:04,060 P-A-S-S. 563 00:31:22,860 --> 00:31:24,960 Again, it looks like it's coming from the same box. 564 00:31:26,040 --> 00:31:28,040 Because it's virtual box, everything looks like it's 565 00:31:28,040 --> 00:31:28,980 coming from the same IP address. 566 00:31:29,440 --> 00:31:32,560 So browser autopone can't tell them apart based on the IP. 567 00:31:33,300 --> 00:31:35,380 But we've got this same exact user agent string. 568 00:31:35,880 --> 00:31:37,180 Coming from the same IP address. 569 00:31:37,400 --> 00:31:38,320 Now I know it's Linux. 570 00:31:38,720 --> 00:31:40,100 And I know that it's 9.60. 571 00:31:52,820 --> 00:31:53,880 So now for the fun stuff. 572 00:32:10,180 --> 00:32:12,980 I have to wait here while all of our exploits run. 573 00:32:18,220 --> 00:32:19,240 12 modules found. 574 00:32:26,140 --> 00:32:27,300 Hey, that one gave us a shell. 575 00:32:31,720 --> 00:32:32,080 Woot. 576 00:32:50,000 --> 00:32:51,120 Hey, that one gave us a shell, too. 577 00:32:56,780 --> 00:32:57,040 Woot. 578 00:33:06,460 --> 00:33:06,980 Stupid port. 579 00:33:21,380 --> 00:33:22,980 You know you want to give me a shell. 580 00:33:26,220 --> 00:33:26,600 Ah. 581 00:33:37,060 --> 00:33:38,920 I knew I should have sacrificed the goat. 582 00:33:42,380 --> 00:33:43,300 So that's that. 583 00:33:45,300 --> 00:33:46,200 I'll try this again. 584 00:33:46,200 --> 00:33:47,980 I lost my place. 585 00:33:48,140 --> 00:33:49,000 Thank you, open office. 586 00:33:52,760 --> 00:33:53,200 Go. 587 00:33:57,240 --> 00:33:58,260 So I hope that worked. 588 00:33:58,420 --> 00:33:59,000 It mostly did. 589 00:34:01,840 --> 00:34:05,460 Now how do we go from seeing all of that cool stuff to 590 00:34:05,460 --> 00:34:08,300 making your Oday work with Metasploit and using browser 591 00:34:08,300 --> 00:34:08,760 autopone? 592 00:34:10,200 --> 00:34:11,760 And we have to wait for open office. 593 00:34:11,920 --> 00:34:12,200 Thank you. 594 00:34:13,060 --> 00:34:13,680 Keep going. 595 00:34:13,820 --> 00:34:14,180 Come on. 596 00:34:15,380 --> 00:34:16,540 You can do it. 597 00:34:18,880 --> 00:34:20,680 Maybe I should have turned those virtual machines off. 598 00:34:23,780 --> 00:34:24,540 Do I get a mouse? 599 00:34:24,700 --> 00:34:25,520 Yay, I got a mouse. 600 00:34:25,620 --> 00:34:26,160 Let's try this. 601 00:34:27,580 --> 00:34:27,940 Woot. 602 00:34:29,780 --> 00:34:33,360 So it's relatively easy to write exploits for this framework now. 603 00:34:33,460 --> 00:34:36,800 All we have to do is add this little autopone info call to the top of the 604 00:34:36,800 --> 00:34:37,340 exploit class. 605 00:34:38,140 --> 00:34:41,820 We have a UA name, which tells us which browser this is going to work 606 00:34:41,820 --> 00:34:42,120 against. 607 00:34:42,320 --> 00:34:44,160 We have VonTest, which is a piece of code that we're going to be using 608 00:34:44,160 --> 00:34:50,160 JavaScript to run before we determine that this exploit will work, unless it's ActiveX. 609 00:34:50,380 --> 00:34:52,740 And we'll talk about the difference there in a second. 610 00:34:52,960 --> 00:34:58,000 But all of the information that you need to go into VonTest comes from the exploit anyway. 611 00:34:58,300 --> 00:35:02,960 Everything in there is stuff that you already had to know to make the exploit work. 612 00:35:04,340 --> 00:35:07,200 So here's an example with Mozilla Navigator Java. 613 00:35:07,720 --> 00:35:14,000 You have to have Java installed, which we can determine based on the existence of Java 614 00:35:14,160 --> 00:35:19,760 enabled, and you have to have Java enabled, so we check to make sure that it is. 615 00:35:20,160 --> 00:35:23,640 And if that is true, then we're good to go and go ahead and try this exploit. 616 00:35:24,940 --> 00:35:27,020 Note also that we've got a rank here. 617 00:35:28,140 --> 00:35:35,060 This tells us, well, that was a terrible drawing, but this tells us what kind of exploit it is. 618 00:35:35,140 --> 00:35:37,520 If it's a reliable exe writer, it goes first. 619 00:35:37,800 --> 00:35:44,140 We want to sort things by how likely they are or how unlikely they are to crash the 620 00:35:44,160 --> 00:35:44,360 browser. 621 00:35:44,640 --> 00:35:48,080 It's much better for us if we can just get a shell without ever alerting the user. 622 00:35:48,220 --> 00:35:49,180 So we try those things first. 623 00:35:51,780 --> 00:35:54,180 Here's an example with an ActiveX control. 624 00:35:54,380 --> 00:36:05,220 The venerable MSO 6067 keyframe pioneered the heap feng shui technique by Alexander Sautereau. 625 00:36:05,260 --> 00:36:05,860 That guy's a pimp. 626 00:36:07,080 --> 00:36:12,120 But the VonTest here is a method in the... 627 00:36:13,140 --> 00:36:15,300 In that ActiveX object. 628 00:36:16,140 --> 00:36:18,340 And the class ID is the class name. 629 00:36:19,120 --> 00:36:23,720 So as long as we know those two things, we can determine whether all of that stuff is going to work. 630 00:36:25,700 --> 00:36:31,560 This is a similar chunk of code, but it's for a completely different exploit. 631 00:36:32,420 --> 00:36:35,420 Using a class ID instead of a class name. 632 00:36:35,640 --> 00:36:38,920 We still have to know the method name to try. 633 00:36:39,780 --> 00:36:42,100 But all of that is contained in the exploit anyway. 634 00:36:43,460 --> 00:36:44,940 So here's a quick summary. 635 00:36:45,600 --> 00:36:47,260 We've got reliable target acquisition. 636 00:36:48,000 --> 00:36:51,280 We can reliably determine who our client is. 637 00:36:51,740 --> 00:36:53,600 What operating system they're running on. 638 00:36:53,800 --> 00:36:55,360 And we've got smart missile detection. 639 00:36:55,720 --> 00:36:57,320 We only send exploits that might work. 640 00:36:57,780 --> 00:37:04,300 We don't send exploits that are more likely to crash or hang the browser or do a heap spray unnecessarily. 641 00:37:04,860 --> 00:37:07,560 Causing the user to potentially click away. 642 00:37:09,380 --> 00:37:12,380 We're stealthy in the sense that it's difficult for AV to detect us. 643 00:37:12,580 --> 00:37:14,240 And it's really easy to write new exploits. 644 00:37:15,200 --> 00:37:17,540 All of our detection results are stored in a database. 645 00:37:19,200 --> 00:37:25,740 And so you can potentially take this and tie it with a bunch of statistical stuff and make it better. 646 00:37:28,280 --> 00:37:34,540 There's also a number of exploit packs out in the wild. 647 00:37:35,480 --> 00:37:37,140 Available for commercial purchase. 648 00:37:37,140 --> 00:37:41,680 But most of these come from places that don't have extradition treaties with the US. 649 00:37:41,980 --> 00:37:46,120 And they're kind of difficult to get. 650 00:37:46,300 --> 00:37:47,520 And so I'll talk about them briefly. 651 00:37:48,760 --> 00:37:51,880 Impact and firepack are sort of related. 652 00:37:52,040 --> 00:37:53,280 They use a lot of the same code. 653 00:37:53,400 --> 00:37:54,520 They're not exactly the same. 654 00:37:54,600 --> 00:37:58,920 But they either had a common ancestor or somebody stole some shit. 655 00:38:02,280 --> 00:38:04,120 They're mostly old exploits though. 656 00:38:04,240 --> 00:38:06,140 And all of their detection is server side. 657 00:38:06,140 --> 00:38:07,600 So it's much less reliable than mine. 658 00:38:07,740 --> 00:38:12,460 And it's really difficult to change or add new exploits to their pack. 659 00:38:13,280 --> 00:38:15,060 Part of that is because it's written in PHP. 660 00:38:15,300 --> 00:38:16,360 And PHP sucks. 661 00:38:18,260 --> 00:38:22,920 They also use a similar obfuscation and XOR technique. 662 00:38:23,620 --> 00:38:24,860 But mine is better. 663 00:38:27,980 --> 00:38:32,560 Neosploit is sort of an oddity among exploit packs. 664 00:38:32,800 --> 00:38:33,960 It's an elf. 665 00:38:34,040 --> 00:38:34,980 It's compiled binary. 666 00:38:34,980 --> 00:38:36,160 And it runs as a CGI. 667 00:38:37,180 --> 00:38:40,360 So getting a hold of the source code proved to be pretty difficult. 668 00:38:40,520 --> 00:38:44,060 And I never actually found someone who had the source code. 669 00:38:45,860 --> 00:38:49,480 And unless you've got that source code or you do some serious reverse engineering, 670 00:38:50,660 --> 00:38:52,680 you won't really know what it does. 671 00:38:52,880 --> 00:38:57,520 And I don't think as a penetration tester it's a good idea to run code when you don't know what it does. 672 00:39:01,440 --> 00:39:03,620 LuckySploit is pretty incredible. 673 00:39:03,620 --> 00:39:06,760 It runs real crypto in JavaScript. 674 00:39:07,180 --> 00:39:11,360 They implemented RSA and they implemented RC4 in JavaScript. 675 00:39:11,860 --> 00:39:12,740 Holy crap. 676 00:39:15,140 --> 00:39:17,300 Unfortunately, it's still really hard to get. 677 00:39:17,700 --> 00:39:24,440 And the legitimate way of getting any of these exploit packs is to send $4,000 to some dude in Russia. 678 00:39:25,380 --> 00:39:26,100 Really? 679 00:39:27,600 --> 00:39:28,820 No thanks. 680 00:39:28,820 --> 00:39:28,980 Thanks. 681 00:39:31,840 --> 00:39:34,160 In contrast, Browser Autopone is awesome. 682 00:39:40,100 --> 00:39:41,500 It's easy to write new exploits. 683 00:39:41,500 --> 00:39:43,460 It's easy to take out the old ones if you don't like them. 684 00:39:43,620 --> 00:39:49,060 There's an option that I didn't really talk about called exclude in the advanced options. 685 00:39:49,300 --> 00:39:52,220 You can just type show advanced and you'll see exclude and match. 686 00:39:53,500 --> 00:39:58,800 And exclude is a regular expression that if any exploit name matches that regular expression, 687 00:39:58,800 --> 00:40:01,600 then it won't try to run that exploit. 688 00:40:02,320 --> 00:40:03,640 Match is the opposite of that. 689 00:40:04,720 --> 00:40:10,880 If any exploit name doesn't match, it'll run. 690 00:40:11,320 --> 00:40:13,000 Or it won't run. 691 00:40:13,660 --> 00:40:14,660 You know what I mean. 692 00:40:16,460 --> 00:40:18,060 One of the best parts is that it's free. 693 00:40:18,260 --> 00:40:20,280 It's a three clause BSD license. 694 00:40:20,580 --> 00:40:22,900 Take it, use it, sell it. 695 00:40:23,000 --> 00:40:23,500 I don't care. 696 00:40:24,240 --> 00:40:27,220 I would prefer if you'd give me some credit. 697 00:40:27,400 --> 00:40:28,680 And I would prefer if... 698 00:40:28,680 --> 00:40:30,900 You would give back. 699 00:40:31,120 --> 00:40:34,400 If you take my framework and make it awesome, 700 00:40:34,620 --> 00:40:35,920 I want to make it awesome too. 701 00:40:36,120 --> 00:40:37,000 So please give me patches. 702 00:40:37,880 --> 00:40:40,760 However, it's BSD so really do whatever you want. 703 00:40:41,860 --> 00:40:44,380 Another big advantage is that it's not written in PHP. 704 00:40:45,260 --> 00:40:46,100 PHP is stupid. 705 00:40:49,380 --> 00:40:51,320 All of my OS and client detection... 706 00:40:51,320 --> 00:40:54,860 Well, almost all of my OS and client detection is client side. 707 00:40:55,680 --> 00:40:59,540 So I don't have to rely on something that can easily lie. 708 00:41:00,660 --> 00:41:05,180 And it works better in the case of a spoofed or borked UA. 709 00:41:05,380 --> 00:41:12,720 So there are third party tools in Windows that will change the Internet Explorer user agent. 710 00:41:13,420 --> 00:41:15,700 And some of them actually break it. 711 00:41:15,860 --> 00:41:18,540 Like, thank you, whatever. 712 00:41:20,660 --> 00:41:24,480 They'll try to insert their own little string in there saying, 713 00:41:24,480 --> 00:41:27,860 Internet Explorer plus some super hootie widget. 714 00:41:28,320 --> 00:41:31,840 Well, super hootie widget puts their string in there and it breaks the user agent. 715 00:41:32,080 --> 00:41:35,900 And then nobody can tell what's going on unless you use my detection methods. 716 00:41:38,260 --> 00:41:39,920 So some of the things I'd like to make better. 717 00:41:40,100 --> 00:41:44,700 The payload selection right now is sort of limited. 718 00:41:45,780 --> 00:41:51,860 Basically, if the exploit is a Windows-only exploit, I always use Meterpreter. 719 00:41:52,400 --> 00:41:54,140 If it's not, 720 00:41:54,480 --> 00:41:57,120 if it can be a Windows or a Linux or whatever. 721 00:41:57,380 --> 00:42:00,060 So, for example, most of the Firefox exploits are this way. 722 00:42:00,220 --> 00:42:01,520 We always use a command shell. 723 00:42:01,860 --> 00:42:04,460 That's kind of a bummer because most of the time I'd rather have Meterpreter. 724 00:42:05,080 --> 00:42:11,780 Fortunately, a lot of really smart people are coming together and trying to write Meterpreter for POSIX. 725 00:42:12,140 --> 00:42:16,760 And once that happens, we'll have a generic payload for everybody that's Meterpreter. 726 00:42:17,100 --> 00:42:18,720 And Meterpreter is freaking cool. 727 00:42:18,900 --> 00:42:20,140 It's much better than a command shell. 728 00:42:20,420 --> 00:42:21,100 CMD sucks. 729 00:42:21,100 --> 00:42:25,820 And I would much rather be able to upload files and all of that stuff. 730 00:42:27,320 --> 00:42:30,120 And another problem is stopping when you get a shell. 731 00:42:30,440 --> 00:42:32,980 This might be really difficult. 732 00:42:33,540 --> 00:42:37,400 In the presence of NAT and proxies, everybody comes from the same IP address. 733 00:42:38,440 --> 00:42:42,380 One of the thoughts I had was making everything a download exec payload. 734 00:42:42,600 --> 00:42:49,760 And then I can have all of the browser autopone stuff determine 735 00:42:49,760 --> 00:42:51,920 which payload gets run. 736 00:42:52,100 --> 00:42:59,020 And so I can set a unique ID for each host in the download part of that download exec. 737 00:43:00,120 --> 00:43:05,760 The part that sucks about that is we end up with EXEs on the target. 738 00:43:05,900 --> 00:43:06,780 And that's not cool. 739 00:43:06,840 --> 00:43:08,400 I'd much rather be in memory if we can do it. 740 00:43:14,900 --> 00:43:18,420 I'd also like to make the JavaScript obfuscation a little bit easier to use. 741 00:43:18,420 --> 00:43:23,680 Right now, you have to, at code writing time, 742 00:43:23,820 --> 00:43:27,620 you have to know the names of all of the identifiers that you want randomized. 743 00:43:29,160 --> 00:43:30,180 That's kind of a bummer. 744 00:43:30,300 --> 00:43:33,480 But getting around that basically means I have to write a JavaScript compiler. 745 00:43:33,740 --> 00:43:35,300 And crap. 746 00:43:35,520 --> 00:43:36,420 I don't want to do that. 747 00:43:39,200 --> 00:43:43,320 Another fun thing is a standard called UAProf for mobile devices. 748 00:43:43,600 --> 00:43:47,940 And it allows very fine-grained control. 749 00:43:47,940 --> 00:43:49,340 Or very fine-grained detection. 750 00:43:49,700 --> 00:43:55,600 And advertisement of things that a mobile device can do. 751 00:43:56,060 --> 00:43:58,980 So this thing can send SMS and yada, yada, yada. 752 00:43:59,740 --> 00:44:00,980 I would like to integrate that. 753 00:44:01,240 --> 00:44:04,220 But we don't really have many exploits for mobile devices yet. 754 00:44:04,280 --> 00:44:05,700 So it's not a high priority. 755 00:44:06,080 --> 00:44:07,960 I'd also like to integrate it with Metafish. 756 00:44:08,460 --> 00:44:15,320 Metafish is a really freaking cool tool put together by Val Smith, Colin Ames, and Dave Kerb. 757 00:44:15,440 --> 00:44:17,520 And you should check out their talk later today. 758 00:44:19,260 --> 00:44:23,020 Basically going all the way from email to shell in one tool. 759 00:44:23,480 --> 00:44:24,320 Totally awesome. 760 00:44:25,580 --> 00:44:26,900 So you can download it here. 761 00:44:27,240 --> 00:44:28,300 Please submit patches. 762 00:44:28,560 --> 00:44:29,400 I love patches. 763 00:44:31,280 --> 00:44:31,960 Thank you. 764 00:44:43,440 --> 00:44:46,320 And I'm going to be in Q&A room two. 765 00:44:46,440 --> 00:44:47,800 If you have any questions. 766 00:44:47,800 --> 00:44:48,340 Take them there.