1 00:00:00,000 --> 00:00:01,560 My name is Toby, this is Mickey. 2 00:00:01,560 --> 00:00:03,780 We're glad you could make it this morning. 3 00:00:04,160 --> 00:00:05,960 We're going to talk to you about Windows gadgets. 4 00:00:09,280 --> 00:00:17,160 First, our standard disclaimer, none of this has anything to do with anyone we've ever worked for, do work for or might ever work for in the future. 5 00:00:17,160 --> 00:00:18,160 We have our own opinions. 6 00:00:18,160 --> 00:00:24,000 They have no opinions about anything and the two connections aren't connected in absolutely no way, shape or form. 7 00:00:24,000 --> 00:00:27,760 They have no knowledge of anything we do ever and they're not even sure we exist. 8 00:00:33,280 --> 00:00:38,120 Well, aside from not being sure that I exist, my name is Toby. 9 00:00:38,120 --> 00:00:42,280 I'm a senior info sec geek for a Fortune 50 company. 10 00:00:42,280 --> 00:00:51,960 I do all sorts of things that mostly involve telling people their ideas are bad and then trying to keep their ideas from being compromised once they insist on doing them anyways. 11 00:00:54,880 --> 00:00:57,040 And an opinion in a loud mouth. 12 00:00:57,920 --> 00:00:59,620 That too, you forgot to say that. 13 00:01:00,200 --> 00:01:01,280 My name is Mickey. 14 00:01:01,280 --> 00:01:03,520 I used to work for a Fortune 50 company. 15 00:01:04,740 --> 00:01:11,100 I used to break software firmware and hardware in my spare time and well, that's it basically. 16 00:01:19,260 --> 00:01:22,660 We're going to keep do-si-do-ing because we don't have wireless mics. 17 00:01:23,780 --> 00:01:25,680 Excuse us for being a bit rough this morning. 18 00:01:25,680 --> 00:01:27,500 Today we're going to go through a bunch of different things. 19 00:01:27,500 --> 00:01:28,920 First we're going to spend some little time. 20 00:01:28,920 --> 00:01:30,040 We've already talked about who we are. 21 00:01:30,040 --> 00:01:31,940 We're going to talk about what gadgets are. 22 00:01:32,100 --> 00:01:34,920 By the way, you all know we're talking about Windows gadgets, right? 23 00:01:35,280 --> 00:01:35,620 Yeah? 24 00:01:35,620 --> 00:01:36,160 We're good? 25 00:01:36,160 --> 00:01:36,660 Okay. 26 00:01:37,540 --> 00:01:40,220 We're going to tell you a little bit about what Windows gadgets are. 27 00:01:40,320 --> 00:01:42,640 A little history, little details about them. 28 00:01:42,640 --> 00:01:44,140 Then we're going to go into what's wrong with them. 29 00:01:44,140 --> 00:01:48,480 We're going to talk about first attacking with gadgets and then we're going to talk about how you can attack gadgets. 30 00:01:48,880 --> 00:01:56,640 Then we'll spend a little bit of time talking about once it's all done what you can do about it and what the solutions are. 31 00:01:56,640 --> 00:02:00,720 Long term, short term solutions that Microsoft chose and otherwise. 32 00:02:08,100 --> 00:02:18,780 A couple of thank yous because this talk is based on civil things made by other people. 33 00:02:19,920 --> 00:02:21,600 And the support of other people. 34 00:02:21,600 --> 00:02:34,140 So I'd like to thank Ethics, Ian, Jason Street, SoftSec folks, Wim, Aviv, Raph, Galdiskin, and Suzuki, Sal, Mitsuki, Mitku, I don't think I pronounced that. 35 00:02:34,200 --> 00:02:38,440 But they helped us a lot with their work. 36 00:02:42,920 --> 00:02:45,360 Also, CG, or not. 37 00:02:45,600 --> 00:02:46,980 I guess we'll use that. 38 00:02:49,460 --> 00:02:50,800 We apologize. 39 00:02:50,800 --> 00:02:54,180 Clearly technology is complex and we're not very good at it. 40 00:02:54,580 --> 00:03:05,720 Also, CG from Carnal Ownage blog for his work on PowerShell bypass, PowerShell Metasploit, and just being a lot of fun to read. 41 00:03:09,140 --> 00:03:14,400 So for those of you who don't own Windows systems, what are gadgets? 42 00:03:14,400 --> 00:03:20,120 Gadgets are those tiny little applications you have on your desktop and you do a right click and it's like gadgets. 43 00:03:20,580 --> 00:03:28,420 You can use gadgets that range from a simple clock up to GPU performance handlers. 44 00:03:29,480 --> 00:03:34,020 They're very simple to use. 45 00:03:34,760 --> 00:03:36,200 A couple of examples on screen. 46 00:03:36,200 --> 00:03:38,600 Those are the default Microsoft gadgets. 47 00:03:38,740 --> 00:03:43,540 The CPU clock, the RSS feed, and the weather. 48 00:03:47,680 --> 00:03:49,920 A little history about gadgets. 49 00:03:49,920 --> 00:03:55,660 The first references we've actually seen documented were to show the active desktop in Windows XP. 50 00:03:55,940 --> 00:04:09,360 Over the course of the last week or so, we've had a couple of people mention that they remember seeing similar things that there was actually an active desktop in 98 as well, but we weren't able to find any traces of it or any documentation on it. 51 00:04:09,360 --> 00:04:14,640 So the first thing that we've seen from Windows XP is the concept of the active desktop. 52 00:04:14,720 --> 00:04:20,280 You could just basically run little tiny things on the desktop and get dynamic updates. 53 00:04:20,280 --> 00:04:21,700 It was fairly simple. 54 00:04:21,780 --> 00:04:26,720 In Vista, they started moving around, moving to the concept of actually having something called a gadget. 55 00:04:26,720 --> 00:04:28,040 They had the sidebar. 56 00:04:28,400 --> 00:04:29,680 It was fairly simple. 57 00:04:29,680 --> 00:04:30,980 We'll show you in half a second . 58 00:04:30,980 --> 00:04:33,100 It looked like this. 59 00:04:33,560 --> 00:04:35,240 Literally it was just a sidebar. 60 00:04:35,240 --> 00:04:40,900 All of the things ran along it and were very tightly tied to it , but they were referred to as gadgets. 61 00:04:41,600 --> 00:04:47,940 In Windows 7, they actually did a significant number of improvements to the capabilities . 62 00:04:47,940 --> 00:04:50,580 First, they combined it to a single process. 63 00:04:51,100 --> 00:04:53,540 They made it much easier to manage them. 64 00:04:54,780 --> 00:04:57,100 They could be placed all over the desktop. 65 00:04:57,100 --> 00:05:05,900 They also added a number of new capabilities to make it easier to develop and they added a bunch of enterprise security features. 66 00:05:06,520 --> 00:05:09,280 The development points are obviously irrelevant at this point. 67 00:05:10,060 --> 00:05:14,460 So Windows Vista, this is what it looked in Windows 7. 68 00:05:15,200 --> 00:05:18,600 We're actually both quite fond of the Pandora gadget. 69 00:05:18,600 --> 00:05:23,360 It's a fairly handy thing to have and it's literally just a way to listen to Pandora on the system. 70 00:05:23,360 --> 00:05:26,500 I think I was listening to Wien at that time. 71 00:05:28,020 --> 00:05:31,160 But these are some other examples besides the ones you saw previously. 72 00:05:35,240 --> 00:05:38,260 So the question is, why does this matter? 73 00:05:38,720 --> 00:05:43,100 To be quite honest, Mickey came to me and said, we should do this. 74 00:05:43,100 --> 00:05:45,540 And I said, why would anyone care? 75 00:05:45,580 --> 00:05:51,260 It took him about three weeks to convince me. 76 00:05:53,120 --> 00:05:54,860 Yeah, you tell me. 77 00:05:55,960 --> 00:05:58,260 About three weeks to convince me to do the research. 78 00:05:58,260 --> 00:06:01,780 And frankly, it's not news. 79 00:06:01,780 --> 00:06:05,180 If you write bad code, you're going to get compromised, right? 80 00:06:05,500 --> 00:06:11,720 If you run somebody else's code on your system, they're going to compromise you, right? 81 00:06:11,720 --> 00:06:13,660 This isn't novel. 82 00:06:14,420 --> 00:06:29,060 Turns out, though, the same issues that made this an actual interesting target and a problem are being moved forward consistently as a clear and enthusiastic business model. 83 00:06:29,060 --> 00:06:38,720 We're seeing everything being done by vendors to try and make it easier and easier for people who have less and less experience and knowledge about development to actually do development. 84 00:06:38,720 --> 00:06:53,620 And so the sorts of mistakes that we found and that we were able to exploit and take advantage of on these systems are going to continue being common as long as you can do something as silly as write an entire application in JavaScript and HTML. 85 00:06:58,580 --> 00:07:01,100 So a little bit of what is a gadget. 86 00:07:01,100 --> 00:07:03,520 A gadget is a zip file. 87 00:07:04,940 --> 00:07:08,860 Technically, it's a zip file renamed to be .gadget. 88 00:07:08,980 --> 00:07:11,520 If you didn't get that, that's cat.zip. 89 00:07:18,010 --> 00:07:21,190 A gadget has several screens on it. 90 00:07:22,250 --> 00:07:30,190 The main one, which you see when you use a gadget, there is an about, a fly out, and a setting screen. 91 00:07:30,190 --> 00:07:32,830 As you can see, they have correlating HTML files. 92 00:07:32,830 --> 00:07:40,890 This is, by the way, the simplest directory structure for a gadget. 93 00:07:40,890 --> 00:07:46,850 You've got a CSS folder, images folder, JavaScript folder, a couple of HTML files. 94 00:07:46,850 --> 00:07:52,930 This is, sorry, this is NeonCAD gadget, which you'll see soon enough. 95 00:07:54,230 --> 00:08:00,330 The part that is not standard is the gadget.xml, which is the gadget manifest. 96 00:08:00,330 --> 00:08:15,490 It holds the information on a gadget , manufacturer, copyright, URLs, permission level, which is always set to full and is expected to be full by Microsoft for some reason. 97 00:08:16,910 --> 00:08:20,650 And, well, did I forget anything? 98 00:08:20,650 --> 00:08:22,510 It can get simpler. 99 00:08:23,310 --> 00:08:27,010 This is the template. 100 00:08:27,010 --> 00:08:28,510 This is the HTML template. 101 00:08:28,510 --> 00:08:35,150 But you can also develop gadgets with silver light, so it's even more simpler. 102 00:08:35,310 --> 00:08:36,690 It's simpler. 103 00:08:37,950 --> 00:08:40,930 English is not my first language, I apologize. 104 00:08:42,190 --> 00:08:47,990 WPF and silver light will make it easier to code malicious code into your gadget. 105 00:08:51,600 --> 00:08:54,800 So a little bit about the security model. 106 00:08:55,100 --> 00:08:58,220 Microsoft actually provides a very detailed explanation. 107 00:08:58,220 --> 00:09:14,160 We were surprised by how much effort Microsoft has put in to documenting the security model and to documenting good security practices for writing gadgets, especially considering the general lack of security quality we found in the development of gadgets. 108 00:09:15,800 --> 00:09:21,740 They didn't, for lack of trying, we didn't see quality for lack of Microsoft trying to do it right. 109 00:09:21,800 --> 00:09:25,460 What we're going to do though is we're going to call out some of the highlights of the security model. 110 00:09:26,160 --> 00:09:32,140 And if you want to see more, you can still find the documentation for it on Microsoft's site. 111 00:09:32,140 --> 00:09:33,760 There's a URL in the background. 112 00:09:34,820 --> 00:09:37,580 First, code signing is actually possible. 113 00:09:37,580 --> 00:09:39,000 It's not standard. 114 00:09:39,420 --> 00:09:40,620 It's not common. 115 00:09:40,620 --> 00:09:43,560 It isn't required, but it is absolutely possible. 116 00:09:44,240 --> 00:09:52,240 We saw out of 60 or 70 gadgets that we were able to pull down, one or two, maybe three. 117 00:09:52,980 --> 00:09:59,600 One single vendor and not very many gadgets from any vendor that were actually signed. 118 00:09:59,680 --> 00:10:05,380 The prompt looks pretty similar to the actual installation for any standard application. 119 00:10:05,380 --> 00:10:14,700 The action behind it is much less complex in that it's just dropping everything into a directory, but making a couple configuration changes, very small stuff. 120 00:10:14,700 --> 00:10:16,960 But as you can see, it looks pretty standard. 121 00:10:18,940 --> 00:10:23,980 Show of hands, who's familiar with an HTML application, HTAs? 122 00:10:24,360 --> 00:10:30,860 Show of hands, who can give me the square root of 1,563? 123 00:10:32,760 --> 00:10:35,680 Just checking that there was actually a difference in response. 124 00:10:38,080 --> 00:10:42,180 So, they're fairly similar to HTAs, HTML applications. 125 00:10:42,180 --> 00:10:51,520 There are some differences in that they still run in the local machine zone, but they have some additional privileges that you wouldn't otherwise be able to take advantage of. 126 00:10:51,520 --> 00:10:54,340 And they have some limitations that aren't always in place. 127 00:10:54,700 --> 00:11:02,020 First, one of the advantages and something we found tremendously useful, you can instantiate any active X object on the system. 128 00:11:02,420 --> 00:11:10,900 Doesn't matter what it's for, doesn't matter whether it's a reasonable or sane thing to be able to do from an HTML function, you can do it from here. 129 00:11:10,960 --> 00:11:13,800 However, you can't actually kick off a UAC prompt. 130 00:11:13,800 --> 00:11:21,460 Doesn't matter what privilege you're actually running as for the user, this is always going to run as a standard user, even if you're in the admin group. 131 00:11:22,280 --> 00:11:30,600 On the other hand, any process that's been exec'd from the gadget can then itself raise a UAC prompt. 132 00:11:30,600 --> 00:11:39,280 And since you can use, for instance, the active X shell.run function or shell.exec function, you can still pretty much do what you want from here. 133 00:11:39,280 --> 00:11:42,960 Parental controls do apply as you would expect for any HTML based thing. 134 00:11:42,960 --> 00:11:44,760 It's running in an IE container. 135 00:11:44,760 --> 00:11:48,520 It's just a modified set of permissions to do so. 136 00:11:49,600 --> 00:11:50,200 Anything? 137 00:11:50,200 --> 00:11:51,360 Want to add anything? 138 00:11:52,340 --> 00:12:00,560 Some of the enterprise features that were added in Windows 7, there are a couple of basic things that you can use, you do via GPO, you can manage them in a couple of different ways. 139 00:12:00,560 --> 00:12:03,480 One, you can turn off the sidebar completely as a function. 140 00:12:04,060 --> 00:12:12,940 Two, you can set policies to control unpacking and installing of Windows gadgets that aren't signed. 141 00:12:13,760 --> 00:12:17,260 Unfortunately, this doesn't actually prevent somebody from installing them manually. 142 00:12:17,660 --> 00:12:20,240 And it doesn't remove gadgets that have already been installed. 143 00:12:20,240 --> 00:12:25,160 It just prevents new ones from being automatically installed when they double click and want to run them. 144 00:12:25,940 --> 00:12:31,840 You can disable user installed gadgets which is basically just locking down the permissions for a specific directory. 145 00:12:32,080 --> 00:12:38,860 And finally, you can actually override the get more gadgets online link which is now dead anyways. 146 00:12:41,560 --> 00:12:48,320 So at this point, normally I know the standard is to ask questions at the end. 147 00:12:48,900 --> 00:12:54,440 Feel free though, does anyone have any questions about anything we've covered on the development side of it that you want to ask now? 148 00:12:56,080 --> 00:12:56,760 Yeah. 149 00:13:09,020 --> 00:13:13,240 The question was is there any concept of this moving to Windows 8. 150 00:13:13,240 --> 00:13:18,380 Do you mean is there anything being done in Windows 8 that has a similar sort of idea behind it? 151 00:13:18,860 --> 00:13:19,600 Okay. 152 00:13:21,280 --> 00:13:30,260 As far as I know, I guess since neither of these work for Microsoft, we can speculate wildly. 153 00:13:31,320 --> 00:13:43,280 But as far as we know, you've got the metro app store sort of thing that is similar, but it's wrapped in the app container capability which locks it down much, much more tightly. 154 00:13:43,960 --> 00:13:50,160 And I haven't looked at the development for the metro app so I don't know if you know anything about metro app. 155 00:13:52,340 --> 00:13:53,940 Any other questions? 156 00:13:56,740 --> 00:13:57,680 Yeah. 157 00:13:57,680 --> 00:13:57,680 Okay. 158 00:14:11,760 --> 00:14:19,820 I think the question was is Microsoft really going to remove gadgets from Windows 8 or something? 159 00:14:20,180 --> 00:14:21,980 Or are they going to make it optional? 160 00:14:21,980 --> 00:14:24,760 Our understanding is they removed the feature completely. 161 00:14:26,820 --> 00:14:28,260 Other questions? 162 00:14:31,260 --> 00:14:32,020 Okay. 163 00:14:35,300 --> 00:14:36,760 Attack surface. 164 00:14:36,760 --> 00:14:41,480 We're going to now go into a little bit of the attacking actually through gadgets and with gadgets. 165 00:14:42,120 --> 00:14:45,060 We're going to start off with attacking with gadgets. 166 00:14:45,060 --> 00:14:52,120 One of the fundamental problems here is that it's just another piece of code somebody is running. 167 00:14:52,640 --> 00:15:00,880 We've all known for 20 years that if you download and run someone's code, you're going to get compromised. 168 00:15:00,880 --> 00:15:02,500 That's what happens. 169 00:15:04,120 --> 00:15:08,780 Unfortunately people don't actually think of gadgets for some reason as code. 170 00:15:09,160 --> 00:15:10,860 We weren't quite sure why. 171 00:15:11,540 --> 00:15:16,860 Mickey speculated that it was because they're cute and small and run around with little hats and pants on all the time. 172 00:15:17,180 --> 00:15:18,760 So he took a picture of them. 173 00:15:20,400 --> 00:15:24,140 Honestly, they are just as dangerous as any other piece of software. 174 00:15:24,260 --> 00:15:26,040 So the question is what can you do with this? 175 00:15:26,040 --> 00:15:28,560 Well, is it really just another piece of software after all? 176 00:15:28,560 --> 00:15:30,320 It's just this little tiny container thing. 177 00:15:30,320 --> 00:15:32,780 It shouldn't have all the capabilities that you would expect. 178 00:15:33,200 --> 00:15:37,320 Here are some of the things that you're actually able to do from a gadget. 179 00:15:38,560 --> 00:15:40,740 I can't do everything I might want. 180 00:15:40,740 --> 00:15:42,940 Well, oh yes, wait a minute, I can. 181 00:15:42,940 --> 00:15:44,600 I can exec code. 182 00:15:44,840 --> 00:15:45,900 Do I need to say anything? 183 00:15:45,900 --> 00:15:50,360 Well, just in case anyone is curious, you can also open URLs. 184 00:15:51,040 --> 00:15:59,740 So if you didn't want to carry something with you in the HTML that you're downloading with the gadget, you can go get more. 185 00:15:59,800 --> 00:16:02,720 If you want to change what you downloaded, you can do that too. 186 00:16:02,720 --> 00:16:03,620 You want to update? 187 00:16:03,620 --> 00:16:04,640 No problem. 188 00:16:04,640 --> 00:16:08,660 You want to create files with arbitrary content, binary or otherwise on the system? 189 00:16:08,660 --> 00:16:09,680 We can do that. 190 00:16:09,720 --> 00:16:11,160 You want to be able to read files? 191 00:16:11,160 --> 00:16:13,840 Anything that the user has permission to, you're good for. 192 00:16:14,140 --> 00:16:19,860 And if you want to get past that permission, obviously you can just spawn something and raise the UAC prompt and do so. 193 00:16:19,940 --> 00:16:21,520 Make your computer speak? 194 00:16:21,780 --> 00:16:22,440 Sure. 195 00:16:22,620 --> 00:16:23,620 You can do that too. 196 00:16:23,920 --> 00:16:26,820 And I guess we should actually show you what that looks like. 197 00:16:27,180 --> 00:16:28,060 Want to run it? 198 00:17:03,340 --> 00:17:09,860 We're going to show you a little demonstration of what you can do with a malicious gadget. 199 00:17:13,800 --> 00:17:23,460 This is a POC of a gadget that will self-spread to all your contacts. 200 00:17:24,420 --> 00:17:28,720 It is not fully weaponized, it's just a POC. 201 00:17:30,300 --> 00:17:34,420 A little explanation, the gadget opens Gmail. 202 00:17:34,600 --> 00:17:40,540 Quick question, how many of you use Gmail? 203 00:17:41,940 --> 00:17:50,660 How many of you make sure you log out and stop using Gmail? 204 00:17:50,660 --> 00:17:53,920 Every single time? 205 00:17:54,700 --> 00:17:57,300 How many of you are lying? 206 00:18:00,060 --> 00:18:02,220 That's not good. 207 00:18:11,540 --> 00:18:19,940 Can we get sound from... okay. 208 00:18:21,760 --> 00:18:24,720 I apologize in advance. 209 00:18:25,140 --> 00:18:26,920 You should be so ashamed. 210 00:18:42,360 --> 00:18:45,880 Now we are back . 211 00:18:48,020 --> 00:18:49,840 Create a new email. 212 00:18:52,580 --> 00:18:54,160 Add a subject. 213 00:18:55,980 --> 00:18:57,540 Add a link. 214 00:19:00,020 --> 00:19:02,080 And we'll send it. 215 00:19:02,640 --> 00:19:05,340 And when it's done it will close the window. 216 00:19:11,630 --> 00:19:19,790 Now, just to clarify, first of all, I would like to stress that there is no security vulnerability in Gmail. 217 00:19:21,210 --> 00:19:23,970 It's kind of a work around for a setting. 218 00:19:24,190 --> 00:19:29,350 Gmail allows users to use keyboard shortcuts. 219 00:19:30,150 --> 00:19:36,850 And to enable that, usually what you do is go into settings and select an option saying enable keyboard shortcuts. 220 00:19:37,130 --> 00:19:45,410 However, if you open a URL with KBD equals 1 in the query string, you will get that feature enabled. 221 00:19:46,510 --> 00:19:50,610 And gadgets very easily send keystrokes to the screen. 222 00:19:50,610 --> 00:19:53,390 This is the code that sends the Gmail. 223 00:19:53,390 --> 00:19:55,050 Sixteen lines. 224 00:19:57,250 --> 00:19:59,190 That's how simple this is. 225 00:20:21,440 --> 00:20:26,600 So, simple example, you saw what can be done. 226 00:20:26,600 --> 00:20:29,880 Very standard malicious sort of gadget activity. 227 00:20:30,320 --> 00:20:39,700 The key is that it's got all of the access it needs to all of your cookies and all of the information in your browser, which means it also has your proxy configurations. 228 00:20:39,720 --> 00:20:42,480 It can manipulate anything else it wants on the system. 229 00:20:42,480 --> 00:20:46,300 It's got all of that state that you're giving it at any point in time. 230 00:20:49,740 --> 00:20:51,860 Another addition. 231 00:20:52,200 --> 00:21:01,900 We discovered also that gadgets can also read map network drives, delete map network drives, handle map network drives, add them. 232 00:21:04,940 --> 00:21:09,420 Everything that Windows supports, it can do, basically. 233 00:21:09,440 --> 00:21:14,420 We actually ran out of time to find out all of the things we kept finding. 234 00:21:14,420 --> 00:21:16,980 We tried something and say, oh, that's possible. 235 00:21:16,980 --> 00:21:19,180 How about, oh, that's possible. 236 00:21:19,500 --> 00:21:21,020 It just kept going. 237 00:21:22,880 --> 00:21:29,360 So, you've been something, we've talked about attacking with gadgets. 238 00:21:29,360 --> 00:21:30,480 Simple demo. 239 00:21:30,480 --> 00:21:32,640 Hopefully you understand it is just a POC. 240 00:21:32,820 --> 00:21:35,460 The question is now, what can you do in terms of attacking gadgets? 241 00:21:35,460 --> 00:21:37,500 Well, unfortunately, they're just code. 242 00:21:38,060 --> 00:21:43,060 And in many cases, they're written by people who don't have a lot of experience writing code. 243 00:21:43,060 --> 00:21:49,880 It was fairly interesting as we went through the collection of gadgets and we found about, is that a question? 244 00:21:50,500 --> 00:21:51,960 I'm going to attack? 245 00:21:52,580 --> 00:21:53,260 Okay. 246 00:21:54,440 --> 00:22:00,040 We found about 65, 70 gadgets that were floating around that people were actually using. 247 00:22:00,600 --> 00:22:16,260 And it was very easy to distinguish between the gadgets that were written by people who were used to doing development and they'd break it down as you'd expect with any developer in terms of having separate files for different function families and all sorts of clean object-oriented design and people who were used to doing web development, 248 00:22:16,260 --> 00:22:22,020 in which case you'd see one big HTML file that contained everything in the JavaScript. 249 00:22:22,020 --> 00:22:23,180 And you can do this. 250 00:22:23,180 --> 00:22:27,720 It's really just a web page to some extent that's running locally with a lot of extra privileges. 251 00:22:28,080 --> 00:22:31,260 So you'd see a lot of different styles. 252 00:22:31,260 --> 00:22:34,160 And of course, that leaves you with a lot of vulnerable systems. 253 00:22:34,240 --> 00:22:42,840 So you end up with a fairly basic strategy, which is just find some gadgets, analyze them, pause, and profit. 254 00:22:45,280 --> 00:22:46,720 So what did we find? 255 00:22:46,720 --> 00:22:52,260 Well, when you started looking around, we found a lot of sites offering malware that were claiming to be gadgets. 256 00:22:53,140 --> 00:23:02,160 We found a fair number of gadgets, but we found more in terms of total number of sites that were offering it, there was more malware out there than there were actual gadgets. 257 00:23:02,200 --> 00:23:05,160 We found really limited use of SSL. 258 00:23:05,160 --> 00:23:13,460 In fact, the only consistent cases that we found SSL being used were in the cases where the websites that were being connected to required it. 259 00:23:13,460 --> 00:23:15,360 Otherwise, they didn't use it. 260 00:23:15,360 --> 00:23:17,740 And we actually found a couple of interesting educations. 261 00:23:18,400 --> 00:23:19,900 You want to give them the rundown? 262 00:23:20,360 --> 00:23:21,140 Yeah. 263 00:23:23,720 --> 00:23:28,620 We saw one use, one good use of SSL in a gadget. 264 00:23:29,540 --> 00:23:39,440 But the funny thing was that the website hosting the file that was being accessed through SSL also hosted it in normal HTTP. 265 00:23:40,420 --> 00:23:43,960 So all you got to do is SSL strip and you win. 266 00:23:44,720 --> 00:23:47,320 And this is the sort of behavior that we saw. 267 00:23:47,320 --> 00:23:50,340 That was actually some of the more well intentioned behavior we saw. 268 00:23:50,340 --> 00:23:52,260 Most of the time we didn't even see that used. 269 00:23:52,280 --> 00:23:56,820 So a lot of connections to ad servers that seem to have no purpose for the gadget. 270 00:23:56,820 --> 00:24:00,140 They never notified the user that they were being connected to. 271 00:24:00,420 --> 00:24:06,040 They never prompted the user for any permission or activity around it. 272 00:24:06,040 --> 00:24:08,040 It was just generically run. 273 00:24:09,020 --> 00:24:16,680 We also found that there were a small number of producers that produced all the gadgets which meant that there was a lot of shared code. 274 00:24:17,160 --> 00:24:22,840 At one point, Mickey got this random text from me saying, there's something really strange going on. 275 00:24:22,840 --> 00:24:30,560 I've got gadgets that are coming from different sources that have the exact same update patterns in their fully qualified domains. 276 00:24:30,780 --> 00:24:32,860 He said, no, that can't be right. 277 00:24:32,860 --> 00:24:35,120 I said, the paths are exactly the same. 278 00:24:35,240 --> 00:24:40,380 We start looking into the domains a little bit and they have not listed anything related between them. 279 00:24:40,380 --> 00:24:46,300 We find out they're owned by the same company and that the developers are the same and all of a sudden it makes sense. 280 00:24:46,300 --> 00:24:47,880 They're using the exact same code base. 281 00:24:47,880 --> 00:24:49,580 There's just no reference. 282 00:24:49,780 --> 00:24:50,580 Question? 283 00:24:56,630 --> 00:25:00,710 The question is, was there any warning for self-signed certs or anything like that? 284 00:25:00,790 --> 00:25:03,770 Certainly you would hope to see that and we did not. 285 00:25:05,150 --> 00:25:07,870 We also didn't see any prompting for cookies. 286 00:25:07,910 --> 00:25:11,550 Now, that may have been the configuration. 287 00:25:11,550 --> 00:25:17,050 I don't think so because we tried it with about half a dozen different configurations and it just didn't seem to prompt the way you would expect. 288 00:25:18,590 --> 00:25:23,890 So the interesting thing is that if you find something in one gadget, you're probably going to find it in other ones as well. 289 00:25:23,890 --> 00:25:25,670 This comes up a lot in any framework. 290 00:25:25,670 --> 00:25:33,070 If you're building a framework and a lot of these are built from simple frameworks, you're going to end up with shared flaws. 291 00:25:34,550 --> 00:25:39,190 This is just another instance of shared code giving you underlying problems. 292 00:25:39,190 --> 00:25:41,490 How many remember the ASN1 bug? 293 00:25:42,870 --> 00:25:45,870 One, two, really? 294 00:25:45,990 --> 00:25:46,950 Wow. 295 00:25:46,950 --> 00:25:47,830 Okay. 296 00:25:48,670 --> 00:25:54,370 ASN1 is an underlying parsing protocol that the U.S. 297 00:25:54,370 --> 00:25:55,830 government defined. 298 00:25:56,090 --> 00:26:15,390 They offered a reference implementation of it that nobody bothered to use as a baseband for satellites, cable, ISDN, SNMP, everything uses ASN1. 299 00:26:15,390 --> 00:26:20,610 So there was this really pernicious flaw that showed up everywhere because of the shared code problem. 300 00:26:20,610 --> 00:26:23,210 It was a long -lasting flaw. 301 00:26:23,910 --> 00:26:32,810 So like we said, we found a bunch of actual really poor practices which led us to plenty of options for how to inject code. 302 00:26:32,810 --> 00:26:34,610 Your default permissions were full. 303 00:26:35,510 --> 00:26:37,850 We found it was phenomenally easy to spot. 304 00:26:37,850 --> 00:26:39,410 Mickey really likes this one. 305 00:26:39,410 --> 00:26:40,010 Yeah. 306 00:26:41,290 --> 00:26:43,130 This is a funny one. 307 00:26:44,210 --> 00:26:56,890 As we were looking through traffic, seeing what the gadgets send through HTTP requests, on 64-bit platforms we noticed that gadgets will send a request, every request will be sent with an HTTP header. 308 00:26:58,130 --> 00:27:00,510 UA-CPU. 309 00:27:00,510 --> 00:27:02,890 Does anyone know what that header is? 310 00:27:04,950 --> 00:27:06,170 Show of hands. 311 00:27:07,050 --> 00:27:08,170 Okay. 312 00:27:08,570 --> 00:27:11,990 That header is to indicate the kind of platform you're using. 313 00:27:12,330 --> 00:27:26,250 As far as I know, I can tell from the large scope searches I did online and Wikipedia, which is not really accurate most of the times. 314 00:27:26,990 --> 00:27:33,810 UA-CPU has been used in IE3 and 4 and has not been used since. 315 00:27:34,430 --> 00:27:36,170 Except here. 316 00:27:36,190 --> 00:27:40,910 The only use that we've seen is in gadgets on 64-bit platforms. 317 00:27:40,950 --> 00:27:43,670 32 bits are unimportant. 318 00:27:44,570 --> 00:27:56,870 More interesting thing is most of the systems that I've been in contact with through all my corporate life experience have been Windows 64-bit machines. 319 00:27:57,630 --> 00:28:04,630 And we have no official numbers, but we assume that most of the Windows 7 machines are 64-bit based. 320 00:28:05,570 --> 00:28:07,730 So I've got to do a sniff to traffic and you'll see it. 321 00:28:07,970 --> 00:28:08,990 Easy to spot. 322 00:28:11,290 --> 00:28:12,290 It was. 323 00:28:14,850 --> 00:28:18,370 So SSL, we all know it's really complex. 324 00:28:18,490 --> 00:28:20,550 It's not like there's good references for it. 325 00:28:20,550 --> 00:28:22,010 It's not like it's well documented. 326 00:28:22,010 --> 00:28:25,010 There certainly aren't libraries that are available for everyone to use. 327 00:28:25,010 --> 00:28:29,770 It certainly hasn't been explained again and again and again and again and again how to do it right. 328 00:28:30,050 --> 00:28:33,310 So why would you expect anyone to do it properly? 329 00:28:33,310 --> 00:28:39,870 And since you can't expect someone to do it properly, what you end up with is a strange habit where gadgets want to update themselves. 330 00:28:39,870 --> 00:28:40,730 It's reasonable. 331 00:28:40,730 --> 00:28:47,210 Auto update is a reasonable thing, but what we found was you have clear text downloads of updates. 332 00:28:47,510 --> 00:29:17,250 And since gadgets are written in JavaScript and HTML, what you've got is clear text download of JavaScript and HTML, which is then fully updating the entire cache of the gadget itself, which means you've just replaced all of the code for the gadget, which unfortunately means that whatever you looked at at the beginning may have absolutely no reference or relevance to what is actually going on, 333 00:29:17,250 --> 00:29:19,850 to what's actually executed. 334 00:29:20,690 --> 00:29:27,510 This is sort of like what Charlie Milley demonstrated, except nowhere near as complex or challenging and not quite as cool. 335 00:29:27,510 --> 00:29:29,130 Well, nowhere near as cool, frankly. 336 00:29:29,130 --> 00:29:31,670 But the same sort of consequence. 337 00:29:31,690 --> 00:29:36,670 You think you get one thing and you get something completely different. 338 00:29:38,590 --> 00:29:43,350 As a result , it makes it really simple to perform a man-in-the-middle attack. 339 00:29:43,990 --> 00:29:52,010 As Mickey pointed out , there's a really simple HTTP header that you can check for. 340 00:29:52,550 --> 00:29:54,770 You can use something as simple as earphone. 341 00:29:54,950 --> 00:30:00,510 To be clear, the demos we're showing you and the demos that we've done, we're using a proxy. 342 00:30:00,510 --> 00:30:02,050 We're actually doing full man-in-the-middle. 343 00:30:02,050 --> 00:30:03,330 We configured a proxy. 344 00:30:03,330 --> 00:30:05,150 This isn't because it's required. 345 00:30:05,170 --> 00:30:10,170 It's because the demo gods are capricious and fickle and really, really nasty. 346 00:30:10,430 --> 00:30:15,730 And we just don't want to have any more variability in it than we absolutely have to. 347 00:30:15,930 --> 00:30:23,050 There's no reason that you couldn't just do a race attack and do an injection without actually having to use a proxy for this. 348 00:30:23,950 --> 00:30:24,470 Okay. 349 00:30:48,260 --> 00:30:49,200 So, I'm going to talk a little bit about 350 00:30:53,210 --> 00:30:54,910 this for now. 351 00:30:56,190 --> 00:31:02,510 What we have here is a proxy running in this window, bottom right window. 352 00:31:02,790 --> 00:31:11,250 A proxy is set to listen to gadget traffic and intercept it and replace the response with something interesting. 353 00:31:12,550 --> 00:31:19,630 I'm going to display this using... yeah. 354 00:31:20,210 --> 00:31:23,750 I'm going to show you this. 355 00:31:23,750 --> 00:31:26,250 No, that was just the port that we set up for the proxy. 356 00:31:26,470 --> 00:31:29,170 The question was, does all gadget traffic hit 81, 81? 357 00:31:29,170 --> 00:31:34,790 No, that was just the proxy port that we chose because it was a nice number. 358 00:31:36,170 --> 00:31:38,190 No meaning otherwise. 359 00:31:43,810 --> 00:31:52,350 The question is, is it typically using any... gadget traffic is just running in an IE process, so it's going to use whatever ports IE is configured to use. 360 00:31:52,350 --> 00:31:54,990 By default, it will use 443, 80. 361 00:31:55,270 --> 00:32:00,170 If you've got a proxy that's on an off-numbered port, it will use whatever is on the off-numbered port. 362 00:32:01,510 --> 00:32:05,650 So this is the normal screen in Windows, the default gadgets. 363 00:32:05,670 --> 00:32:09,870 The only two different ones are the Nyan Cat, which you've already seen, and the Piano. 364 00:32:10,150 --> 00:32:18,830 The Piano gadget is, this one is exactly the one that was in the Microsoft gallery, live gallery, before they killed it. 365 00:32:19,670 --> 00:32:22,050 No modifications have been done to it. 366 00:32:24,770 --> 00:32:28,170 Reminder, this computer is running through a proxy right now. 367 00:32:40,330 --> 00:32:42,610 The gadget isn't supposed to do that. 368 00:32:44,150 --> 00:32:46,510 That's, by the way, three lines of code. 369 00:32:49,170 --> 00:32:53,830 The hardest part of that was actually, well, that wasn't really a hard part of that one. 370 00:32:54,110 --> 00:32:55,270 That was an easy one. 371 00:32:57,450 --> 00:33:00,230 To be fair, your computer does complain at you a lot. 372 00:33:05,310 --> 00:33:09,090 Imagine hearing that when you least expect it. 373 00:33:14,060 --> 00:33:24,780 So the simple example we gave you of running just injection, making your computer say something, this is kind of cute, trite, a little silly. 374 00:33:24,900 --> 00:33:25,600 We've seen it before. 375 00:33:25,600 --> 00:33:28,600 The question is, of course, can we get a shell? 376 00:33:29,100 --> 00:33:31,180 That's always the real interesting question. 377 00:33:31,640 --> 00:33:46,560 And the interesting thing is, as we said, since you've just got the ability to write anything you want to the system, and you've got the updates in many cases, or not even the updates, you've got the request for HTML and JavaScript running in clear text, 378 00:33:46,560 --> 00:33:56,020 and it's going to then go execute your JavaScript and parse your HTML, you've got a tremendous amount of power in the process. 379 00:33:56,040 --> 00:33:58,640 You can write any scripting language you want to the system. 380 00:33:58,640 --> 00:34:00,960 You can exec anything you want. 381 00:34:00,980 --> 00:34:03,320 In our case, we started playing with PowerShell. 382 00:34:07,800 --> 00:34:15,500 So at this point, that's not what we want right now. 383 00:34:23,570 --> 00:34:24,650 Okay. 384 00:34:24,810 --> 00:34:28,350 So what you've got now is three windows. 385 00:34:29,370 --> 00:34:33,790 Top left is a simple HTTP web server that we set up. 386 00:34:33,910 --> 00:34:35,470 It's serving a shell. 387 00:34:37,070 --> 00:34:38,550 Serving a file. 388 00:34:38,850 --> 00:34:44,550 In this case, the file it's serving is a very simple metasploit interpreter reverse TCP shell. 389 00:34:45,390 --> 00:34:47,510 We didn't do any modifications by itself. 390 00:34:47,510 --> 00:34:50,630 This shell would be detected by any decent antivirus. 391 00:34:51,310 --> 00:34:53,970 That's purely for POC because we're lazy. 392 00:34:54,330 --> 00:34:59,450 The fact is obviously that you could download any binary that you want, and you could write anything you want. 393 00:35:03,510 --> 00:35:14,110 In the upper right corner, you've got metasploit waiting for a connection, and as Mickey already showed you, you've got a proxy in this corner. 394 00:35:17,130 --> 00:35:23,470 We're going to do one small change to payload that's delivered. 395 00:35:34,030 --> 00:35:41,950 Because it is a gadget just like, or because it runs in the IE process, you've basically still got to clear the cache. 396 00:35:41,950 --> 00:35:43,110 It'll store things. 397 00:35:43,770 --> 00:35:50,410 There were a number of times where one of us or the other would forget and try to figure out why something suddenly stopped working. 398 00:35:50,410 --> 00:35:52,070 It was more than a little frustrating. 399 00:35:52,830 --> 00:35:54,150 But it's pretty straightforward. 400 00:35:54,670 --> 00:35:58,210 What you're going to see from this side is not particularly exciting. 401 00:36:00,870 --> 00:36:02,150 Fairly intentionally. 402 00:36:04,730 --> 00:36:12,010 From this side, all you get is that. 403 00:36:13,210 --> 00:36:15,430 All you see is a file written to the desktop. 404 00:36:15,490 --> 00:36:17,710 Now, this is for a POC. 405 00:36:17,710 --> 00:36:19,290 We chose to write to the desktop. 406 00:36:19,310 --> 00:36:20,890 You can write anywhere you want. 407 00:36:20,890 --> 00:36:22,670 There's no reason you have to write to the desktop. 408 00:36:22,670 --> 00:36:25,350 You can write to the startup folder. 409 00:36:25,890 --> 00:36:28,870 You can write anywhere the user has permissions to. 410 00:36:28,970 --> 00:36:33,390 But notice that there was no prompt that you're running an unsigned binary. 411 00:36:33,390 --> 00:36:38,910 Notice that there was no prompt that you were kicking off anything from a script or running a script . 412 00:36:39,350 --> 00:36:40,410 All you saw. 413 00:36:40,570 --> 00:36:43,150 And one last thing, the gadget is functional. 414 00:36:45,650 --> 00:36:46,830 Still works. 415 00:36:46,930 --> 00:36:53,810 In contrast, what you see when you've got back here is that you see the request was detected and injected. 416 00:36:53,870 --> 00:36:58,290 You see a request here for the URL and for the file that it downloaded. 417 00:36:58,290 --> 00:37:03,710 And over here, what do we have but actually a Windows shell. 418 00:37:05,250 --> 00:37:09,270 So, you can in fact... 419 00:37:14,860 --> 00:37:30,600 Now, the interesting thing about this is that if you run the exact function from JavaScript, it will warn the user that you are trying to execute something that's not signed, that was downloaded from an untrusted zone. 420 00:37:30,600 --> 00:37:32,400 It tries to do the right thing. 421 00:37:32,700 --> 00:37:41,900 However, if you run a binary from Power Script, PowerShell, it doesn't warn you at all. 422 00:37:42,100 --> 00:37:46,500 Now, of course, the default policy for PowerShell is you can't run scripts on the system. 423 00:37:47,180 --> 00:37:58,200 Luckily, CG and some of the other folks out there have been looking around and talking about PowerShell attacks and documented some really nice PowerShell policy bypasses. 424 00:37:58,360 --> 00:38:18,780 So what we're actually doing in this attack is we are using JavaScript to write, first to pull down the binary onto the system, then it writes a PowerShell script which is meant to execute the binary and then it writes a batch file which is used to bypass the PowerShell policy so that you've got a batch script running PowerShell, 425 00:38:18,780 --> 00:38:26,480 executing the shell, the result of which is the user sees nothing and it bypasses all of the basic controls on the system to do so. 426 00:38:27,280 --> 00:38:34,260 It was actually mostly the pain in the neck of getting all of that escaping properly set up between multiple languages and getting it to write to the disk. 427 00:38:35,440 --> 00:38:36,740 So, 428 00:38:43,580 --> 00:38:49,560 at this point you can see, we feel pretty comfortable that you've got complete compromise of the system. 429 00:38:49,640 --> 00:38:54,360 We've owned it, you've got shell, we can do this with anything you're asking for JavaScript from. 430 00:38:54,600 --> 00:38:57,340 Anytime you ask for JavaScript with a gadget, we can do this. 431 00:38:58,040 --> 00:38:59,760 What do you do about this? 432 00:39:00,460 --> 00:39:04,140 It's fun to find flaws, but you've got to find something you can do about this. 433 00:39:04,140 --> 00:39:11,220 Well, at a basic level, if you're going to write applications, you have to remember code is code. 434 00:39:11,220 --> 00:39:12,540 It's going to be vulnerable. 435 00:39:12,540 --> 00:39:17,200 If you're going to download and execute stuff, don't take candy from strangers. 436 00:39:17,200 --> 00:39:20,140 Think about what you're downloading, think about what you're executing. 437 00:39:21,340 --> 00:39:31,840 If you're someone involved in writing an application framework, and this is an open request to anyone writing application frameworks, if it matters that something be done properly, don't leave it to chance. 438 00:39:32,060 --> 00:39:41,720 The easier you make it for people to write code, the less well written the code will be and the less experience they're going to have writing code. 439 00:39:42,900 --> 00:39:56,360 Finally, there's always Microsoft's solution, which is they removed the feature completely and they moved over to the Windows 8 model, which has the app container instead, which has much, much tighter controls over it completely. 440 00:39:57,980 --> 00:40:04,820 They're moving into the Windows Store, they've updated all the documentation for developers and everything else. 441 00:40:14,550 --> 00:40:18,630 This research could not have been done without the help of others. 442 00:40:20,650 --> 00:40:22,750 Interesting history. 443 00:40:22,890 --> 00:40:29,390 The three CVEs you see are remote code execution in default, Windows, Gadgets and Vista. 444 00:40:29,790 --> 00:40:33,650 Reported by Aviv Raf in 2007. 445 00:40:33,850 --> 00:40:35,550 That's five years ago. 446 00:40:38,050 --> 00:40:48,990 There's been prior work by Ian and Aviv on DEF CON 15 and Yitzik and Yoratan for the jinx malware for a lot of reference. 447 00:40:51,410 --> 00:41:07,990 Even though it's not listed under the references, the fact is that all of the functions we found, the PowerShell policy bypass, all of those things, we borrowed proudly and stole enthusiastically from people who did and published and were good enough to share the original research that they found. 448 00:41:08,030 --> 00:41:09,570 We couldn't have done it without them. 449 00:41:11,790 --> 00:41:19,070 So if you've got any interest, there's additional references here and at this point, if you've got questions, we're happy to take them. 450 00:41:19,310 --> 00:41:23,790 And we've got only a couple of minutes, after that we're going to be in the Q&A room number four. 451 00:41:24,350 --> 00:41:28,230 So I guess maybe we'll move to the Q&A room and take questions there. 452 00:41:29,190 --> 00:41:30,050 Thank you.