start	end	text
0	2900	My name is Toby, this is Mickey. We're glad you could make it
2900	5280	this morning. We're going to talk to you about Windows
5280	12540	gadgets. First, our standard disclaimer, none of this has
12540	15700	anything to do with anyone we've ever worked for, do work for or
15700	17700	might ever work for in the future. We have our own
17700	20140	opinions. They have no opinions about anything and the two
20140	23280	connections aren't connected in absolutely no way, shape or
23280	26180	form. They have no knowledge of anything we do ever and they're
26180	35040	not even sure we exist. Well, aside from not being sure that I
35040	41300	exist, my name is Toby. I'm a senior info sec geek for a
41300	45460	Fortune 50 company. I do all sorts of things that mostly
45460	48500	involve telling people their ideas are bad and then trying to
48500	50800	keep their ideas from being compromised once they insist on
50800	58120	doing them anyways. And an opinion in a loud mouth. That
58120	61860	too, you forgot to say that. My name is Mickey. I used to work
61860	66600	for a Fortune 50 company. I used to break software firmware and
66600	79660	hardware in my spare time and well, that's it basically. We're
79660	81900	going to keep do-si-do-ing because we don't have wireless
81900	86040	mics. Excuse us for being a bit rough this morning. Today we're
86040	87820	going to go through a bunch of different things. First we're
87820	89700	going to spend some little time. We've already talked about who
89700	92420	we are. We're going to talk about what gadgets are. By the
92420	94920	way, you all know we're talking about Windows gadgets, right?
95280	98560	Yeah? We're good? Okay. We're going to tell you a little bit
98560	102220	about what Windows gadgets are. A little history, little details
102220	104140	about them. Then we're going to go into what's wrong with them.
104140	106420	We're going to talk about first attacking with gadgets and then
106420	109180	we're going to talk about how you can attack gadgets. Then
109180	113220	we'll spend a little bit of time talking about once it's all done
113770	116980	what you can do about it and what the solutions are. Long
116980	120720	term, short term solutions that Microsoft chose and otherwise.
128100	135260	A couple of thank yous because this talk is based on civil
136740	141680	things made by other people. And the support of other people. So
141680	146020	I'd like to thank Ethics, Ian, Jason Street, SoftSec folks,
146020	152800	Wim, Aviv, Raph, Galdiskin, and Suzuki, Sal, Mitsuki, Mitku, I
152800	157480	don't think I pronounced that. But they helped us a lot with
157480	170000	their work. Also, CG, or not. I guess we'll use that. We
170000	173320	apologize. Clearly technology is complex and we're not very good
173320	179620	at it. Also, CG from Carnal Ownage blog for his work on
179620	184600	PowerShell bypass, PowerShell Metasploit, and just being a lot
184600	192260	of fun to read. So for those of you who don't own Windows
192260	195960	systems, what are gadgets? Gadgets are those tiny little
195960	198560	applications you have on your desktop and you do a right click
198560	204520	and it's like gadgets. You can use gadgets that range from a
204520	209660	simple clock up to GPU performance handlers. They're
209660	216440	very simple to use. A couple of examples on screen. Those are
216440	222620	the default Microsoft gadgets. The CPU clock, the RSS feed, and
222620	230380	the weather. A little history about gadgets. The first
230380	233200	references we've actually seen documented were to show the
233200	237280	active desktop in Windows XP. Over the course of the last week
237280	239280	or so, we've had a couple of people mention that they
239280	242160	remember seeing similar things that there was actually an
242160	246580	active desktop in 98 as well, but we weren't able to find any
246580	249560	traces of it or any documentation on it. So the
249560	253560	first thing that we've seen from Windows XP is the concept of
253560	256280	the active desktop. You could just basically run little tiny
256280	260840	things on the desktop and get dynamic updates. It was fairly
260840	264140	simple. In Vista, they started moving around, moving to the
264140	266840	concept of actually having something called a gadget. They
266840	270740	had the sidebar. It was fairly simple. We'll show you in half a
270740	275340	second. It looked like this. Literally it was just a sidebar.
275340	278700	All of the things ran along it and were very tightly tied to
278700	283380	it, but they were referred to as gadgets. In Windows 7, they
283380	287280	actually did a significant number of improvements to the
287740	291540	capabilities. First, they combined it to a single process.
291540	295400	They made it much easier to manage them. They could be
295400	300160	placed all over the desktop. They also added a number of new
300160	303280	capabilities to make it easier to develop and they added a
303280	307500	bunch of enterprise security features. The development points
307500	312960	are obviously irrelevant at this point. So Windows Vista, this is
312960	317340	what it looked in Windows 7. We're actually both quite fond
317340	320380	of the Pandora gadget. It's a fairly handy thing to have and
320380	323360	it's literally just a way to listen to Pandora on the system.
323360	328580	I think I was listening to Wien at that time. But these are
328580	336440	some other examples besides the ones you saw previously. So the
336440	340700	question is, why does this matter? To be quite honest,
340700	344400	Mickey came to me and said, we should do this. And I said, why
344400	350460	would anyone care? It took him about three weeks to convince
350460	357520	me. Yeah, you tell me. About three weeks to convince me to
357520	362740	do the research. And frankly, it's not news. If you write bad
362740	366380	code, you're going to get compromised, right? If you run
366380	370380	somebody else's code on your system, they're going to
370380	376160	compromise you, right? This isn't novel. Turns out, though,
376880	381220	the same issues that made this an actual interesting target and
381360	385740	a problem are being moved forward consistently as a clear
385740	390380	and enthusiastic business model. We're seeing everything being
390380	393260	done by vendors to try and make it easier and easier for people
393260	396240	who have less and less experience and knowledge about
396240	399840	development to actually do development. And so the sorts of
399840	404100	mistakes that we found and that we were able to exploit and take
404100	406920	advantage of on these systems are going to continue being
406920	410560	common as long as you can do something as silly as write an
410560	419960	entire application in JavaScript and HTML. So a little bit of
419960	426240	what is a gadget. A gadget is a zip file. Technically, it's a
426240	429960	zip file renamed to be .gadget. If you didn't get that, that's
429960	443450	cat.zip. A gadget has several screens on it. The main one,
443450	447870	which you see when you use a gadget, there is an about, a fly
447870	451050	out, and a setting screen. As you can see, they have
451050	456790	correlating HTML files. This is, by the way, the simplest
459090	462250	directory structure for a gadget. You've got a CSS folder,
462250	466850	images folder, JavaScript folder, a couple of HTML files.
466850	471910	This is, sorry, this is NeonCAD gadget, which you'll see soon
471910	478670	enough. The part that is not standard is the gadget.xml,
478670	482670	which is the gadget manifest. It holds the information on a
482670	489250	gadget, manufacturer, copyright, URLs, permission level, which is
489250	492350	always set to full and is expected to be full by
492350	501050	Microsoft for some reason. And, well, did I forget anything? It
501050	507770	can get simpler. This is the template. This is the HTML
507770	511730	template. But you can also develop gadgets with silver
511730	518670	light, so it's even more simpler. It's simpler. English
518670	523350	is not my first language, I apologize. WPF and silver light
523350	527990	will make it easier to code malicious code into your gadget.
531600	535520	So a little bit about the security model. Microsoft
535520	538660	actually provides a very detailed explanation. We were
538660	542680	surprised by how much effort Microsoft has put in to
542680	545580	documenting the security model and to documenting good security
545580	548700	practices for writing gadgets, especially considering the
548700	553300	general lack of security quality we found in the development of
553300	559540	gadgets. They didn't, for lack of trying, we didn't see quality
559540	562280	for lack of Microsoft trying to do it right. What we're going to
562280	564220	do though is we're going to call out some of the highlights of
564220	569260	the security model. And if you want to see more, you can still
569260	572780	find the documentation for it on Microsoft's site. There's a URL
572780	577580	in the background. First, code signing is actually possible.
577580	581740	It's not standard. It's not common. It isn't required, but
581740	588080	it is absolutely possible. We saw out of 60 or 70 gadgets that
588080	594260	we were able to pull down, one or two, maybe three. One single
594260	598200	vendor and not very many gadgets from any vendor that were
598200	601280	actually signed. The prompt looks pretty similar to the
601280	606160	actual installation for any standard application. The action
606160	608880	behind it is much less complex in that it's just dropping
608880	612980	everything into a directory, but making a couple configuration
612980	615960	changes, very small stuff. But as you can see, it looks pretty
615960	621260	standard. Show of hands, who's familiar with an HTML
621260	627480	application, HTAs? Show of hands, who can give me the
627480	634180	square root of 1,563? Just checking that there was actually
634300	640680	a difference in response. So, they're fairly similar to HTAs,
640680	644140	HTML applications. There are some differences in that they
644140	647040	still run in the local machine zone, but they have some
647040	650160	additional privileges that you wouldn't otherwise be able to
650160	652960	take advantage of. And they have some limitations that aren't
652960	657300	always in place. First, one of the advantages and something we
657300	660580	found tremendously useful, you can instantiate any active X
660580	664700	object on the system. Doesn't matter what it's for, doesn't
664700	667400	matter whether it's a reasonable or sane thing to be able to do
667400	671480	from an HTML function, you can do it from here. However, you
671480	674560	can't actually kick off a UAC prompt. Doesn't matter what
674560	677840	privilege you're actually running as for the user, this is
677840	680180	always going to run as a standard user, even if you're in
680180	684720	the admin group. On the other hand, any process that's been
684720	690600	exec'd from the gadget can then itself raise a UAC prompt. And
690600	694800	since you can use, for instance, the active X shell.run function
694800	698180	or shell.exec function, you can still pretty much do what you
698180	700980	want from here. Parental controls do apply as you would
700980	704760	expect for any HTML based thing. It's running in an IE container.
704760	710200	It's just a modified set of permissions to do so. Anything?
710200	713960	Want to add anything? Some of the enterprise features that
713960	716760	were added in Windows 7, there are a couple of basic things
716760	719920	that you can use, you do via GPO, you can manage them in a
719920	722420	couple of different ways. One, you can turn off the sidebar
722420	728720	completely as a function. Two, you can set policies to control
729180	732940	unpacking and installing of Windows gadgets that aren't
733760	735840	signed. Unfortunately, this doesn't actually prevent
735840	739160	somebody from installing them manually. And it doesn't remove
739160	741560	gadgets that have already been installed. It just prevents new
741560	743800	ones from being automatically installed when they double click
743800	748320	and want to run them. You can disable user installed gadgets
748320	750880	which is basically just locking down the permissions for a
750880	754280	specific directory. And finally, you can actually override the
754280	763040	get more gadgets online link which is now dead anyways. So at
763040	767580	this point, normally I know the standard is to ask questions at
767580	771060	the end. Feel free though, does anyone have any questions about
771060	772820	anything we've covered on the development side of it that you
772820	790640	want to ask now? Yeah. The question was is there any
790640	794740	concept of this moving to Windows 8. Do you mean is there
794740	797340	anything being done in Windows 8 that has a similar sort of idea
797340	806240	behind it? Okay. As far as I know, I guess since neither of
806240	812080	these work for Microsoft, we can speculate wildly. But as far as
812080	816780	we know, you've got the metro app store sort of thing that is
816780	820760	similar, but it's wrapped in the app container capability which
820760	825440	locks it down much, much more tightly. And I haven't looked at
825440	828440	the development for the metro app so I don't know if you know
828440	837680	anything about metro app. Any other questions? Yeah. Okay.
851760	855880	I think the question was is Microsoft really going to remove
855880	861060	gadgets from Windows 8 or something? Or are they going to
861060	863500	make it optional? Our understanding is they removed
863500	876760	the feature completely. Other questions? Okay. Attack surface.
876760	878720	We're going to now go into a little bit of the attacking
878720	882900	actually through gadgets and with gadgets. We're going to
882900	885760	start off with attacking with gadgets. One of the fundamental
885760	890980	problems here is that it's just another piece of code somebody
890980	897540	is running. We've all known for 20 years that if you download
897540	901160	and run someone's code, you're going to get compromised. That's
901160	906260	what happens. Unfortunately people don't actually think of
906260	910860	gadgets for some reason as code. We weren't quite sure why.
911540	914320	Mickey speculated that it was because they're cute and small
914320	917660	and run around with little hats and pants on all the time. So he
917660	921920	took a picture of them. Honestly, they are just as
921920	924860	dangerous as any other piece of software. So the question is
924860	927220	what can you do with this? Well, is it really just another
927220	929620	piece of software after all? It's just this little tiny
929620	931760	container thing. It shouldn't have all the capabilities that
931760	934800	you would expect. Here are some of the things that you're
934800	940040	actually able to do from a gadget. I can't do everything I
940040	944600	might want. Well, oh yes, wait a minute, I can. I can exec code.
944840	948600	Do I need to say anything? Well, just in case anyone is curious,
948600	952620	you can also open URLs. So if you didn't want to carry
952620	955940	something with you in the HTML that you're downloading with the
955940	961000	gadget, you can go get more. If you want to change what you
961000	964640	downloaded, you can do that too. You want to update? No problem.
964640	967500	You want to create files with arbitrary content, binary or
967500	970500	otherwise on the system? We can do that. You want to be able to
970500	972980	read files? Anything that the user has permission to, you're
972980	976140	good for. And if you want to get past that permission, obviously
976140	979860	you can just spawn something and raise the UAC prompt and do so.
979940	984880	Make your computer speak? Sure. You can do that too. And I guess
984880	988060	we should actually show you what that looks like. Want to run it?
1023340	1028080	We're going to show you a little demonstration of what you can do
1028080	1042080	with a malicious gadget. This is a POC of a gadget that will self-spread to all your
1042080	1052940	contacts. It is not fully weaponized, it's just a POC. A little explanation, the gadget
1052940	1067220	opens Gmail. Quick question, how many of you use Gmail? How many of you make sure you log
1067220	1082220	out and stop using Gmail? Every single time? How many of you are lying? That's not good.
1091540	1125280	Can we get sound from... okay. I apologize in advance. You should be so ashamed. Now we
1125280	1143740	are back. Create a new email. Add a subject. Add a link. And we'll send it. And when it's
1143740	1157610	done it will close the window. Now, just to clarify, first of all, I would like to stress that
1157610	1163970	there is no security vulnerability in Gmail. It's kind of a work around for a setting.
1164190	1172110	Gmail allows users to use keyboard shortcuts. And to enable that, usually what you do is go
1172110	1179010	into settings and select an option saying enable keyboard shortcuts. However, if you open a
1179010	1187350	URL with KBD equals 1 in the query string, you will get that feature enabled. And gadgets
1188170	1193990	very easily send keystrokes to the screen. This is the code that sends the Gmail. Sixteen
1193990	1226800	lines. That's how simple this is. So, simple example, you saw what can be done. Very
1226800	1232940	standard malicious sort of gadget activity. The key is that it's got all of the access it
1232940	1237760	needs to all of your cookies and all of the information in your browser, which means it also
1237760	1242580	has your proxy configurations. It can manipulate anything else it wants on the system. It's
1242580	1252420	got all of that state that you're giving it at any point in time. Another addition. We
1252420	1259580	discovered also that gadgets can also read map network drives, delete map network drives,
1259580	1269420	handle map network drives, add them. Everything that Windows supports, it can do, basically.
1269440	1274720	We actually ran out of time to find out all of the things we kept finding. We tried
1274720	1281020	something and say, oh, that's possible. How about, oh, that's possible. It just kept going.
1282880	1290480	So, you've been something, we've talked about attacking with gadgets. Simple demo.
1290480	1294560	Hopefully you understand it is just a POC. The question is now, what can you do in terms of
1294560	1299580	attacking gadgets? Well, unfortunately, they're just code. And in many cases, they're
1299580	1303620	written by people who don't have a lot of experience writing code. It was fairly
1303620	1309120	interesting as we went through the collection of gadgets and we found about, is that a
1309120	1318180	question? I'm going to attack? Okay. We found about 65, 70 gadgets that were floating
1318180	1322840	around that people were actually using. And it was very easy to distinguish between the
1322840	1326360	gadgets that were written by people who were used to doing development and they'd break it
1326360	1330060	down as you'd expect with any developer in terms of having separate files for different
1330060	1335080	function families and all sorts of clean object-oriented design and people who were used
1335080	1340860	to doing web development, in which case you'd see one big HTML file that contained
1340860	1345140	everything in the JavaScript. And you can do this. It's really just a web page to some
1345140	1350280	extent that's running locally with a lot of extra privileges. So you'd see a lot of
1350280	1354700	different styles. And of course, that leaves you with a lot of vulnerable systems. So you end
1354700	1361340	up with a fairly basic strategy, which is just find some gadgets, analyze them, pause,
1361340	1369220	and profit. So what did we find? Well, when you started looking around, we found a lot of
1369220	1374520	sites offering malware that were claiming to be gadgets. We found a fair number of
1374520	1379460	gadgets, but we found more in terms of total number of sites that were offering it, there
1379460	1384480	was more malware out there than there were actual gadgets. We found really limited use of
1384480	1390020	SSL. In fact, the only consistent cases that we found SSL being used were in the cases
1390020	1395360	where the websites that were being connected to required it. Otherwise, they didn't use it.
1395360	1399900	And we actually found a couple of interesting educations. You want to give them the rundown?
1400360	1412980	Yeah. We saw one use, one good use of SSL in a gadget. But the funny thing was that the
1412980	1418620	website hosting the file that was being accessed through SSL also hosted it in normal
1418620	1426660	HTTP. So all you got to do is SSL strip and you win. And this is the sort of behavior that we
1426660	1430740	saw. That was actually some of the more well intentioned behavior we saw. Most of the time
1430740	1434980	we didn't even see that used. So a lot of connections to ad servers that seem to have no
1434980	1440800	purpose for the gadget. They never notified the user that they were being connected to. They
1440800	1447280	never prompted the user for any permission or activity around it. It was just generically
1447280	1454060	run. We also found that there were a small number of producers that produced all the gadgets
1454060	1459600	which meant that there was a lot of shared code. At one point, Mickey got this random text
1459600	1463940	from me saying, there's something really strange going on. I've got gadgets that are coming
1463940	1469660	from different sources that have the exact same update patterns in their fully qualified
1469660	1475640	domains. He said, no, that can't be right. I said, the paths are exactly the same. We start
1475640	1479780	looking into the domains a little bit and they have not listed anything related between
1479780	1484840	them. We find out they're owned by the same company and that the developers are the same
1484840	1488720	and all of a sudden it makes sense. They're using the exact same code base. There's just no
1488720	1500010	reference. Question? The question is, was there any warning for self-signed certs or anything
1500010	1506390	like that? Certainly you would hope to see that and we did not. We also didn't see any
1506390	1512370	prompting for cookies. Now, that may have been the configuration. I don't think so because
1512370	1515550	we tried it with about half a dozen different configurations and it just didn't seem to
1515550	1521110	prompt the way you would expect. So the interesting thing is that if you find something in
1521110	1524850	one gadget, you're probably going to find it in other ones as well. This comes up a lot in
1524850	1528670	any framework. If you're building a framework and a lot of these are built from simple
1528670	1536310	frameworks, you're going to end up with shared flaws. This is just another instance of
1536970	1544810	shared code giving you underlying problems. How many remember the ASN1 bug? One, two,
1544810	1554650	really? Wow. Okay. ASN1 is an underlying parsing protocol that the U.S. government
1554650	1566210	defined. They offered a reference implementation of it that nobody bothered to use as a
1566750	1576230	baseband for satellites, cable, ISDN, SNMP, everything uses ASN1. So there was this really
1576230	1581710	pernicious flaw that showed up everywhere because of the shared code problem. It was a
1581710	1589370	long-lasting flaw. So like we said, we found a bunch of actual really poor practices which
1589370	1596190	led us to plenty of options for how to inject code. Your default permissions were full. We
1596190	1602310	found it was phenomenally easy to spot. Mickey really likes this one. Yeah. This is a funny
1602310	1607770	one. As we were looking through traffic, seeing what the gadgets send through HTTP
1607770	1614910	requests, on 64-bit platforms we noticed that gadgets will send a request, every request will
1614910	1626170	be sent with an HTTP header. UA-CPU. Does anyone know what that header is? Show of hands.
1627050	1634250	Okay. That header is to indicate the kind of platform you're using. As far as I know, I can
1634250	1645090	tell from the large scope searches I did online and Wikipedia, which is not really accurate
1645090	1656170	most of the times. UA-CPU has been used in IE3 and 4 and has not been used since. Except here.
1656190	1663670	The only use that we've seen is in gadgets on 64-bit platforms. 32 bits are unimportant.
1664570	1671530	More interesting thing is most of the systems that I've been in contact with through all my
1672310	1679070	corporate life experience have been Windows 64-bit machines. And we have no official
1679070	1686110	numbers, but we assume that most of the Windows 7 machines are 64-bit based. So I've got to do
1686270	1697410	a sniff to traffic and you'll see it. Easy to spot. It was. So SSL, we all know it's really
1697410	1702010	complex. It's not like there's good references for it. It's not like it's well documented.
1702010	1705670	There certainly aren't libraries that are available for everyone to use. It certainly hasn't
1705670	1711510	been explained again and again and again and again and again how to do it right. So why
1711510	1715470	would you expect anyone to do it properly? And since you can't expect someone to do it
1715470	1719870	properly, what you end up with is a strange habit where gadgets want to update themselves.
1719870	1725510	It's reasonable. Auto update is a reasonable thing, but what we found was you have clear text
1725510	1733970	downloads of updates. And since gadgets are written in JavaScript and HTML, what you've got
1733970	1741230	is clear text download of JavaScript and HTML, which is then fully updating the entire
1741230	1748310	cache of the gadget itself, which means you've just replaced all of the code for the gadget,
1748310	1752610	which unfortunately means that whatever you looked at at the beginning may have absolutely
1752610	1761530	no reference or relevance to what is actually going on, to what's actually executed. This is
1761530	1765290	sort of like what Charlie Milley demonstrated, except nowhere near as complex or
1765290	1770830	challenging and not quite as cool. Well, nowhere near as cool, frankly. But the same sort of
1770830	1779450	consequence. You think you get one thing and you get something completely different. As a
1779450	1785150	result, it makes it really simple to perform a man-in-the-middle attack. As Mickey pointed
1785150	1793870	out, there's a really simple HTTP header that you can check for. You can use something as
1793870	1799230	simple as earphone. To be clear, the demos we're showing you and the demos that we've done,
1799230	1803490	we're using a proxy. We're actually doing full man-in-the-middle. We configured a proxy. This
1803490	1809130	isn't because it's required. It's because the demo gods are capricious and fickle and really,
1809130	1814750	really nasty. And we just don't want to have any more variability in it than we absolutely
1814750	1820710	have to. There's no reason that you couldn't just do a race attack and do an injection without
1820710	1849200	actually having to use a proxy for this. Okay. So, I'm going to talk a little bit about
1853210	1863010	this for now. What we have here is a proxy running in this window, bottom right window. A
1863010	1868930	proxy is set to listen to gadget traffic and intercept it and replace the response with
1868930	1880950	something interesting. I'm going to display this using... yeah. I'm going to show you
1883350	1887550	this. No, that was just the port that we set up for the proxy. The question was, does all
1887550	1894110	gadget traffic hit 81, 81? No, that was just the proxy port that we chose because it was a
1894110	1906530	nice number. No meaning otherwise. The question is, is it typically using any... gadget
1906530	1911530	traffic is just running in an IE process, so it's going to use whatever ports IE is
1911530	1917150	configured to use. By default, it will use 443, 80. If you've got a proxy that's on an
1917150	1922690	off-numbered port, it will use whatever is on the off-numbered port. So this is the normal
1922690	1927710	screen in Windows, the default gadgets. The only two different ones are the Nyan Cat, which
1927710	1934110	you've already seen, and the Piano. The Piano gadget is, this one is exactly the one that was
1934110	1941090	in the Microsoft gallery, live gallery, before they killed it. No modifications have been
1941090	1961430	done to it. Reminder, this computer is running through a proxy right now. The gadget isn't
1961430	1970450	supposed to do that. That's, by the way, three lines of code. The hardest part of that was
1970450	1978270	actually, well, that wasn't really a hard part of that one. That was an easy one. To be fair,
1978270	1989090	your computer does complain at you a lot. Imagine hearing that when you least expect it.
1994060	2001000	So the simple example we gave you of running just injection, making your computer say
2001000	2006240	something, this is kind of cute, trite, a little silly. We've seen it before. The question is,
2006240	2012520	of course, can we get a shell? That's always the real interesting question. And the
2012520	2017960	interesting thing is, as we said, since you've just got the ability to write anything you want
2017960	2023140	to the system, and you've got the updates in many cases, or not even the updates, you've got
2023140	2028640	the request for HTML and JavaScript running in clear text, and it's going to then go execute
2028640	2036020	your JavaScript and parse your HTML, you've got a tremendous amount of power in the process.
2036040	2040960	You can write any scripting language you want to the system. You can exec anything you want.
2040980	2054480	In our case, we started playing with PowerShell. So at this point, that's not what we want
2054480	2072190	right now. Okay. So what you've got now is three windows. Top left is a simple HTTP web
2072190	2080130	server that we set up. It's serving a shell. Serving a file. In this case, the file it's
2080130	2086090	serving is a very simple metasploit interpreter reverse TCP shell. We didn't do any
2086090	2091790	modifications by itself. This shell would be detected by any decent antivirus. That's
2091790	2096810	purely for POC because we're lazy. The fact is obviously that you could download any binary
2096810	2105730	that you want, and you could write anything you want. In the upper right corner, you've got
2106290	2112510	metasploit waiting for a connection, and as Mickey already showed you, you've got a proxy in
2112510	2135450	this corner. We're going to do one small change to payload that's delivered. Because it is a
2135450	2141270	gadget just like, or because it runs in the IE process, you've basically still got to clear
2141270	2147010	the cache. It'll store things. There were a number of times where one of us or the other
2147010	2150870	would forget and try to figure out why something suddenly stopped working. It was more
2150870	2155990	than a little frustrating. But it's pretty straightforward. What you're going to see from
2155990	2169470	this side is not particularly exciting. Fairly intentionally. From this side, all you get is
2171410	2178350	that. All you see is a file written to the desktop. Now, this is for a POC. We chose to write
2178350	2182190	to the desktop. You can write anywhere you want. There's no reason you have to write to the
2182190	2187690	desktop. You can write to the startup folder. You can write anywhere the user has
2187690	2193390	permissions to. But notice that there was no prompt that you're running an unsigned binary.
2193390	2198430	Notice that there was no prompt that you were kicking off anything from a script or running a
2198430	2207750	script. All you saw. And one last thing, the gadget is functional. Still works. In contrast,
2207750	2212830	what you see when you've got back here is that you see the request was detected and
2212830	2218530	injected. You see a request here for the URL and for the file that it downloaded. And over
2218530	2235820	here, what do we have but actually a Windows shell. So, you can in fact... Now, the
2235820	2243320	interesting thing about this is that if you run the exact function from JavaScript, it will
2243340	2248920	warn the user that you are trying to execute something that's not signed, that was
2248920	2256600	downloaded from an untrusted zone. It tries to do the right thing. However, if you run a
2256600	2263400	binary from Power Script, PowerShell, it doesn't warn you at all. Now, of course, the
2263400	2268580	default policy for PowerShell is you can't run scripts on the system. Luckily, CG and some
2268580	2273000	of the other folks out there have been looking around and talking about PowerShell attacks
2273000	2280180	and documented some really nice PowerShell policy bypasses. So what we're actually doing in
2280180	2286740	this attack is we are using JavaScript to write, first to pull down the binary onto the
2286740	2291500	system, then it writes a PowerShell script which is meant to execute the binary and then it
2291500	2297000	writes a batch file which is used to bypass the PowerShell policy so that you've got a batch
2297000	2302200	script running PowerShell, executing the shell, the result of which is the user sees
2302200	2308080	nothing and it bypasses all of the basic controls on the system to do so. It was actually
2308080	2311780	mostly the pain in the neck of getting all of that escaping properly set up between
2311780	2326740	multiple languages and getting it to write to the disk. So, at this point you can see, we feel
2326740	2330560	pretty comfortable that you've got complete compromise of the system. We've owned it, you've
2330560	2335240	got shell, we can do this with anything you're asking for JavaScript from. Anytime you ask
2335240	2341420	for JavaScript with a gadget, we can do this. What do you do about this? It's fun to find
2341420	2346960	flaws, but you've got to find something you can do about this. Well, at a basic level, if
2346960	2351660	you're going to write applications, you have to remember code is code. It's going to be
2351660	2357200	vulnerable. If you're going to download and execute stuff, don't take candy from strangers.
2357200	2362180	Think about what you're downloading, think about what you're executing. If you're someone
2362180	2366700	involved in writing an application framework, and this is an open request to anyone writing
2366700	2371020	application frameworks, if it matters that something be done properly, don't leave it to
2371020	2378780	chance. The easier you make it for people to write code, the less well written the code will
2378780	2383820	be and the less experience they're going to have writing code. Finally, there's always
2383820	2390040	Microsoft's solution, which is they removed the feature completely and they moved over to
2390040	2394580	the Windows 8 model, which has the app container instead, which has much, much tighter
2394580	2402260	controls over it completely. They're moving into the Windows Store, they've updated all the
2402260	2416750	documentation for developers and everything else. This research could not have been done
2416750	2425470	without the help of others. Interesting history. The three CVEs you see are remote code
2425470	2434410	execution in default, Windows, Gadgets and Vista. Reported by Aviv Raf in 2007. That's five
2434410	2446330	years ago. There's been prior work by Ian and Aviv on DEF CON 15 and Yitzik and Yoratan for
2446330	2454490	the jinx malware for a lot of reference. Even though it's not listed under the references, the
2454490	2460310	fact is that all of the functions we found, the PowerShell policy bypass, all of those
2460310	2464790	things, we borrowed proudly and stole enthusiastically from people who did and
2464790	2468390	published and were good enough to share the original research that they found. We couldn't
2468390	2475710	have done it without them. So if you've got any interest, there's additional references here
2475710	2480430	and at this point, if you've got questions, we're happy to take them. And we've got only a
2480430	2485770	couple of minutes, after that we're going to be in the Q&A room number four. So I guess maybe
2485770	2490050	we'll move to the Q&A room and take questions there. Thank you.
