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