WEBVTT

00:00.000 --> 00:01.560
My name is Toby, this is Mickey.

00:01.560 --> 00:03.780
We're glad you could make it this morning.

00:04.160 --> 00:05.960
We're going to talk to you about Windows gadgets.

00:09.280 --> 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.

00:17.160 --> 00:18.160
We have our own opinions.

00:18.160 --> 00:24.000
They have no opinions about anything and the two connections aren't connected in absolutely no way, shape or form.

00:24.000 --> 00:27.760
They have no knowledge of anything we do ever and they're not even sure we exist.

00:33.280 --> 00:38.120
Well, aside from not being sure that I exist, my name is Toby.

00:38.120 --> 00:42.280
I'm a senior info sec geek for a Fortune 50 company.

00:42.280 --> 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.

00:54.880 --> 00:57.040
And an opinion in a loud mouth.

00:57.920 --> 00:59.620
That too, you forgot to say that.

01:00.200 --> 01:01.280
My name is Mickey.

01:01.280 --> 01:03.520
I used to work for a Fortune 50 company.

01:04.740 --> 01:11.100
I used to break software firmware and hardware in my spare time and well, that's it basically.

01:19.260 --> 01:22.660
We're going to keep do-si-do-ing because we don't have wireless mics.

01:23.780 --> 01:25.680
Excuse us for being a bit rough this morning.

01:25.680 --> 01:27.500
Today we're going to go through a bunch of different things.

01:27.500 --> 01:28.920
First we're going to spend some little time.

01:28.920 --> 01:30.040
We've already talked about who we are.

01:30.040 --> 01:31.940
We're going to talk about what gadgets are.

01:32.100 --> 01:34.920
By the way, you all know we're talking about Windows gadgets, right?

01:35.280 --> 01:35.620
Yeah?

01:35.620 --> 01:36.160
We're good?

01:36.160 --> 01:36.660
Okay.

01:37.540 --> 01:40.220
We're going to tell you a little bit about what Windows gadgets are.

01:40.320 --> 01:42.640
A little history, little details about them.

01:42.640 --> 01:44.140
Then we're going to go into what's wrong with them.

01:44.140 --> 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.

01:48.880 --> 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.

01:56.640 --> 02:00.720
Long term, short term solutions that Microsoft chose and otherwise.

02:08.100 --> 02:18.780
A couple of thank yous because this talk is based on civil things made by other people.

02:19.920 --> 02:21.600
And the support of other people.

02:21.600 --> 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.

02:34.200 --> 02:38.440
But they helped us a lot with their work.

02:42.920 --> 02:45.360
Also, CG, or not.

02:45.600 --> 02:46.980
I guess we'll use that.

02:49.460 --> 02:50.800
We apologize.

02:50.800 --> 02:54.180
Clearly technology is complex and we're not very good at it.

02:54.580 --> 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.

03:09.140 --> 03:14.400
So for those of you who don't own Windows systems, what are gadgets?

03:14.400 --> 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.

03:20.580 --> 03:28.420
You can use gadgets that range from a simple clock up to GPU performance handlers.

03:29.480 --> 03:34.020
They're very simple to use.

03:34.760 --> 03:36.200
A couple of examples on screen.

03:36.200 --> 03:38.600
Those are the default Microsoft gadgets.

03:38.740 --> 03:43.540
The CPU clock, the RSS feed, and the weather.

03:47.680 --> 03:49.920
A little history about gadgets.

03:49.920 --> 03:55.660
The first references we've actually seen documented were to show the active desktop in Windows XP.

03:55.940 --> 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.

04:09.360 --> 04:14.640
So the first thing that we've seen from Windows XP is the concept of the active desktop.

04:14.720 --> 04:20.280
You could just basically run little tiny things on the desktop and get dynamic updates.

04:20.280 --> 04:21.700
It was fairly simple.

04:21.780 --> 04:26.720
In Vista, they started moving around, moving to the concept of actually having something called a gadget.

04:26.720 --> 04:28.040
They had the sidebar.

04:28.400 --> 04:29.680
It was fairly simple.

04:29.680 --> 04:30.980
We'll show you in half a second .

04:30.980 --> 04:33.100
It looked like this.

04:33.560 --> 04:35.240
Literally it was just a sidebar.

04:35.240 --> 04:40.900
All of the things ran along it and were very tightly tied to it , but they were referred to as gadgets.

04:41.600 --> 04:47.940
In Windows 7, they actually did a significant number of improvements to the capabilities .

04:47.940 --> 04:50.580
First, they combined it to a single process.

04:51.100 --> 04:53.540
They made it much easier to manage them.

04:54.780 --> 04:57.100
They could be placed all over the desktop.

04:57.100 --> 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.

05:06.520 --> 05:09.280
The development points are obviously irrelevant at this point.

05:10.060 --> 05:14.460
So Windows Vista, this is what it looked in Windows 7.

05:15.200 --> 05:18.600
We're actually both quite fond of the Pandora gadget.

05:18.600 --> 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.

05:23.360 --> 05:26.500
I think I was listening to Wien at that time.

05:28.020 --> 05:31.160
But these are some other examples besides the ones you saw previously.

05:35.240 --> 05:38.260
So the question is, why does this matter?

05:38.720 --> 05:43.100
To be quite honest, Mickey came to me and said, we should do this.

05:43.100 --> 05:45.540
And I said, why would anyone care?

05:45.580 --> 05:51.260
It took him about three weeks to convince me.

05:53.120 --> 05:54.860
Yeah, you tell me.

05:55.960 --> 05:58.260
About three weeks to convince me to do the research.

05:58.260 --> 06:01.780
And frankly, it's not news.

06:01.780 --> 06:05.180
If you write bad code, you're going to get compromised, right?

06:05.500 --> 06:11.720
If you run somebody else's code on your system, they're going to compromise you, right?

06:11.720 --> 06:13.660
This isn't novel.

06:14.420 --> 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.

06:29.060 --> 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.

06:38.720 --> 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.

06:58.580 --> 07:01.100
So a little bit of what is a gadget.

07:01.100 --> 07:03.520
A gadget is a zip file.

07:04.940 --> 07:08.860
Technically, it's a zip file renamed to be .gadget.

07:08.980 --> 07:11.520
If you didn't get that, that's cat.zip.

07:18.010 --> 07:21.190
A gadget has several screens on it.

07:22.250 --> 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.

07:30.190 --> 07:32.830
As you can see, they have correlating HTML files.

07:32.830 --> 07:40.890
This is, by the way, the simplest directory structure for a gadget.

07:40.890 --> 07:46.850
You've got a CSS folder, images folder, JavaScript folder, a couple of HTML files.

07:46.850 --> 07:52.930
This is, sorry, this is NeonCAD gadget, which you'll see soon enough.

07:54.230 --> 08:00.330
The part that is not standard is the gadget.xml, which is the gadget manifest.

08:00.330 --> 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.

08:16.910 --> 08:20.650
And, well, did I forget anything?

08:20.650 --> 08:22.510
It can get simpler.

08:23.310 --> 08:27.010
This is the template.

08:27.010 --> 08:28.510
This is the HTML template.

08:28.510 --> 08:35.150
But you can also develop gadgets with silver light, so it's even more simpler.

08:35.310 --> 08:36.690
It's simpler.

08:37.950 --> 08:40.930
English is not my first language, I apologize.

08:42.190 --> 08:47.990
WPF and silver light will make it easier to code malicious code into your gadget.

08:51.600 --> 08:54.800
So a little bit about the security model.

08:55.100 --> 08:58.220
Microsoft actually provides a very detailed explanation.

08:58.220 --> 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.

09:15.800 --> 09:21.740
They didn't, for lack of trying, we didn't see quality for lack of Microsoft trying to do it right.

09:21.800 --> 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.

09:26.160 --> 09:32.140
And if you want to see more, you can still find the documentation for it on Microsoft's site.

09:32.140 --> 09:33.760
There's a URL in the background.

09:34.820 --> 09:37.580
First, code signing is actually possible.

09:37.580 --> 09:39.000
It's not standard.

09:39.420 --> 09:40.620
It's not common.

09:40.620 --> 09:43.560
It isn't required, but it is absolutely possible.

09:44.240 --> 09:52.240
We saw out of 60 or 70 gadgets that we were able to pull down, one or two, maybe three.

09:52.980 --> 09:59.600
One single vendor and not very many gadgets from any vendor that were actually signed.

09:59.680 --> 10:05.380
The prompt looks pretty similar to the actual installation for any standard application.

10:05.380 --> 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.

10:14.700 --> 10:16.960
But as you can see, it looks pretty standard.

10:18.940 --> 10:23.980
Show of hands, who's familiar with an HTML application, HTAs?

10:24.360 --> 10:30.860
Show of hands, who can give me the square root of 1,563?

10:32.760 --> 10:35.680
Just checking that there was actually a difference in response.

10:38.080 --> 10:42.180
So, they're fairly similar to HTAs, HTML applications.

10:42.180 --> 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.

10:51.520 --> 10:54.340
And they have some limitations that aren't always in place.

10:54.700 --> 11:02.020
First, one of the advantages and something we found tremendously useful, you can instantiate any active X object on the system.

11:02.420 --> 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.

11:10.960 --> 11:13.800
However, you can't actually kick off a UAC prompt.

11:13.800 --> 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.

11:22.280 --> 11:30.600
On the other hand, any process that's been exec'd from the gadget can then itself raise a UAC prompt.

11:30.600 --> 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.

11:39.280 --> 11:42.960
Parental controls do apply as you would expect for any HTML based thing.

11:42.960 --> 11:44.760
It's running in an IE container.

11:44.760 --> 11:48.520
It's just a modified set of permissions to do so.

11:49.600 --> 11:50.200
Anything?

11:50.200 --> 11:51.360
Want to add anything?

11:52.340 --> 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.

12:00.560 --> 12:03.480
One, you can turn off the sidebar completely as a function.

12:04.060 --> 12:12.940
Two, you can set policies to control unpacking and installing of Windows gadgets that aren't signed.

12:13.760 --> 12:17.260
Unfortunately, this doesn't actually prevent somebody from installing them manually.

12:17.660 --> 12:20.240
And it doesn't remove gadgets that have already been installed.

12:20.240 --> 12:25.160
It just prevents new ones from being automatically installed when they double click and want to run them.

12:25.940 --> 12:31.840
You can disable user installed gadgets which is basically just locking down the permissions for a specific directory.

12:32.080 --> 12:38.860
And finally, you can actually override the get more gadgets online link which is now dead anyways.

12:41.560 --> 12:48.320
So at this point, normally I know the standard is to ask questions at the end.

12:48.900 --> 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?

12:56.080 --> 12:56.760
Yeah.

13:09.020 --> 13:13.240
The question was is there any concept of this moving to Windows 8.

13:13.240 --> 13:18.380
Do you mean is there anything being done in Windows 8 that has a similar sort of idea behind it?

13:18.860 --> 13:19.600
Okay.

13:21.280 --> 13:30.260
As far as I know, I guess since neither of these work for Microsoft, we can speculate wildly.

13:31.320 --> 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.

13:43.960 --> 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.

13:52.340 --> 13:53.940
Any other questions?

13:56.740 --> 13:57.680
Yeah.

13:57.680 --> 13:57.680
Okay.

14:11.760 --> 14:19.820
I think the question was is Microsoft really going to remove gadgets from Windows 8 or something?

14:20.180 --> 14:21.980
Or are they going to make it optional?

14:21.980 --> 14:24.760
Our understanding is they removed the feature completely.

14:26.820 --> 14:28.260
Other questions?

14:31.260 --> 14:32.020
Okay.

14:35.300 --> 14:36.760
Attack surface.

14:36.760 --> 14:41.480
We're going to now go into a little bit of the attacking actually through gadgets and with gadgets.

14:42.120 --> 14:45.060
We're going to start off with attacking with gadgets.

14:45.060 --> 14:52.120
One of the fundamental problems here is that it's just another piece of code somebody is running.

14:52.640 --> 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.

15:00.880 --> 15:02.500
That's what happens.

15:04.120 --> 15:08.780
Unfortunately people don't actually think of gadgets for some reason as code.

15:09.160 --> 15:10.860
We weren't quite sure why.

15:11.540 --> 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.

15:17.180 --> 15:18.760
So he took a picture of them.

15:20.400 --> 15:24.140
Honestly, they are just as dangerous as any other piece of software.

15:24.260 --> 15:26.040
So the question is what can you do with this?

15:26.040 --> 15:28.560
Well, is it really just another piece of software after all?

15:28.560 --> 15:30.320
It's just this little tiny container thing.

15:30.320 --> 15:32.780
It shouldn't have all the capabilities that you would expect.

15:33.200 --> 15:37.320
Here are some of the things that you're actually able to do from a gadget.

15:38.560 --> 15:40.740
I can't do everything I might want.

15:40.740 --> 15:42.940
Well, oh yes, wait a minute, I can.

15:42.940 --> 15:44.600
I can exec code.

15:44.840 --> 15:45.900
Do I need to say anything?

15:45.900 --> 15:50.360
Well, just in case anyone is curious, you can also open URLs.

15:51.040 --> 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.

15:59.800 --> 16:02.720
If you want to change what you downloaded, you can do that too.

16:02.720 --> 16:03.620
You want to update?

16:03.620 --> 16:04.640
No problem.

16:04.640 --> 16:08.660
You want to create files with arbitrary content, binary or otherwise on the system?

16:08.660 --> 16:09.680
We can do that.

16:09.720 --> 16:11.160
You want to be able to read files?

16:11.160 --> 16:13.840
Anything that the user has permission to, you're good for.

16:14.140 --> 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.

16:19.940 --> 16:21.520
Make your computer speak?

16:21.780 --> 16:22.440
Sure.

16:22.620 --> 16:23.620
You can do that too.

16:23.920 --> 16:26.820
And I guess we should actually show you what that looks like.

16:27.180 --> 16:28.060
Want to run it?

17:03.340 --> 17:09.860
We're going to show you a little demonstration of what you can do with a malicious gadget.

17:13.800 --> 17:23.460
This is a POC of a gadget that will self-spread to all your contacts.

17:24.420 --> 17:28.720
It is not fully weaponized, it's just a POC.

17:30.300 --> 17:34.420
A little explanation, the gadget opens Gmail.

17:34.600 --> 17:40.540
Quick question, how many of you use Gmail?

17:41.940 --> 17:50.660
How many of you make sure you log out and stop using Gmail?

17:50.660 --> 17:53.920
Every single time?

17:54.700 --> 17:57.300
How many of you are lying?

18:00.060 --> 18:02.220
That's not good.

18:11.540 --> 18:19.940
Can we get sound from... okay.

18:21.760 --> 18:24.720
I apologize in advance.

18:25.140 --> 18:26.920
You should be so ashamed.

18:42.360 --> 18:45.880
Now we are back .

18:48.020 --> 18:49.840
Create a new email.

18:52.580 --> 18:54.160
Add a subject.

18:55.980 --> 18:57.540
Add a link.

19:00.020 --> 19:02.080
And we'll send it.

19:02.640 --> 19:05.340
And when it's done it will close the window.

19:11.630 --> 19:19.790
Now, just to clarify, first of all, I would like to stress that there is no security vulnerability in Gmail.

19:21.210 --> 19:23.970
It's kind of a work around for a setting.

19:24.190 --> 19:29.350
Gmail allows users to use keyboard shortcuts.

19:30.150 --> 19:36.850
And to enable that, usually what you do is go into settings and select an option saying enable keyboard shortcuts.

19:37.130 --> 19:45.410
However, if you open a URL with KBD equals 1 in the query string, you will get that feature enabled.

19:46.510 --> 19:50.610
And gadgets very easily send keystrokes to the screen.

19:50.610 --> 19:53.390
This is the code that sends the Gmail.

19:53.390 --> 19:55.050
Sixteen lines.

19:57.250 --> 19:59.190
That's how simple this is.

20:21.440 --> 20:26.600
So, simple example, you saw what can be done.

20:26.600 --> 20:29.880
Very standard malicious sort of gadget activity.

20:30.320 --> 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.

20:39.720 --> 20:42.480
It can manipulate anything else it wants on the system.

20:42.480 --> 20:46.300
It's got all of that state that you're giving it at any point in time.

20:49.740 --> 20:51.860
Another addition.

20:52.200 --> 21:01.900
We discovered also that gadgets can also read map network drives, delete map network drives, handle map network drives, add them.

21:04.940 --> 21:09.420
Everything that Windows supports, it can do, basically.

21:09.440 --> 21:14.420
We actually ran out of time to find out all of the things we kept finding.

21:14.420 --> 21:16.980
We tried something and say, oh, that's possible.

21:16.980 --> 21:19.180
How about, oh, that's possible.

21:19.500 --> 21:21.020
It just kept going.

21:22.880 --> 21:29.360
So, you've been something, we've talked about attacking with gadgets.

21:29.360 --> 21:30.480
Simple demo.

21:30.480 --> 21:32.640
Hopefully you understand it is just a POC.

21:32.820 --> 21:35.460
The question is now, what can you do in terms of attacking gadgets?

21:35.460 --> 21:37.500
Well, unfortunately, they're just code.

21:38.060 --> 21:43.060
And in many cases, they're written by people who don't have a lot of experience writing code.

21:43.060 --> 21:49.880
It was fairly interesting as we went through the collection of gadgets and we found about, is that a question?

21:50.500 --> 21:51.960
I'm going to attack?

21:52.580 --> 21:53.260
Okay.

21:54.440 --> 22:00.040
We found about 65, 70 gadgets that were floating around that people were actually using.

22:00.600 --> 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,

22:16.260 --> 22:22.020
in which case you'd see one big HTML file that contained everything in the JavaScript.

22:22.020 --> 22:23.180
And you can do this.

22:23.180 --> 22:27.720
It's really just a web page to some extent that's running locally with a lot of extra privileges.

22:28.080 --> 22:31.260
So you'd see a lot of different styles.

22:31.260 --> 22:34.160
And of course, that leaves you with a lot of vulnerable systems.

22:34.240 --> 22:42.840
So you end up with a fairly basic strategy, which is just find some gadgets, analyze them, pause, and profit.

22:45.280 --> 22:46.720
So what did we find?

22:46.720 --> 22:52.260
Well, when you started looking around, we found a lot of sites offering malware that were claiming to be gadgets.

22:53.140 --> 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.

23:02.200 --> 23:05.160
We found really limited use of SSL.

23:05.160 --> 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.

23:13.460 --> 23:15.360
Otherwise, they didn't use it.

23:15.360 --> 23:17.740
And we actually found a couple of interesting educations.

23:18.400 --> 23:19.900
You want to give them the rundown?

23:20.360 --> 23:21.140
Yeah.

23:23.720 --> 23:28.620
We saw one use, one good use of SSL in a gadget.

23:29.540 --> 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.

23:40.420 --> 23:43.960
So all you got to do is SSL strip and you win.

23:44.720 --> 23:47.320
And this is the sort of behavior that we saw.

23:47.320 --> 23:50.340
That was actually some of the more well intentioned behavior we saw.

23:50.340 --> 23:52.260
Most of the time we didn't even see that used.

23:52.280 --> 23:56.820
So a lot of connections to ad servers that seem to have no purpose for the gadget.

23:56.820 --> 24:00.140
They never notified the user that they were being connected to.

24:00.420 --> 24:06.040
They never prompted the user for any permission or activity around it.

24:06.040 --> 24:08.040
It was just generically run.

24:09.020 --> 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.

24:17.160 --> 24:22.840
At one point, Mickey got this random text from me saying, there's something really strange going on.

24:22.840 --> 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.

24:30.780 --> 24:32.860
He said, no, that can't be right.

24:32.860 --> 24:35.120
I said, the paths are exactly the same.

24:35.240 --> 24:40.380
We start looking into the domains a little bit and they have not listed anything related between them.

24:40.380 --> 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.

24:46.300 --> 24:47.880
They're using the exact same code base.

24:47.880 --> 24:49.580
There's just no reference.

24:49.780 --> 24:50.580
Question?

24:56.630 --> 25:00.710
The question is, was there any warning for self-signed certs or anything like that?

25:00.790 --> 25:03.770
Certainly you would hope to see that and we did not.

25:05.150 --> 25:07.870
We also didn't see any prompting for cookies.

25:07.910 --> 25:11.550
Now, that may have been the configuration.

25:11.550 --> 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.

25:18.590 --> 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.

25:23.890 --> 25:25.670
This comes up a lot in any framework.

25:25.670 --> 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.

25:34.550 --> 25:39.190
This is just another instance of shared code giving you underlying problems.

25:39.190 --> 25:41.490
How many remember the ASN1 bug?

25:42.870 --> 25:45.870
One, two, really?

25:45.990 --> 25:46.950
Wow.

25:46.950 --> 25:47.830
Okay.

25:48.670 --> 25:54.370
ASN1 is an underlying parsing protocol that the U.S.

25:54.370 --> 25:55.830
government defined.

25:56.090 --> 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.

26:15.390 --> 26:20.610
So there was this really pernicious flaw that showed up everywhere because of the shared code problem.

26:20.610 --> 26:23.210
It was a long -lasting flaw.

26:23.910 --> 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.

26:32.810 --> 26:34.610
Your default permissions were full.

26:35.510 --> 26:37.850
We found it was phenomenally easy to spot.

26:37.850 --> 26:39.410
Mickey really likes this one.

26:39.410 --> 26:40.010
Yeah.

26:41.290 --> 26:43.130
This is a funny one.

26:44.210 --> 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.

26:58.130 --> 27:00.510
UA-CPU.

27:00.510 --> 27:02.890
Does anyone know what that header is?

27:04.950 --> 27:06.170
Show of hands.

27:07.050 --> 27:08.170
Okay.

27:08.570 --> 27:11.990
That header is to indicate the kind of platform you're using.

27:12.330 --> 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.

27:26.990 --> 27:33.810
UA-CPU has been used in IE3 and 4 and has not been used since.

27:34.430 --> 27:36.170
Except here.

27:36.190 --> 27:40.910
The only use that we've seen is in gadgets on 64-bit platforms.

27:40.950 --> 27:43.670
32 bits are unimportant.

27:44.570 --> 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.

27:57.630 --> 28:04.630
And we have no official numbers, but we assume that most of the Windows 7 machines are 64-bit based.

28:05.570 --> 28:07.730
So I've got to do a sniff to traffic and you'll see it.

28:07.970 --> 28:08.990
Easy to spot.

28:11.290 --> 28:12.290
It was.

28:14.850 --> 28:18.370
So SSL, we all know it's really complex.

28:18.490 --> 28:20.550
It's not like there's good references for it.

28:20.550 --> 28:22.010
It's not like it's well documented.

28:22.010 --> 28:25.010
There certainly aren't libraries that are available for everyone to use.

28:25.010 --> 28:29.770
It certainly hasn't been explained again and again and again and again and again how to do it right.

28:30.050 --> 28:33.310
So why would you expect anyone to do it properly?

28:33.310 --> 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.

28:39.870 --> 28:40.730
It's reasonable.

28:40.730 --> 28:47.210
Auto update is a reasonable thing, but what we found was you have clear text downloads of updates.

28:47.510 --> 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,

29:17.250 --> 29:19.850
to what's actually executed.

29:20.690 --> 29:27.510
This is sort of like what Charlie Milley demonstrated, except nowhere near as complex or challenging and not quite as cool.

29:27.510 --> 29:29.130
Well, nowhere near as cool, frankly.

29:29.130 --> 29:31.670
But the same sort of consequence.

29:31.690 --> 29:36.670
You think you get one thing and you get something completely different.

29:38.590 --> 29:43.350
As a result , it makes it really simple to perform a man-in-the-middle attack.

29:43.990 --> 29:52.010
As Mickey pointed out , there's a really simple HTTP header that you can check for.

29:52.550 --> 29:54.770
You can use something as simple as earphone.

29:54.950 --> 30:00.510
To be clear, the demos we're showing you and the demos that we've done, we're using a proxy.

30:00.510 --> 30:02.050
We're actually doing full man-in-the-middle.

30:02.050 --> 30:03.330
We configured a proxy.

30:03.330 --> 30:05.150
This isn't because it's required.

30:05.170 --> 30:10.170
It's because the demo gods are capricious and fickle and really, really nasty.

30:10.430 --> 30:15.730
And we just don't want to have any more variability in it than we absolutely have to.

30:15.930 --> 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.

30:23.950 --> 30:24.470
Okay.

30:48.260 --> 30:49.200
So, I'm going to talk a little bit about

30:53.210 --> 30:54.910
this for now.

30:56.190 --> 31:02.510
What we have here is a proxy running in this window, bottom right window.

31:02.790 --> 31:11.250
A proxy is set to listen to gadget traffic and intercept it and replace the response with something interesting.

31:12.550 --> 31:19.630
I'm going to display this using... yeah.

31:20.210 --> 31:23.750
I'm going to show you this.

31:23.750 --> 31:26.250
No, that was just the port that we set up for the proxy.

31:26.470 --> 31:29.170
The question was, does all gadget traffic hit 81, 81?

31:29.170 --> 31:34.790
No, that was just the proxy port that we chose because it was a nice number.

31:36.170 --> 31:38.190
No meaning otherwise.

31:43.810 --> 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.

31:52.350 --> 31:54.990
By default, it will use 443, 80.

31:55.270 --> 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.

32:01.510 --> 32:05.650
So this is the normal screen in Windows, the default gadgets.

32:05.670 --> 32:09.870
The only two different ones are the Nyan Cat, which you've already seen, and the Piano.

32:10.150 --> 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.

32:19.670 --> 32:22.050
No modifications have been done to it.

32:24.770 --> 32:28.170
Reminder, this computer is running through a proxy right now.

32:40.330 --> 32:42.610
The gadget isn't supposed to do that.

32:44.150 --> 32:46.510
That's, by the way, three lines of code.

32:49.170 --> 32:53.830
The hardest part of that was actually, well, that wasn't really a hard part of that one.

32:54.110 --> 32:55.270
That was an easy one.

32:57.450 --> 33:00.230
To be fair, your computer does complain at you a lot.

33:05.310 --> 33:09.090
Imagine hearing that when you least expect it.

33:14.060 --> 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.

33:24.900 --> 33:25.600
We've seen it before.

33:25.600 --> 33:28.600
The question is, of course, can we get a shell?

33:29.100 --> 33:31.180
That's always the real interesting question.

33:31.640 --> 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,

33:46.560 --> 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.

33:56.040 --> 33:58.640
You can write any scripting language you want to the system.

33:58.640 --> 34:00.960
You can exec anything you want.

34:00.980 --> 34:03.320
In our case, we started playing with PowerShell.

34:07.800 --> 34:15.500
So at this point, that's not what we want right now.

34:23.570 --> 34:24.650
Okay.

34:24.810 --> 34:28.350
So what you've got now is three windows.

34:29.370 --> 34:33.790
Top left is a simple HTTP web server that we set up.

34:33.910 --> 34:35.470
It's serving a shell.

34:37.070 --> 34:38.550
Serving a file.

34:38.850 --> 34:44.550
In this case, the file it's serving is a very simple metasploit interpreter reverse TCP shell.

34:45.390 --> 34:47.510
We didn't do any modifications by itself.

34:47.510 --> 34:50.630
This shell would be detected by any decent antivirus.

34:51.310 --> 34:53.970
That's purely for POC because we're lazy.

34:54.330 --> 34:59.450
The fact is obviously that you could download any binary that you want, and you could write anything you want.

35:03.510 --> 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.

35:17.130 --> 35:23.470
We're going to do one small change to payload that's delivered.

35:34.030 --> 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.

35:41.950 --> 35:43.110
It'll store things.

35:43.770 --> 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.

35:50.410 --> 35:52.070
It was more than a little frustrating.

35:52.830 --> 35:54.150
But it's pretty straightforward.

35:54.670 --> 35:58.210
What you're going to see from this side is not particularly exciting.

36:00.870 --> 36:02.150
Fairly intentionally.

36:04.730 --> 36:12.010
From this side, all you get is that.

36:13.210 --> 36:15.430
All you see is a file written to the desktop.

36:15.490 --> 36:17.710
Now, this is for a POC.

36:17.710 --> 36:19.290
We chose to write to the desktop.

36:19.310 --> 36:20.890
You can write anywhere you want.

36:20.890 --> 36:22.670
There's no reason you have to write to the desktop.

36:22.670 --> 36:25.350
You can write to the startup folder.

36:25.890 --> 36:28.870
You can write anywhere the user has permissions to.

36:28.970 --> 36:33.390
But notice that there was no prompt that you're running an unsigned binary.

36:33.390 --> 36:38.910
Notice that there was no prompt that you were kicking off anything from a script or running a script .

36:39.350 --> 36:40.410
All you saw.

36:40.570 --> 36:43.150
And one last thing, the gadget is functional.

36:45.650 --> 36:46.830
Still works.

36:46.930 --> 36:53.810
In contrast, what you see when you've got back here is that you see the request was detected and injected.

36:53.870 --> 36:58.290
You see a request here for the URL and for the file that it downloaded.

36:58.290 --> 37:03.710
And over here, what do we have but actually a Windows shell.

37:05.250 --> 37:09.270
So, you can in fact...

37:14.860 --> 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.

37:30.600 --> 37:32.400
It tries to do the right thing.

37:32.700 --> 37:41.900
However, if you run a binary from Power Script, PowerShell, it doesn't warn you at all.

37:42.100 --> 37:46.500
Now, of course, the default policy for PowerShell is you can't run scripts on the system.

37:47.180 --> 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.

37:58.360 --> 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,

38:18.780 --> 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.

38:27.280 --> 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.

38:35.440 --> 38:36.740
So,

38:43.580 --> 38:49.560
at this point you can see, we feel pretty comfortable that you've got complete compromise of the system.

38:49.640 --> 38:54.360
We've owned it, you've got shell, we can do this with anything you're asking for JavaScript from.

38:54.600 --> 38:57.340
Anytime you ask for JavaScript with a gadget, we can do this.

38:58.040 --> 38:59.760
What do you do about this?

39:00.460 --> 39:04.140
It's fun to find flaws, but you've got to find something you can do about this.

39:04.140 --> 39:11.220
Well, at a basic level, if you're going to write applications, you have to remember code is code.

39:11.220 --> 39:12.540
It's going to be vulnerable.

39:12.540 --> 39:17.200
If you're going to download and execute stuff, don't take candy from strangers.

39:17.200 --> 39:20.140
Think about what you're downloading, think about what you're executing.

39:21.340 --> 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.

39:32.060 --> 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.

39:42.900 --> 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.

39:57.980 --> 40:04.820
They're moving into the Windows Store, they've updated all the documentation for developers and everything else.

40:14.550 --> 40:18.630
This research could not have been done without the help of others.

40:20.650 --> 40:22.750
Interesting history.

40:22.890 --> 40:29.390
The three CVEs you see are remote code execution in default, Windows, Gadgets and Vista.

40:29.790 --> 40:33.650
Reported by Aviv Raf in 2007.

40:33.850 --> 40:35.550
That's five years ago.

40:38.050 --> 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.

40:51.410 --> 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.

41:08.030 --> 41:09.570
We couldn't have done it without them.

41:11.790 --> 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.

41:19.310 --> 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.

41:24.350 --> 41:28.230
So I guess maybe we'll move to the Q&A room and take questions there.

41:29.190 --> 41:30.050
Thank you.

