[00:00.000 --> 00:02.900] My name is Toby, this is Mickey. We're glad you could make it [00:02.900 --> 00:05.280] this morning. We're going to talk to you about Windows [00:05.280 --> 00:12.540] gadgets. First, our standard disclaimer, none of this has [00:12.540 --> 00:15.700] anything to do with anyone we've ever worked for, do work for or [00:15.700 --> 00:17.700] might ever work for in the future. We have our own [00:17.700 --> 00:20.140] opinions. They have no opinions about anything and the two [00:20.140 --> 00:23.280] connections aren't connected in absolutely no way, shape or [00:23.280 --> 00:26.180] form. They have no knowledge of anything we do ever and they're [00:26.180 --> 00:35.040] not even sure we exist. Well, aside from not being sure that I [00:35.040 --> 00:41.300] exist, my name is Toby. I'm a senior info sec geek for a [00:41.300 --> 00:45.460] Fortune 50 company. I do all sorts of things that mostly [00:45.460 --> 00:48.500] involve telling people their ideas are bad and then trying to [00:48.500 --> 00:50.800] keep their ideas from being compromised once they insist on [00:50.800 --> 00:58.120] doing them anyways. And an opinion in a loud mouth. That [00:58.120 --> 01:01.860] too, you forgot to say that. My name is Mickey. I used to work [01:01.860 --> 01:06.600] for a Fortune 50 company. I used to break software firmware and [01:06.600 --> 01:19.660] hardware in my spare time and well, that's it basically. We're [01:19.660 --> 01:21.900] going to keep do-si-do-ing because we don't have wireless [01:21.900 --> 01:26.040] mics. Excuse us for being a bit rough this morning. Today we're [01:26.040 --> 01:27.820] going to go through a bunch of different things. First we're [01:27.820 --> 01:29.700] going to spend some little time. We've already talked about who [01:29.700 --> 01:32.420] we are. We're going to talk about what gadgets are. By the [01:32.420 --> 01:34.920] way, you all know we're talking about Windows gadgets, right? [01:35.280 --> 01:38.560] Yeah? We're good? Okay. We're going to tell you a little bit [01:38.560 --> 01:42.220] about what Windows gadgets are. A little history, little details [01:42.220 --> 01:44.140] about them. Then we're going to go into what's wrong with them. [01:44.140 --> 01:46.420] We're going to talk about first attacking with gadgets and then [01:46.420 --> 01:49.180] we're going to talk about how you can attack gadgets. Then [01:49.180 --> 01:53.220] we'll spend a little bit of time talking about once it's all done [01:53.770 --> 01:56.980] what you can do about it and what the solutions are. Long [01:56.980 --> 02:00.720] term, short term solutions that Microsoft chose and otherwise. [02:08.100 --> 02:15.260] A couple of thank yous because this talk is based on civil [02:16.740 --> 02:21.680] things made by other people. And the support of other people. So [02:21.680 --> 02:26.020] I'd like to thank Ethics, Ian, Jason Street, SoftSec folks, [02:26.020 --> 02:32.800] Wim, Aviv, Raph, Galdiskin, and Suzuki, Sal, Mitsuki, Mitku, I [02:32.800 --> 02:37.480] don't think I pronounced that. But they helped us a lot with [02:37.480 --> 02:50.000] their work. Also, CG, or not. I guess we'll use that. We [02:50.000 --> 02:53.320] apologize. Clearly technology is complex and we're not very good [02:53.320 --> 02:59.620] at it. Also, CG from Carnal Ownage blog for his work on [02:59.620 --> 03:04.600] PowerShell bypass, PowerShell Metasploit, and just being a lot [03:04.600 --> 03:12.260] of fun to read. So for those of you who don't own Windows [03:12.260 --> 03:15.960] systems, what are gadgets? Gadgets are those tiny little [03:15.960 --> 03:18.560] applications you have on your desktop and you do a right click [03:18.560 --> 03:24.520] and it's like gadgets. You can use gadgets that range from a [03:24.520 --> 03:29.660] simple clock up to GPU performance handlers. They're [03:29.660 --> 03:36.440] very simple to use. A couple of examples on screen. Those are [03:36.440 --> 03:42.620] the default Microsoft gadgets. The CPU clock, the RSS feed, and [03:42.620 --> 03:50.380] the weather. A little history about gadgets. The first [03:50.380 --> 03:53.200] references we've actually seen documented were to show the [03:53.200 --> 03:57.280] active desktop in Windows XP. Over the course of the last week [03:57.280 --> 03:59.280] or so, we've had a couple of people mention that they [03:59.280 --> 04:02.160] remember seeing similar things that there was actually an [04:02.160 --> 04:06.580] active desktop in 98 as well, but we weren't able to find any [04:06.580 --> 04:09.560] traces of it or any documentation on it. So the [04:09.560 --> 04:13.560] first thing that we've seen from Windows XP is the concept of [04:13.560 --> 04:16.280] the active desktop. You could just basically run little tiny [04:16.280 --> 04:20.840] things on the desktop and get dynamic updates. It was fairly [04:20.840 --> 04:24.140] simple. In Vista, they started moving around, moving to the [04:24.140 --> 04:26.840] concept of actually having something called a gadget. They [04:26.840 --> 04:30.740] had the sidebar. It was fairly simple. We'll show you in half a [04:30.740 --> 04:35.340] second. It looked like this. Literally it was just a sidebar. [04:35.340 --> 04:38.700] All of the things ran along it and were very tightly tied to [04:38.700 --> 04:43.380] it, but they were referred to as gadgets. In Windows 7, they [04:43.380 --> 04:47.280] actually did a significant number of improvements to the [04:47.740 --> 04:51.540] capabilities. First, they combined it to a single process. [04:51.540 --> 04:55.400] They made it much easier to manage them. They could be [04:55.400 --> 05:00.160] placed all over the desktop. They also added a number of new [05:00.160 --> 05:03.280] capabilities to make it easier to develop and they added a [05:03.280 --> 05:07.500] bunch of enterprise security features. The development points [05:07.500 --> 05:12.960] are obviously irrelevant at this point. So Windows Vista, this is [05:12.960 --> 05:17.340] what it looked in Windows 7. We're actually both quite fond [05:17.340 --> 05:20.380] of the Pandora gadget. It's a fairly handy thing to have and [05:20.380 --> 05:23.360] it's literally just a way to listen to Pandora on the system. [05:23.360 --> 05:28.580] I think I was listening to Wien at that time. But these are [05:28.580 --> 05:36.440] some other examples besides the ones you saw previously. So the [05:36.440 --> 05:40.700] question is, why does this matter? To be quite honest, [05:40.700 --> 05:44.400] Mickey came to me and said, we should do this. And I said, why [05:44.400 --> 05:50.460] would anyone care? It took him about three weeks to convince [05:50.460 --> 05:57.520] me. Yeah, you tell me. About three weeks to convince me to [05:57.520 --> 06:02.740] do the research. And frankly, it's not news. If you write bad [06:02.740 --> 06:06.380] code, you're going to get compromised, right? If you run [06:06.380 --> 06:10.380] somebody else's code on your system, they're going to [06:10.380 --> 06:16.160] compromise you, right? This isn't novel. Turns out, though, [06:16.880 --> 06:21.220] the same issues that made this an actual interesting target and [06:21.360 --> 06:25.740] a problem are being moved forward consistently as a clear [06:25.740 --> 06:30.380] and enthusiastic business model. We're seeing everything being [06:30.380 --> 06:33.260] done by vendors to try and make it easier and easier for people [06:33.260 --> 06:36.240] who have less and less experience and knowledge about [06:36.240 --> 06:39.840] development to actually do development. And so the sorts of [06:39.840 --> 06:44.100] mistakes that we found and that we were able to exploit and take [06:44.100 --> 06:46.920] advantage of on these systems are going to continue being [06:46.920 --> 06:50.560] common as long as you can do something as silly as write an [06:50.560 --> 06:59.960] entire application in JavaScript and HTML. So a little bit of [06:59.960 --> 07:06.240] what is a gadget. A gadget is a zip file. Technically, it's a [07:06.240 --> 07:09.960] zip file renamed to be .gadget. If you didn't get that, that's [07:09.960 --> 07:23.450] cat.zip. A gadget has several screens on it. The main one, [07:23.450 --> 07:27.870] which you see when you use a gadget, there is an about, a fly [07:27.870 --> 07:31.050] out, and a setting screen. As you can see, they have [07:31.050 --> 07:36.790] correlating HTML files. This is, by the way, the simplest [07:39.090 --> 07:42.250] directory structure for a gadget. You've got a CSS folder, [07:42.250 --> 07:46.850] images folder, JavaScript folder, a couple of HTML files. [07:46.850 --> 07:51.910] This is, sorry, this is NeonCAD gadget, which you'll see soon [07:51.910 --> 07:58.670] enough. The part that is not standard is the gadget.xml, [07:58.670 --> 08:02.670] which is the gadget manifest. It holds the information on a [08:02.670 --> 08:09.250] gadget, manufacturer, copyright, URLs, permission level, which is [08:09.250 --> 08:12.350] always set to full and is expected to be full by [08:12.350 --> 08:21.050] Microsoft for some reason. And, well, did I forget anything? It [08:21.050 --> 08:27.770] can get simpler. This is the template. This is the HTML [08:27.770 --> 08:31.730] template. But you can also develop gadgets with silver [08:31.730 --> 08:38.670] light, so it's even more simpler. It's simpler. English [08:38.670 --> 08:43.350] is not my first language, I apologize. WPF and silver light [08:43.350 --> 08:47.990] will make it easier to code malicious code into your gadget. [08:51.600 --> 08:55.520] So a little bit about the security model. Microsoft [08:55.520 --> 08:58.660] actually provides a very detailed explanation. We were [08:58.660 --> 09:02.680] surprised by how much effort Microsoft has put in to [09:02.680 --> 09:05.580] documenting the security model and to documenting good security [09:05.580 --> 09:08.700] practices for writing gadgets, especially considering the [09:08.700 --> 09:13.300] general lack of security quality we found in the development of [09:13.300 --> 09:19.540] gadgets. They didn't, for lack of trying, we didn't see quality [09:19.540 --> 09:22.280] for lack of Microsoft trying to do it right. What we're going to [09:22.280 --> 09:24.220] do though is we're going to call out some of the highlights of [09:24.220 --> 09:29.260] the security model. And if you want to see more, you can still [09:29.260 --> 09:32.780] find the documentation for it on Microsoft's site. There's a URL [09:32.780 --> 09:37.580] in the background. First, code signing is actually possible. [09:37.580 --> 09:41.740] It's not standard. It's not common. It isn't required, but [09:41.740 --> 09:48.080] it is absolutely possible. We saw out of 60 or 70 gadgets that [09:48.080 --> 09:54.260] we were able to pull down, one or two, maybe three. One single [09:54.260 --> 09:58.200] vendor and not very many gadgets from any vendor that were [09:58.200 --> 10:01.280] actually signed. The prompt looks pretty similar to the [10:01.280 --> 10:06.160] actual installation for any standard application. The action [10:06.160 --> 10:08.880] behind it is much less complex in that it's just dropping [10:08.880 --> 10:12.980] everything into a directory, but making a couple configuration [10:12.980 --> 10:15.960] changes, very small stuff. But as you can see, it looks pretty [10:15.960 --> 10:21.260] standard. Show of hands, who's familiar with an HTML [10:21.260 --> 10:27.480] application, HTAs? Show of hands, who can give me the [10:27.480 --> 10:34.180] square root of 1,563? Just checking that there was actually [10:34.300 --> 10:40.680] a difference in response. So, they're fairly similar to HTAs, [10:40.680 --> 10:44.140] HTML applications. There are some differences in that they [10:44.140 --> 10:47.040] still run in the local machine zone, but they have some [10:47.040 --> 10:50.160] additional privileges that you wouldn't otherwise be able to [10:50.160 --> 10:52.960] take advantage of. And they have some limitations that aren't [10:52.960 --> 10:57.300] always in place. First, one of the advantages and something we [10:57.300 --> 11:00.580] found tremendously useful, you can instantiate any active X [11:00.580 --> 11:04.700] object on the system. Doesn't matter what it's for, doesn't [11:04.700 --> 11:07.400] matter whether it's a reasonable or sane thing to be able to do [11:07.400 --> 11:11.480] from an HTML function, you can do it from here. However, you [11:11.480 --> 11:14.560] can't actually kick off a UAC prompt. Doesn't matter what [11:14.560 --> 11:17.840] privilege you're actually running as for the user, this is [11:17.840 --> 11:20.180] always going to run as a standard user, even if you're in [11:20.180 --> 11:24.720] the admin group. On the other hand, any process that's been [11:24.720 --> 11:30.600] exec'd from the gadget can then itself raise a UAC prompt. And [11:30.600 --> 11:34.800] since you can use, for instance, the active X shell.run function [11:34.800 --> 11:38.180] or shell.exec function, you can still pretty much do what you [11:38.180 --> 11:40.980] want from here. Parental controls do apply as you would [11:40.980 --> 11:44.760] expect for any HTML based thing. It's running in an IE container. [11:44.760 --> 11:50.200] It's just a modified set of permissions to do so. Anything? [11:50.200 --> 11:53.960] Want to add anything? Some of the enterprise features that [11:53.960 --> 11:56.760] were added in Windows 7, there are a couple of basic things [11:56.760 --> 11:59.920] that you can use, you do via GPO, you can manage them in a [11:59.920 --> 12:02.420] couple of different ways. One, you can turn off the sidebar [12:02.420 --> 12:08.720] completely as a function. Two, you can set policies to control [12:09.180 --> 12:12.940] unpacking and installing of Windows gadgets that aren't [12:13.760 --> 12:15.840] signed. Unfortunately, this doesn't actually prevent [12:15.840 --> 12:19.160] somebody from installing them manually. And it doesn't remove [12:19.160 --> 12:21.560] gadgets that have already been installed. It just prevents new [12:21.560 --> 12:23.800] ones from being automatically installed when they double click [12:23.800 --> 12:28.320] and want to run them. You can disable user installed gadgets [12:28.320 --> 12:30.880] which is basically just locking down the permissions for a [12:30.880 --> 12:34.280] specific directory. And finally, you can actually override the [12:34.280 --> 12:43.040] get more gadgets online link which is now dead anyways. So at [12:43.040 --> 12:47.580] this point, normally I know the standard is to ask questions at [12:47.580 --> 12:51.060] the end. Feel free though, does anyone have any questions about [12:51.060 --> 12:52.820] anything we've covered on the development side of it that you [12:52.820 --> 13:10.640] want to ask now? Yeah. The question was is there any [13:10.640 --> 13:14.740] concept of this moving to Windows 8. Do you mean is there [13:14.740 --> 13:17.340] anything being done in Windows 8 that has a similar sort of idea [13:17.340 --> 13:26.240] behind it? Okay. As far as I know, I guess since neither of [13:26.240 --> 13:32.080] these work for Microsoft, we can speculate wildly. But as far as [13:32.080 --> 13:36.780] we know, you've got the metro app store sort of thing that is [13:36.780 --> 13:40.760] similar, but it's wrapped in the app container capability which [13:40.760 --> 13:45.440] locks it down much, much more tightly. And I haven't looked at [13:45.440 --> 13:48.440] the development for the metro app so I don't know if you know [13:48.440 --> 13:57.680] anything about metro app. Any other questions? Yeah. Okay. [14:11.760 --> 14:15.880] I think the question was is Microsoft really going to remove [14:15.880 --> 14:21.060] gadgets from Windows 8 or something? Or are they going to [14:21.060 --> 14:23.500] make it optional? Our understanding is they removed [14:23.500 --> 14:36.760] the feature completely. Other questions? Okay. Attack surface. [14:36.760 --> 14:38.720] We're going to now go into a little bit of the attacking [14:38.720 --> 14:42.900] actually through gadgets and with gadgets. We're going to [14:42.900 --> 14:45.760] start off with attacking with gadgets. One of the fundamental [14:45.760 --> 14:50.980] problems here is that it's just another piece of code somebody [14:50.980 --> 14:57.540] is running. We've all known for 20 years that if you download [14:57.540 --> 15:01.160] and run someone's code, you're going to get compromised. That's [15:01.160 --> 15:06.260] what happens. Unfortunately people don't actually think of [15:06.260 --> 15:10.860] gadgets for some reason as code. We weren't quite sure why. [15:11.540 --> 15:14.320] Mickey speculated that it was because they're cute and small [15:14.320 --> 15:17.660] and run around with little hats and pants on all the time. So he [15:17.660 --> 15:21.920] took a picture of them. Honestly, they are just as [15:21.920 --> 15:24.860] dangerous as any other piece of software. So the question is [15:24.860 --> 15:27.220] what can you do with this? Well, is it really just another [15:27.220 --> 15:29.620] piece of software after all? It's just this little tiny [15:29.620 --> 15:31.760] container thing. It shouldn't have all the capabilities that [15:31.760 --> 15:34.800] you would expect. Here are some of the things that you're [15:34.800 --> 15:40.040] actually able to do from a gadget. I can't do everything I [15:40.040 --> 15:44.600] might want. Well, oh yes, wait a minute, I can. I can exec code. [15:44.840 --> 15:48.600] Do I need to say anything? Well, just in case anyone is curious, [15:48.600 --> 15:52.620] you can also open URLs. So if you didn't want to carry [15:52.620 --> 15:55.940] something with you in the HTML that you're downloading with the [15:55.940 --> 16:01.000] gadget, you can go get more. If you want to change what you [16:01.000 --> 16:04.640] downloaded, you can do that too. You want to update? No problem. [16:04.640 --> 16:07.500] You want to create files with arbitrary content, binary or [16:07.500 --> 16:10.500] otherwise on the system? We can do that. You want to be able to [16:10.500 --> 16:12.980] read files? Anything that the user has permission to, you're [16:12.980 --> 16:16.140] good for. And if you want to get past that permission, obviously [16:16.140 --> 16:19.860] you can just spawn something and raise the UAC prompt and do so. [16:19.940 --> 16:24.880] Make your computer speak? Sure. You can do that too. And I guess [16:24.880 --> 16:28.060] we should actually show you what that looks like. Want to run it? [17:03.340 --> 17:08.080] We're going to show you a little demonstration of what you can do [17:08.080 --> 17:22.080] with a malicious gadget. This is a POC of a gadget that will self-spread to all your [17:22.080 --> 17:32.940] contacts. It is not fully weaponized, it's just a POC. A little explanation, the gadget [17:32.940 --> 17:47.220] opens Gmail. Quick question, how many of you use Gmail? How many of you make sure you log [17:47.220 --> 18:02.220] out and stop using Gmail? Every single time? How many of you are lying? That's not good. [18:11.540 --> 18:45.280] Can we get sound from... okay. I apologize in advance. You should be so ashamed. Now we [18:45.280 --> 19:03.740] are back. Create a new email. Add a subject. Add a link. And we'll send it. And when it's [19:03.740 --> 19:17.610] done it will close the window. Now, just to clarify, first of all, I would like to stress that [19:17.610 --> 19:23.970] there is no security vulnerability in Gmail. It's kind of a work around for a setting. [19:24.190 --> 19:32.110] Gmail allows users to use keyboard shortcuts. And to enable that, usually what you do is go [19:32.110 --> 19:39.010] into settings and select an option saying enable keyboard shortcuts. However, if you open a [19:39.010 --> 19:47.350] URL with KBD equals 1 in the query string, you will get that feature enabled. And gadgets [19:48.170 --> 19:53.990] very easily send keystrokes to the screen. This is the code that sends the Gmail. Sixteen [19:53.990 --> 20:26.800] lines. That's how simple this is. So, simple example, you saw what can be done. Very [20:26.800 --> 20:32.940] standard malicious sort of gadget activity. The key is that it's got all of the access it [20:32.940 --> 20:37.760] needs to all of your cookies and all of the information in your browser, which means it also [20:37.760 --> 20:42.580] has your proxy configurations. It can manipulate anything else it wants on the system. It's [20:42.580 --> 20:52.420] got all of that state that you're giving it at any point in time. Another addition. We [20:52.420 --> 20:59.580] discovered also that gadgets can also read map network drives, delete map network drives, [20:59.580 --> 21:09.420] handle map network drives, add them. Everything that Windows supports, it can do, basically. [21:09.440 --> 21:14.720] We actually ran out of time to find out all of the things we kept finding. We tried [21:14.720 --> 21:21.020] something and say, oh, that's possible. How about, oh, that's possible. It just kept going. [21:22.880 --> 21:30.480] So, you've been something, we've talked about attacking with gadgets. Simple demo. [21:30.480 --> 21:34.560] Hopefully you understand it is just a POC. The question is now, what can you do in terms of [21:34.560 --> 21:39.580] attacking gadgets? Well, unfortunately, they're just code. And in many cases, they're [21:39.580 --> 21:43.620] written by people who don't have a lot of experience writing code. It was fairly [21:43.620 --> 21:49.120] interesting as we went through the collection of gadgets and we found about, is that a [21:49.120 --> 21:58.180] question? I'm going to attack? Okay. We found about 65, 70 gadgets that were floating [21:58.180 --> 22:02.840] around that people were actually using. And it was very easy to distinguish between the [22:02.840 --> 22:06.360] gadgets that were written by people who were used to doing development and they'd break it [22:06.360 --> 22:10.060] down as you'd expect with any developer in terms of having separate files for different [22:10.060 --> 22:15.080] function families and all sorts of clean object-oriented design and people who were used [22:15.080 --> 22:20.860] to doing web development, in which case you'd see one big HTML file that contained [22:20.860 --> 22:25.140] everything in the JavaScript. And you can do this. It's really just a web page to some [22:25.140 --> 22:30.280] extent that's running locally with a lot of extra privileges. So you'd see a lot of [22:30.280 --> 22:34.700] different styles. And of course, that leaves you with a lot of vulnerable systems. So you end [22:34.700 --> 22:41.340] up with a fairly basic strategy, which is just find some gadgets, analyze them, pause, [22:41.340 --> 22:49.220] and profit. So what did we find? Well, when you started looking around, we found a lot of [22:49.220 --> 22:54.520] sites offering malware that were claiming to be gadgets. We found a fair number of [22:54.520 --> 22:59.460] gadgets, but we found more in terms of total number of sites that were offering it, there [22:59.460 --> 23:04.480] was more malware out there than there were actual gadgets. We found really limited use of [23:04.480 --> 23:10.020] SSL. In fact, the only consistent cases that we found SSL being used were in the cases [23:10.020 --> 23:15.360] where the websites that were being connected to required it. Otherwise, they didn't use it. [23:15.360 --> 23:19.900] And we actually found a couple of interesting educations. You want to give them the rundown? [23:20.360 --> 23:32.980] Yeah. We saw one use, one good use of SSL in a gadget. But the funny thing was that the [23:32.980 --> 23:38.620] website hosting the file that was being accessed through SSL also hosted it in normal [23:38.620 --> 23:46.660] HTTP. So all you got to do is SSL strip and you win. And this is the sort of behavior that we [23:46.660 --> 23:50.740] saw. That was actually some of the more well intentioned behavior we saw. Most of the time [23:50.740 --> 23:54.980] we didn't even see that used. So a lot of connections to ad servers that seem to have no [23:54.980 --> 24:00.800] purpose for the gadget. They never notified the user that they were being connected to. They [24:00.800 --> 24:07.280] never prompted the user for any permission or activity around it. It was just generically [24:07.280 --> 24:14.060] run. We also found that there were a small number of producers that produced all the gadgets [24:14.060 --> 24:19.600] which meant that there was a lot of shared code. At one point, Mickey got this random text [24:19.600 --> 24:23.940] from me saying, there's something really strange going on. I've got gadgets that are coming [24:23.940 --> 24:29.660] from different sources that have the exact same update patterns in their fully qualified [24:29.660 --> 24:35.640] domains. He said, no, that can't be right. I said, the paths are exactly the same. We start [24:35.640 --> 24:39.780] looking into the domains a little bit and they have not listed anything related between [24:39.780 --> 24:44.840] them. We find out they're owned by the same company and that the developers are the same [24:44.840 --> 24:48.720] and all of a sudden it makes sense. They're using the exact same code base. There's just no [24:48.720 --> 25:00.010] reference. Question? The question is, was there any warning for self-signed certs or anything [25:00.010 --> 25:06.390] like that? Certainly you would hope to see that and we did not. We also didn't see any [25:06.390 --> 25:12.370] prompting for cookies. Now, that may have been the configuration. I don't think so because [25:12.370 --> 25:15.550] we tried it with about half a dozen different configurations and it just didn't seem to [25:15.550 --> 25:21.110] prompt the way you would expect. So the interesting thing is that if you find something in [25:21.110 --> 25:24.850] one gadget, you're probably going to find it in other ones as well. This comes up a lot in [25:24.850 --> 25:28.670] any framework. If you're building a framework and a lot of these are built from simple [25:28.670 --> 25:36.310] frameworks, you're going to end up with shared flaws. This is just another instance of [25:36.970 --> 25:44.810] shared code giving you underlying problems. How many remember the ASN1 bug? One, two, [25:44.810 --> 25:54.650] really? Wow. Okay. ASN1 is an underlying parsing protocol that the U.S. government [25:54.650 --> 26:06.210] defined. They offered a reference implementation of it that nobody bothered to use as a [26:06.750 --> 26:16.230] baseband for satellites, cable, ISDN, SNMP, everything uses ASN1. So there was this really [26:16.230 --> 26:21.710] pernicious flaw that showed up everywhere because of the shared code problem. It was a [26:21.710 --> 26:29.370] long-lasting flaw. So like we said, we found a bunch of actual really poor practices which [26:29.370 --> 26:36.190] led us to plenty of options for how to inject code. Your default permissions were full. We [26:36.190 --> 26:42.310] found it was phenomenally easy to spot. Mickey really likes this one. Yeah. This is a funny [26:42.310 --> 26:47.770] one. As we were looking through traffic, seeing what the gadgets send through HTTP [26:47.770 --> 26:54.910] requests, on 64-bit platforms we noticed that gadgets will send a request, every request will [26:54.910 --> 27:06.170] be sent with an HTTP header. UA-CPU. Does anyone know what that header is? Show of hands. [27:07.050 --> 27:14.250] Okay. That header is to indicate the kind of platform you're using. As far as I know, I can [27:14.250 --> 27:25.090] tell from the large scope searches I did online and Wikipedia, which is not really accurate [27:25.090 --> 27:36.170] most of the times. UA-CPU has been used in IE3 and 4 and has not been used since. Except here. [27:36.190 --> 27:43.670] The only use that we've seen is in gadgets on 64-bit platforms. 32 bits are unimportant. [27:44.570 --> 27:51.530] More interesting thing is most of the systems that I've been in contact with through all my [27:52.310 --> 27:59.070] corporate life experience have been Windows 64-bit machines. And we have no official [27:59.070 --> 28:06.110] numbers, but we assume that most of the Windows 7 machines are 64-bit based. So I've got to do [28:06.270 --> 28:17.410] a sniff to traffic and you'll see it. Easy to spot. It was. So SSL, we all know it's really [28:17.410 --> 28:22.010] complex. It's not like there's good references for it. It's not like it's well documented. [28:22.010 --> 28:25.670] There certainly aren't libraries that are available for everyone to use. It certainly hasn't [28:25.670 --> 28:31.510] been explained again and again and again and again and again how to do it right. So why [28:31.510 --> 28:35.470] would you expect anyone to do it properly? And since you can't expect someone to do it [28:35.470 --> 28:39.870] properly, what you end up with is a strange habit where gadgets want to update themselves. [28:39.870 --> 28:45.510] It's reasonable. Auto update is a reasonable thing, but what we found was you have clear text [28:45.510 --> 28:53.970] downloads of updates. And since gadgets are written in JavaScript and HTML, what you've got [28:53.970 --> 29:01.230] is clear text download of JavaScript and HTML, which is then fully updating the entire [29:01.230 --> 29:08.310] cache of the gadget itself, which means you've just replaced all of the code for the gadget, [29:08.310 --> 29:12.610] which unfortunately means that whatever you looked at at the beginning may have absolutely [29:12.610 --> 29:21.530] no reference or relevance to what is actually going on, to what's actually executed. This is [29:21.530 --> 29:25.290] sort of like what Charlie Milley demonstrated, except nowhere near as complex or [29:25.290 --> 29:30.830] challenging and not quite as cool. Well, nowhere near as cool, frankly. But the same sort of [29:30.830 --> 29:39.450] consequence. You think you get one thing and you get something completely different. As a [29:39.450 --> 29:45.150] result, it makes it really simple to perform a man-in-the-middle attack. As Mickey pointed [29:45.150 --> 29:53.870] out, there's a really simple HTTP header that you can check for. You can use something as [29:53.870 --> 29:59.230] simple as earphone. To be clear, the demos we're showing you and the demos that we've done, [29:59.230 --> 30:03.490] we're using a proxy. We're actually doing full man-in-the-middle. We configured a proxy. This [30:03.490 --> 30:09.130] isn't because it's required. It's because the demo gods are capricious and fickle and really, [30:09.130 --> 30:14.750] really nasty. And we just don't want to have any more variability in it than we absolutely [30:14.750 --> 30:20.710] have to. There's no reason that you couldn't just do a race attack and do an injection without [30:20.710 --> 30:49.200] actually having to use a proxy for this. Okay. So, I'm going to talk a little bit about [30:53.210 --> 31:03.010] this for now. What we have here is a proxy running in this window, bottom right window. A [31:03.010 --> 31:08.930] proxy is set to listen to gadget traffic and intercept it and replace the response with [31:08.930 --> 31:20.950] something interesting. I'm going to display this using... yeah. I'm going to show you [31:23.350 --> 31:27.550] this. No, that was just the port that we set up for the proxy. The question was, does all [31:27.550 --> 31:34.110] gadget traffic hit 81, 81? No, that was just the proxy port that we chose because it was a [31:34.110 --> 31:46.530] nice number. No meaning otherwise. The question is, is it typically using any... gadget [31:46.530 --> 31:51.530] traffic is just running in an IE process, so it's going to use whatever ports IE is [31:51.530 --> 31:57.150] configured to use. By default, it will use 443, 80. If you've got a proxy that's on an [31:57.150 --> 32:02.690] off-numbered port, it will use whatever is on the off-numbered port. So this is the normal [32:02.690 --> 32:07.710] screen in Windows, the default gadgets. The only two different ones are the Nyan Cat, which [32:07.710 --> 32:14.110] you've already seen, and the Piano. The Piano gadget is, this one is exactly the one that was [32:14.110 --> 32:21.090] in the Microsoft gallery, live gallery, before they killed it. No modifications have been [32:21.090 --> 32:41.430] done to it. Reminder, this computer is running through a proxy right now. The gadget isn't [32:41.430 --> 32:50.450] supposed to do that. That's, by the way, three lines of code. The hardest part of that was [32:50.450 --> 32:58.270] actually, well, that wasn't really a hard part of that one. That was an easy one. To be fair, [32:58.270 --> 33:09.090] your computer does complain at you a lot. Imagine hearing that when you least expect it. [33:14.060 --> 33:21.000] So the simple example we gave you of running just injection, making your computer say [33:21.000 --> 33:26.240] something, this is kind of cute, trite, a little silly. We've seen it before. The question is, [33:26.240 --> 33:32.520] of course, can we get a shell? That's always the real interesting question. And the [33:32.520 --> 33:37.960] interesting thing is, as we said, since you've just got the ability to write anything you want [33:37.960 --> 33:43.140] to the system, and you've got the updates in many cases, or not even the updates, you've got [33:43.140 --> 33:48.640] the request for HTML and JavaScript running in clear text, and it's going to then go execute [33:48.640 --> 33:56.020] your JavaScript and parse your HTML, you've got a tremendous amount of power in the process. [33:56.040 --> 34:00.960] You can write any scripting language you want to the system. You can exec anything you want. [34:00.980 --> 34:14.480] In our case, we started playing with PowerShell. So at this point, that's not what we want [34:14.480 --> 34:32.190] right now. Okay. So what you've got now is three windows. Top left is a simple HTTP web [34:32.190 --> 34:40.130] server that we set up. It's serving a shell. Serving a file. In this case, the file it's [34:40.130 --> 34:46.090] serving is a very simple metasploit interpreter reverse TCP shell. We didn't do any [34:46.090 --> 34:51.790] modifications by itself. This shell would be detected by any decent antivirus. That's [34:51.790 --> 34:56.810] purely for POC because we're lazy. The fact is obviously that you could download any binary [34:56.810 --> 35:05.730] that you want, and you could write anything you want. In the upper right corner, you've got [35:06.290 --> 35:12.510] metasploit waiting for a connection, and as Mickey already showed you, you've got a proxy in [35:12.510 --> 35:35.450] this corner. We're going to do one small change to payload that's delivered. Because it is a [35:35.450 --> 35:41.270] gadget just like, or because it runs in the IE process, you've basically still got to clear [35:41.270 --> 35:47.010] the cache. It'll store things. There were a number of times where one of us or the other [35:47.010 --> 35:50.870] would forget and try to figure out why something suddenly stopped working. It was more [35:50.870 --> 35:55.990] than a little frustrating. But it's pretty straightforward. What you're going to see from [35:55.990 --> 36:09.470] this side is not particularly exciting. Fairly intentionally. From this side, all you get is [36:11.410 --> 36:18.350] that. All you see is a file written to the desktop. Now, this is for a POC. We chose to write [36:18.350 --> 36:22.190] to the desktop. You can write anywhere you want. There's no reason you have to write to the [36:22.190 --> 36:27.690] desktop. You can write to the startup folder. You can write anywhere the user has [36:27.690 --> 36:33.390] permissions to. But notice that there was no prompt that you're running an unsigned binary. [36:33.390 --> 36:38.430] Notice that there was no prompt that you were kicking off anything from a script or running a [36:38.430 --> 36:47.750] script. All you saw. And one last thing, the gadget is functional. Still works. In contrast, [36:47.750 --> 36:52.830] what you see when you've got back here is that you see the request was detected and [36:52.830 --> 36:58.530] injected. You see a request here for the URL and for the file that it downloaded. And over [36:58.530 --> 37:15.820] here, what do we have but actually a Windows shell. So, you can in fact... Now, the [37:15.820 --> 37:23.320] interesting thing about this is that if you run the exact function from JavaScript, it will [37:23.340 --> 37:28.920] warn the user that you are trying to execute something that's not signed, that was [37:28.920 --> 37:36.600] downloaded from an untrusted zone. It tries to do the right thing. However, if you run a [37:36.600 --> 37:43.400] binary from Power Script, PowerShell, it doesn't warn you at all. Now, of course, the [37:43.400 --> 37:48.580] default policy for PowerShell is you can't run scripts on the system. Luckily, CG and some [37:48.580 --> 37:53.000] of the other folks out there have been looking around and talking about PowerShell attacks [37:53.000 --> 38:00.180] and documented some really nice PowerShell policy bypasses. So what we're actually doing in [38:00.180 --> 38:06.740] this attack is we are using JavaScript to write, first to pull down the binary onto the [38:06.740 --> 38:11.500] system, then it writes a PowerShell script which is meant to execute the binary and then it [38:11.500 --> 38:17.000] writes a batch file which is used to bypass the PowerShell policy so that you've got a batch [38:17.000 --> 38:22.200] script running PowerShell, executing the shell, the result of which is the user sees [38:22.200 --> 38:28.080] nothing and it bypasses all of the basic controls on the system to do so. It was actually [38:28.080 --> 38:31.780] mostly the pain in the neck of getting all of that escaping properly set up between [38:31.780 --> 38:46.740] multiple languages and getting it to write to the disk. So, at this point you can see, we feel [38:46.740 --> 38:50.560] pretty comfortable that you've got complete compromise of the system. We've owned it, you've [38:50.560 --> 38:55.240] got shell, we can do this with anything you're asking for JavaScript from. Anytime you ask [38:55.240 --> 39:01.420] for JavaScript with a gadget, we can do this. What do you do about this? It's fun to find [39:01.420 --> 39:06.960] flaws, but you've got to find something you can do about this. Well, at a basic level, if [39:06.960 --> 39:11.660] you're going to write applications, you have to remember code is code. It's going to be [39:11.660 --> 39:17.200] vulnerable. If you're going to download and execute stuff, don't take candy from strangers. [39:17.200 --> 39:22.180] Think about what you're downloading, think about what you're executing. If you're someone [39:22.180 --> 39:26.700] involved in writing an application framework, and this is an open request to anyone writing [39:26.700 --> 39:31.020] application frameworks, if it matters that something be done properly, don't leave it to [39:31.020 --> 39:38.780] chance. The easier you make it for people to write code, the less well written the code will [39:38.780 --> 39:43.820] be and the less experience they're going to have writing code. Finally, there's always [39:43.820 --> 39:50.040] Microsoft's solution, which is they removed the feature completely and they moved over to [39:50.040 --> 39:54.580] the Windows 8 model, which has the app container instead, which has much, much tighter [39:54.580 --> 40:02.260] controls over it completely. They're moving into the Windows Store, they've updated all the [40:02.260 --> 40:16.750] documentation for developers and everything else. This research could not have been done [40:16.750 --> 40:25.470] without the help of others. Interesting history. The three CVEs you see are remote code [40:25.470 --> 40:34.410] execution in default, Windows, Gadgets and Vista. Reported by Aviv Raf in 2007. That's five [40:34.410 --> 40:46.330] years ago. There's been prior work by Ian and Aviv on DEF CON 15 and Yitzik and Yoratan for [40:46.330 --> 40:54.490] the jinx malware for a lot of reference. Even though it's not listed under the references, the [40:54.490 --> 41:00.310] fact is that all of the functions we found, the PowerShell policy bypass, all of those [41:00.310 --> 41:04.790] things, we borrowed proudly and stole enthusiastically from people who did and [41:04.790 --> 41:08.390] published and were good enough to share the original research that they found. We couldn't [41:08.390 --> 41:15.710] have done it without them. So if you've got any interest, there's additional references here [41:15.710 --> 41:20.430] and at this point, if you've got questions, we're happy to take them. And we've got only a [41:20.430 --> 41:25.770] couple of minutes, after that we're going to be in the Q&A room number four. So I guess maybe [41:25.770 --> 41:30.050] we'll move to the Q&A room and take questions there. Thank you.