What's up, guys? Oh, God. You guys are nuts. Look at this freaking crowd. All right, we have so much stuff to go over. Let's break some things, eh? But the beer is all the way over there, and I'm here, and the wire doesn't move. Oh, wait. Oh, wait. All right, so this is my seventh talk here, and for people who have been coming to my talks for a while, this is the freaking remix. There are little pieces of all the old talks that have been abused in really new ways. And why? I have discovered the web, and it is glorious. Oh, dear, that's totally not a moon. That's a web browser. Okay, they say this is like a new, new operating system. No, no, no, it's a new network stack, but you get to, like, send it code to teach it how to parse your packets. Holy hell. Oh, and, you know, just to make sure I'm not being too abusive here, oh, oh, oh, iPhone's in on it, too. The best part was not having to Photoshop the scene. It looks enough like an iPhone already. All right, so this is where the wild stuff seems to be lately. We're just cross-site scripting and cross-site request forgery have gotten ridiculous in terms of what they can do. The Super Bowl, we had a WMF attack. Oh, day. Two days before the Super Bowl, malicious image placed on this site. These guys got a couple million boxes. But then, then this is what really caught my attention. And this was actually the DNS rebinding test by a group at Stanford run by Dan Bonet. Actually, there's one of the guys that's actually here from it. His name's Andrew Bortz. His alias is Abortz. This is awesome. So what these guys did, you know, we've all known in the security realm, that ad networks are like the way to put crap on lots and lots of different places. And it's been a bit of a problem lately. Well, what they did is they put an ad on lots and lots of places and they were a bit of a problem. They had their little applet. It got network connectivity to all these different networks. And they got like in for 50 bucks, 100,000 networks. Whoa. So you have my attention. You know, I was trying not to look at DNS anymore. You know, I've really kind of, you know, I did DNS over DNS. What more could there possibly be? Okay. When the words DNS, tunneling, and behind firewalls come up, my ears prick up like, ooh, this sounds like fun. So it turns out what we're talking about is an old, old, old, old, old bug. This goes back to like 1996. People dealt with it back then and promptly forgot about it. But you know what's great about design bugs? They freaking come back from the dead. They're like zombies. What Benet's group found is that they're like, you know, what happened is Martin Johns went ahead, revived the attack, said, hey, look, all this stuff from 11 years ago works against Flash and Java and MSXML and all these other things. Benet started going after it. R Snake went, started looking after it. And so I got in. Now, the effect of this bug, and I'm going to explain it, is that it breaks the security policy of the web. You know, nothing important. So to understand what's going on, we're going to start from scratch here. The web is interesting. On the web, components are pulled in from all over the place. You can get an image from over here. You can get some text from over there. Maybe you get a little JavaScript. You know, you can even embed an entirely different web page inside of the web page you're looking at. This is what's called an iframe. And it's a little window that can actually be any web page on the internet. Now, from a security perspective, this could be scary, you know? What if you had a little window that was Hotmail? And what if you were logged into Hotmail? Would this other site that created the little window, would it be able to read your mail? Well, the answer is actually no. They have something called the same origin policy, which you can think of as look, but don't touch. A web page, any web page you go to, can go ahead and they can embed Hotmail. They can show it to you. You can even read your mail inside the little embedding. They can show it to you, but they don't get to programmatically read it themselves. So the model is that you get to look inside your things from your own site, but not from others. So if foo.com has an iframe to foo.com, yeah, I can look inside, change things, update it, whatever. But if foo.com has an iframe to bar.com, nah, not as much access at all. So it's a reasonable security policy, right? You know, two things come from the same place. They must be trusted the same. And of course, same place equals the same name, right? No. The problem is, is that, names don't host anything on the internet. Everything comes from IP addresses. So we use DNS to convert between a name, foo.com, to an IP address, 1.2.3.4. Now, the assumption is that the translation between foo and 1.2.3.4 is relatively static. It doesn't change much. It is what it is. And you know, foo.com would only return its own IP addresses. No. Foo.com can return whatever it damn well pleases, whenever it damn well pleases. The problem is, foo.com can return IP addresses of things completely outside its security domain. So what this means, I'll go to bar.com. One moment, bar.com? Oh, no, that's some server out in Europe. Next moment, dude, that's your printer down the hall. Okay, bar.com now has both resources. The resource downloaded from the European server is able to script against the resource downloaded from your printer. So your printer's behind the firewall. That server on Europe can't go ahead and access the printer directly. But you know what it can access is you. You have a browser, and it will do whatever the server on Europe says. And if it says, hey, go mess with the printer this way, your browser will do it. You actually have a situation where the internet can go ahead, bounce off your browser, and do things on your internal network. Now, of course, this was originally done, you know, from a corporate perspective. How many people here run, like, Linksyses and little home routers and so on? Yeah, yeah, you know that web interface on this? Yeah, at one moment, it's the server on Europe. At the other moment, it's the web interface of your Linksys box, dude. I mean, yeah, you better have a good password on that. So the attack works because the browser doesn't know that bar.com from the external IP is different than bar.com from the internal IP. This is totally by design. Look, you go to Google, you go to Yahoo, you go to CNN, you go to Akamai, you know, all these frickin' places, all these providers, all these content distribution networks are actually distributed across lots and lots of different IP addresses. And they don't want to care that, you know, oh, you downloaded this script from this instance of Akamai, but it actually is now scripting against this instance of Akamai. My God, this terrifies these guys. It wouldn't scale. So we have two problems. First, we've got to detect that we've even done this cross-IP script at all. That, you know, hey, you know, foo.com's moved, dude. And like, what's going on? The second is, what do we do about it? And what scared a lot of people is, well, what if what we do about it means that Yahoo doesn't work anymore? Because let me tell you, Yahoo likes working. So the canonical attack is the firewall bypass. Most corporate networks draw a significant distinction between the external network and the internal network. Now, there are all sorts of arguments about whether this is good or bad, but it's this nice thing. It's called reality. Get with it. The model is that things can route out, but things outside cannot route in. The attack is, by bouncing off a lured browser, an attacker on the outside can access resources inside. So what are our levels of exploitation? The basic one, you don't use any plug-ins at all. The browser gives you iframes. You can move them around. You can just use that. And what you end up with is, you know, one iframe is from Europe, and inside of that iframe is another one. It's a machine down the hall. They're from the same name. They can script against one another. What do you get here? HTTP resources. That's it. No special magic. The next level of attack actually comes from web plug-ins. That'd be your MSXML, your XML HTTP request, and even Silverlight. What you get here is the addition of not just HTTP, but because these things were built to interact with web services, now you get to go ahead, have all these arbitrary headers and, you know, messages, you know, things to control the infrastructure a bit more. But the real thing, the fun stuff, you know, for all the love of web services out in the professional world, you know, the corporate world, man, these guys are excited about getting back to raw sockets. So it turns out both Flash and Java have ways of giving you raw TCP and UDP access to things. So now you have a bunch of things that aren't the web at all that you're now reaching through your browser. And what we're seeing is, oh, man, you can do bad things with this. So let's look at Java first. Java was the original target of the 1996 Princeton attack. And, you know, they kind of solved the problem in their applet interface 11 years ago. And not only did they solve it 11 years ago, they kept it solved. Frickin' awesome. Except they had two different interfaces. So you could run a little Java applet and it would totally be safe and it would be un-re-bindable because Java would do its own download. Sweetness and light. Unfortunately, you could also use the second model that's supported in Firefox and Safari called Live Connect, where JavaScript gets to call Java objects correctly. And one of these objects is socket. No applet, no security. It's one of these situations where they put this big, huge wall over here, but look over there, there's a little bit of a back door. Don't pay attention. Works like a charm. You actually get some UDP out of that, which is kind of terrifying. But Flash. Flash is the big thing that I've been playing with. Flash has worked hardest to make arbitrary socket connections work when they're supposed to. You know, I feel bad about attacking Flash. I mean, these guys have worked their butt off to make this stuff actually safe and secure, and they made a beautiful security model. I mean, we're talking this is exactly what they should have done at every step of the way. They, unfortunately, did not deal with DNS rebinding, so all of their security model just collapses. This is what happens when you download your security policy from the wrong IP address. Crap. So what are the mechanisms for actually rebinding an address? There are lots of ways of using it, but, you know, how do you actually make this move in the first place? Now, I don't actually have it on my slide, but the reason I bring this up is there are kind of, sort of, a few people bringing up apocalyptically bad solutions to this problem. There's this whole class of solutions that pretty much can be defined as, there's not a hacker in the room when the solution was brought up. Please, all of you, your career goal should be, be the hacker in the room when dumb solutions are proposed. This is our value to society. So how do you actually cause the DNS infrastructure to accept a change of address? It actually was built to hold things around for a long period of time, so, you know, there's a reason people have this delusion. Well, there are three mechanisms, right? We've got a temporal mechanism, where we change things in time. Well, I'll just walk through them. Temporal, spatial, ridiculous. So our traditional rebinding method, and by far the easiest, look, records in DNS that map names to IP addresses, these records have a little time to live value that say how long they're valid. You know what, you can totally put a zero in there, and now it won't cache. So every single time it tries to make a connection, it'll go ahead and say, hmm, I'm making another connection. Has the address changed? Has the address changed? Amazingly enough, that's exactly the behavior we want. So some networks actually say, ah, we have our security solution. We'll say, an address has to be valid for at least five minutes, or at least ten minutes. And this is awesome, we have protected our customers. Because, you know, hackers are really good at this. They're really impatient people and can't wait five or ten minutes. Oh, oh, it gets worse. Watch this. Here's another little hack. You know, you can return multiple addresses at the same time in DNS. So when they ask for the address, you say, oh, it's both the machine out in Europe and the machine down the hall, and you can store that for like a day. And this works great. Now, of course, every once in a while, the browser will go ahead and pick the wrong one. So guess what you do? You try again. It turns out you can totally detect when you did it right and when you did it wrong. And I don't have time to go into the full method, but trust me, it's not that hard. The ridiculous method. This one's fun. Every once in a while, a bit of a tangent, every once in a while, you get people who try to use things as security technologies that really weren't. They're trying to use DNS, TTLs as security technologies. I haven't seen a screw up this bad since people tried to use virtualization as a security technology. Tommy the Tank Engine Security. You know, you guys know what that is? I think it's safe. I think it's safe. I think... Oh, fuck. God. Yeah, you know what virtual means? Not real. Okay. Okay. So overwriting a TTL, when you ask for it, and you actually control the record, turns out to be really easy. And this is by design. This is not surprising. Watch out. So I call it C-nyping. You know, when you look up a name, you can get back not just an address. You can get back, like, a different name. It says, yeah, I know you looked up foo, but what you really wanted is bar. It doesn't just say that. It goes, and bar's real IP address is this. Okay. When it says bar's real IP address is this, it overrides any TTLs that are already there. So watch. Here's the demo, right? We're going to look up 1.foo.mallory.com, and it's going to say, oh, yeah, I'm really bar.foo, and here's bar.foo's IP address. And, you know, that's now bar.foo's IP address, and it's going to be valid for 111 seconds. Unless I do a second query, where I look up 2.foo.mallory.com, and it says, oh, you know, this is at bar.foo.mallory.com as well. But look at this new IP address. It's all nice and fresh and has 120 seconds to be valid. Oh, look, bar's now moved. Yeah, do not use TTLs as some kind of magic security trick. It doesn't actually work. So, review. By swapping addresses from out from underneath the web browser by any of a number of means, we can get arbitrary TCP and sometimes UDP access to hosts reachable behind the client. Well, what can we do with this? I'm thinking VPN. So it's actually totally easy. Okay, yeah, it takes, like, seven programming languages and six protocols. Totally easy. Frickin' web coders, you guys change languages like... It's like you're in the middle of China, and it's like, oh, I've walked ten blocks, I have a new dialect. It's great. So, we got three actors in this little dance, right? We got a browser. The browser's got the good stuff. It has access to the internal resources. We got the attacker. He won. He wants that access, the internal resources. And then we got a proxy. And this proxy is gonna send code to the browser to copy messages back and forth to and from the attacker. Now, we're gonna start with a proxy running software that I wrote. I'm calling it Slurpee. The reason behind the name will be clear shortly. So, Slurpee. Slurpee's a multi-protocol server. It's built using the Perl object environment. Perl is great because of all of its massive libraries that mean I don't need to code things from scratch. It kind of speaks a few languages. So, the first thing it does is it talks to the attacker and gets TCP streams that need to be delivered through the browser. And these streams contain routing data saying where it would like it really to go. You got HTTP requests from the browser. Browser says, hey, what am I supposed to copy where? You've got DNS requests that this server also has to handle. Hey, you know, I'm swapping DNS around, so my proxy needs to own DNS. And then there's this fourth thing, which is XML socket requests. It turns out there's a routing policy mechanism in Flash. I'm telling you, these guys worked pretty hard. Unfortunately, I can provide that, too. So, the basic theme is that the attacker connects to the proxy, which manages the appropriate resources on the browser to service the attacker's connection. So, let's talk about how we actually build this. So, we start out with an iframe. I call it a bucket. And what this bucket does, it says, hey, proxy, got anything for me? And now that can be nothing. There might be no connections requests. But eventually, eventually, the bucket says, oh, yeah, I totally got something for you. Here you go. I want a connection to 10.0.0.1 port 80. And the browser goes, oh, crap, I got to go service this. So, what it does is for every individual IP address that it sees it's going to need to talk to, it goes and opens another iframe. And this iframe, all it's supposed to do is service connections for that IP address. And this iframe is called a socket. It's like a socket, but it sucks. So, what you end up with is that this child iframe actually comes from a different DNS name, meaning it can have a different mapping, as far as the browser knows, even. It can have a different IP address than the parent. And it will. Just not yet. So, we end up here with a bucket of sockets. And now, we need to go ahead and service these sockets. We need to actually get them into doing sockets. This brings up the obvious question. How many DNS requests does it take to get to the center of your corporate network? You have no idea how happy I was with the answer. So, we have query one. Query one involves loading the movie. And that comes from one. We have query two. That involves loading the security policy. We're still going to go ahead and we're going to have... I want to host the security policy. I don't want the real guy doing it. Two, now we need to go ahead and tell the server, hey, server, next time there's a lookup, don't come to me. Go to that IP over there. And we arm it. And we do query three. And we connect to 1001foo.proxyhost.com, port 80. All of a sudden. And now this DNS lookup resolves, uh-oh, 1001foo.proxyhost.com. I'm thinking 1001 is the address. Three. It takes three. So, okay. I'm totally going to do something I'm never supposed to do. You know what the difference between Black Hat and DEF CON is? I actually want to do a live demo for you guys. That and I have wired net. So, I actually can't. All right, I have no idea if this is going to work. It's live demo-tastic. All right, so here we have our little window. I know you can't see it much, but it's going ahead and it's updating. Hey, you know, do you have a, you got a connection for me? And I'm repeatedly saying no. Well, now what I'm going to do is I'm going to go over to my other window. And I'm going to say, hmm, I'd like to go to 2098142.254, port 80, protocol 6. Because I want to say TCP. And now I hit enter. Oh, you look at that, an iframe opened up in the back. I wonder why that happened. So, it gives me a little error message for fun. But wait, maybe, oh wait, it's socketed, it's connected. So, now, I know you can't read it, just trust me. We do get, slash, we hit enter, and, hey, I didn't write it for perf, let me tell you. Look at that. Browser just went ahead. Made a connection. Grabbed the web page. Now, I did this all by plain text protocols. You can do freaking anything over this. You can even do DNS because DNS runs over TCP 453. So, told you it worked. All right. So, how did I actually pull it off? So, there are data flows going on. We kind of have is this language called JSON, which, again, I know the screen sucks. But what JSON actually is is it goes ahead and says, okay, well, we've got our IP, 1001. We've got our connection on 1001, which is connection three. And then we have a bunch of things. We have a to browser field, which is data from the attacker to the browser. We have a from browser field, which is data from the browser to the attacker. And everything else is about state exchange, and we have acknowledgements, and, okay, I admit it, I ported TCP to JavaScript. And then it got really scary, but that's at the end of the talk. I should actually have my timer here so I know where the heck I am. All right. Well, it keeps the throat lubricated. All right. So, here's how we're managing our data flows. So, data is going to arrive by Flash. Flash has a little event handler that says, oh, my God, I got data. And what it does is Flash doesn't send the data back to the attacker itself. It doesn't even send it to the proxy. Oh, no, no, no. We got a web browser for that. So, Flash actually goes back into the web page that hosted it and says, all right, I got some data. Here, here you go. Now, the socket, the socket does not send the data either. What happens is the bucket goes around to each of the sockets and says, you got any data for me? You got any data for me? You got any, oh, okay. So, it turns out that iframes are actually running simultaneously with, you know, their parents. So, I had threading bugs in a web browser. Shoot me. So, I had to build a concurrency clean framework. My God, computer science came in useful. So, the bucket goes around, goes to each of the sockets, finds out that there's data to send, and then it goes ahead and sends this big list that looks exactly like that up to the server. Server proxy gets this big list, says, okay, let's pick out what's got to go where, let's send acknowledgements for what's got to go where, goes ahead and passes out data. Well, the attacker goes, great, I got data. Now, here's what I want some more of. Attacker provides some data. Attacker provides some data. It shows up in the exact same data structure, gets sent to the client. The bucket goes ahead and passes things out to each of the sockets. This architecture, not so much fast, frickin' flexible. So, obscure little things. One thing you might notice is that the iframes inside are actually in a different domain. Now, I told you earlier that, if foo.com tries to do bar.com, different domain, well, you can't look inside. You can't go ahead and read the DOM out. You can't read these variables. What are you doing? Well, it turns out this same origin policy actually has a little bit of an exception. If two pages are in the same domain, so they're both in, you know, proxyhost.com or notmalory.com or whatever, and they both say, hey, you know what? Even though we're in different subdomains, we want to be treated in the same domain. They can both claim this. And if they both do it, they'll both be allowed to script against each other. So, yeah, I actually used the same origin policy to attack the same origin policy. It's great. So, that's it. You know, a little bit of housekeeping for opening and closing sockets, and you're pretty much done. But what about the attacker? You know, I gave you a live demo, and I showed, you know, typing things out. Is it possible for us to do something more flexible than typing get slash into a TCP selection? Ooh, yeah. Who here was at my first DEF CON talk ever? Was anyone? Awesome! So, check this out. Back in the day, I used to use a tool called Slurp. Who here used Slurp back in the day? You, my people. Slurp is fantastic. Slurp was in 1995. The way you got... From your text connection, just a shell that you dialed into, Slurp let you get images and web browsers and graphics and pretty, pretty pictures. In fact, the PPP protocol is supported, I'm pretty sure stands for pretty, pretty pictures. Now, I talked about Slurp in 2001. Okay, it was old school back then. We know what it is now. Slurp does this. Given a stream of packets, create sockets. Just like the web browser. Create sockets and send the data and the packets to each of these sockets. Slurp was nat circa 1995. Now, if you want to go out and find Slurp, the latest versions kind of disappeared. I don't know what happened to them. I ended up having to go back to old hard drives from like three machines ago. And will you look at that? It's right there. Oh, yeah. I'm bringing Slurp back. That's right. Check this out. So we've got this code called PopTop. And what PopTop does is PopTop is a VPN server that works with Windows. And it'll actually go ahead and take the VPN connection. You know, we say, I want to make a connection to my workplace network. Well, one of the protocols it'll use is PPTP. Now, PPTP is an abomination. . I have no desire to express how horrifying a protocol it is. Just understand, PPTP ends up putting all of your packets through many layers of encapsulation into a stream of PPP data. Well, it turns out you can hand this stream of PPP to Slurp, which wants to go ahead and make socket connections. OK, so we have all the data from the applications coming into PPP. It comes into Slurp, and Slurp wants to make socket connections. What if we modified Slurp to, instead of making it themselves, go through the web browser I just told you about? Well, we now have Slurp connected to IE, thus the name of the software, Slurpee. So the way it works, the attacker runs the applications that run sockets. The sockets get their traffic sent over PPTP to Slurp. Slurp goes ahead and says, Hey, Slurpee, I got all these sockets. Go handle them for me. Proxy tells the browser, open the appropriate sockets. The browser opens the sockets, which themselves provide sockets. The proxy mediates the traffic between the attacker's sockets and the browser's sockets. And it all just works. You want to run Nessus over IE? You got Nessie. You want to run World of Warcraft over IE? You got Wowie. Pretty much anything over TCP. And if it's Firefox and Safari, you got some UDP. That's right, kids, VPN over IE. What could possibly go wrong? More toys. So lots of people have been looking into this. And I was wondering, well, what else can I use this for? You know, I'm kind of curious. This is kind of fun. Well, one thing that's been a big problem is click fraud. You know, if you can drive people's browsers around, you can go ahead and make them seem to click on things and do this and do that. Spam. Your browser will now say, send spam. That's exactly what I want to do when I go to a website. Make penis fast. What else can we do, though? Well, one thing that's pretty much inevitable is what's called stealth tor. This is where you go to a website and you are involuntarily added to a worldwide proxy network. Man, that's exactly what I think when I see a web ad. That could be a web proxy. Crap. Something else you can do is protect network neutrality. Oh, by the way, there's this stuff with peer-to-peer networking. And, um, see, Java provides UDP support. What that means is we can make the browsers go ahead and make all these UDP packets go around. And UDP is very nice in that it deals with NATS very, very nicely. You could actually build a cloud of browsers talking to each other with no central server managing them. It's not supposed to work. Oh, but it does. Then there was this one thing. Was anyone here at TCP IP drinking game last year? Anyone hear me talk very drunkenly about IP over spam? Okay, so I'm smashed, right? And there's this question that comes up, which is, how would you get around the Great Firewall of China? Now, of course, the person asking the question was expecting me to be like, oh, yes, you know, drop all the reset packets, and then, you know, it's the Harry Potter attack. Okay, I'm smashed. I got much better ideas. I'm like, look, China sends a crap ton of spam. China receives a crap ton of spam. That's a high-bandwidth, low-latency channel. Let's just copy our stuff into that. Okay, I was joking. And then I'm looking at this like, well, the browser does have IP inbound. Well, the browser does have spam outbound. Crap, I actually built it by accident. Damn it! Oh, I hate when that happens. So I had no idea people were so interested in this network neutrality thing. Last year, I'm messing with packets, and I'm like, oh, this is kind of cool. I can find when a provider is messing with me. Sweet! I've gotten so many people wanting that tool, so many people wanting that method, it's got a little bit of a bug. My method from last year for detecting messed-up networks, it kind of sort of involved flooding it with so much traffic that it actually started dropping packets. Yes, that's exactly what I want to do. I want to be the guy who tested networks by destroying them. Okay, that doesn't work. So I've actually been working over the last year, you know, kind of thinking about it. Thinking, you know, what else could I do to try to detect? And then I realized we're talking about it wrong. It's not about defending network neutrality. Network neutrality is a freaking status quo. That what's actually suggested is provider hostility. Okay, just a little secret. Every single person that I know working in router hardware is building stuff to make hostile networks. What do I define as hostile? If you're sniffing my traffic, you might very well be a hostile network. If you're altering my traffic, you're really a hostile network. And if you're selling my traffic to people, okay, look, we Napster music, they Napster us. The size of the B2B personal information market is way larger than the size of the music market. So for hostility, though, here's a nice little standard for if you know you're deploying a hostile network. If the US military would fucking kill you for doing it, you might be a hostile network. I'm just saying. So what do we need to detect provider hostility? Well, one of the problems is that if you download two things from two different pages and it comes at two different speeds, so they could have like different ISPs, different backhauls, different this, different that, it doesn't really tell you anything. And that's why they think they can get away with it. And I came along. So what we actually need is the ability for lots and lots and lots of different sites to actually seem to be hosted from the exact same place on the Internet. And it turns out we need to do two things. First, see if it's faster or slower. And second, see if they actually host the content from the website. One of the things that is actually a real problem and that it's starting to grow and it's starting to spread is something that I refer to as the Times Square effect. And as I realize it, I realize in horror, oh, dear God, I'm going to use awesome packet tools to save Internet advertising. This is not what I intended to do, but okay. This is the Times Square effect. Watch this. When you watch a movie and Times Square in New York City is in that movie, those ads aren't actually physically there. They're all digitally added. Now, why are they digitally added? Well, because they can be. It turns out there's no contractual relationship between the movie maker and the actual, you know, physical place that has those ads up on buildings. There's no contractual obligation. Well, you know what? Your ISP is actually under no contractual obligation to actually host the real contents of Google, to actually host the real contents of MySpace. There's none of it. And do you realize how much money you could make if you could sell the top link on Google? Okay. Google has built a neutral playground, a neutral framework, where the way to get to be the top link is to actually have the top best material for that subject. It turns out that it would be a lot easier. And in fact, Google would theoretically make a lot more money if they just sold that top link. Now, Google won't do it because their long-term brand is defended by actually having the best search results. But let me tell you, there are people out there who want to pay, and they want to pay a lot. They want to pay a lot of money. And the ISPs are starting to realize we like money. The web has been built on a model that man-in-the-middle attacks aren't going to happen. And what we're seeing is that entire companies are spawning that are doing man-in-the-middle attacks against advertising. Believe it or not, you don't mind ads that much. You might, some of them do, but you know what? You're the guys who don't click on them. Now, because of that, at least we expect that the ads we're seeing are going to, you know, the people actually running the web pages. No. The providers want to show their ads instead, and that's a problem. So, here's a modest proposal for actually building this. I've kind of noticed with my newfound knowledge of Flash, hey, look, we actually can do all sorts of crazy things with the DOM from Flash. We can hop things around. It turns out one of the things we can do is we can have a secure loader. We load this Flash applet over SSL, and then it goes ahead and it grabs stuff from all over the place, just like the browser does. But our loader has a list of hashes, and it says, hey, okay, well, this is what I'm supposed to get back. If I get something else back, if I get back a different ad, crap, I'm one of those evil networks, those bastards. All right, let's go soon. In the meantime, let's host the ad over a secure link. Like it or not, this is probably what the web is going to have to do, because the providers are getting really, really creepy. So, I'm building a tool set to do this. It's going to be called NDK. NDK stands for Not Domo-kun, because I would never go ahead and use the slogan of some big Japanese television show to name my software. That would just be wrong. So, Not Domo-kun. So, I know a lot of you guys might think, oh, you know, why am I helping the commercial realm? Well, guess why you have crypto in your browser in the first place. About, you know, a couple of years back, the people who wanted you to put your credit card over the internet, they're like, we like money too. In order for us to get money, we need good crypto. Therefore, we need good crypto, because we like money. The whole goal is aligning their goals with ours. So, is it possible? Interesting question. Is it possible to get better data regarding the spread of provider hostility? And it turns out we can totally start using all the DNS rebinding tools. Well, what? You know, we now have all sorts of mad control over the browser network. Which means all these things that were hard before in terms of checking up on networks, we now have the web browsers that are going to help us. So, here's what we're going to do. All right. Who here knows what a transparent proxy is? Rock. All right, so check this out. Transparent proxies, the way they work, you think you've got a real connection to the internet, but it turns out if you send out a request on port 80, all your traffic gets routed to this one guy. And then he looks at the host header on your request and says, oh, oh, oh, I know it came to me, but who you really wanted was CNN, who you really wanted was Yahoo, who you really wanted was whatever. Now, on its face, this causes real problems for Flash and Java, because Flash and Java are like, okay, we only want you to be able to connect back to the guy you got your applet from. Unfortunately, the guy you got your applet from was the transparent proxy, and guess how much of the internet is there? It's behind the transparent proxy? Oh, yeah, all of it. Not just the external network, the internal network, too. It's like, hey, transparent proxy, hey, 1.2.3.4, give me this host that's inside this network. Thing goes, okay. Here you go. Crap. Okay, proxies are so horrifyingly broken, it doesn't work. So what we can do, it turns out, remember I said earlier, what we want is to be able out of a neutrality test, what we want out of a hostility detection framework is to filter out all the changes that might come from the weirdness of the internet and instead just have the provider network. Well, there's a great thing about transparent proxies, they live on the provider network. So if a transparent proxy would, I don't know, perhaps be willing to go ahead and provide two different websites at two different speeds, well, that's entirely within the provider network. Straight up test for hostility. Awesome. But there's a difference, though. There's something called the silent sensor. It turns out none of the big ISPs, much to my surprise, actually seem to have transparent proxies deployed. You know, your Comcasts, your AT&Ts, you know, all these guys, they don't seem to do this. I think it's for scalability reasons. These proxies fall over and now you have a bunch of pissed-off customers. However, they may have filter boxes. What these filter boxes might do is they'll go ahead and they'll say, hmm. You connected to this IP address and you asked it for a host, CNN, Yahoo, MySpace, Google, whatever. And I either like it or don't like it. Well, now what we can do with Flash is we can go to an IP address, testyournetwork.com, port 80, and be like, yeah, this block of one meg, this one's from CNN, I promise. You can do it faster or slower and it'll tell you and it'll totally do the rules. Now, here's the problem. Problem is, is that I assume there's a jackass as smart as me in all these different carriers. And this guy's like, ah, I can totally detect him doing this. He'll have the wrong IP, he'll have the wrong this, he'll have the wrong that. So I was kind of curious, can I make a detection framework that even I can't defeat? Either way, I win. Well, so here's the problem. You know, we want to spoof sites on the internet. We want to use their real IPs. We want to have the real TTLs. We want to have the real ports. We want to see what they would see even though we're not man in the middle. We really don't want the real sites to mess with us as we're doing it. Good luck. I mean, we'd have to have like sequence numbers from the browser to know what the heck it's doing. And we're certainly not getting TCP sequence numbers from a browser, right? Oh, hell no. ActiveX is redeemed. There's an ActiveX plugin that will put a packet sniffer in a web browser and fire JavaScript events when a packet arrives. Holy crap. This really shouldn't exist. Okay, now we can have some fun. Oh, yeah, and I'm bringing packets back. So check this out. I'm building this tool. It's called Inspector Packet. I'm going to do Paquetto Kiritsu 3.0 just to release this. So what normally stops Mallory from pretending to be a random site on the internet? Well, you know Mallory doesn't know the sequence numbers to use. And Mallory has no idea. She doesn't compete with a real server. Well, what toy do we have now? We've got a sniffer running on Alice. We've got a sniffer running on the client. So check out what Mallory can do. Well, first of all, she can send all this data to Alice with the exact right sequence numbers. Totally has the codes to get in. Well, here's a problem, you know. Alice is going to acknowledge, not to Mallory, because the IP address is still, you know, CNN, MySpace, whatever. Alice is going to acknowledge and Mallory, and then, you know, the real server is going to be like, what the hell are you talking about? I didn't send you that data. Reset, reset, reset. Unless, you know, Mallory has the actual sequence number to send a reset to the server too. And it turns out Mallory can shut down MySpace. Be like, you know what? That client went away. Now, normally, normally what would happen is, you know, these packets arrive at, these packets arrive at MySpace or whatever and the server says, you know, I'm getting all the acknowledgements, but I don't have a session open to you. So, client, why don't you shut down your session? But then came security and security put in a firewall. And the firewall says, I don't have a session open to you. I'm going to pretend like I don't exist. I'm just going to be nice and silent. So, what this means is when Mallory shuts down the connection to MySpace, MySpace ignores now all the acknowledgements coming from Alice. It totally works. And now what this means is, you know, Mallory is sending traffic to Alice. Mallory's provider thinks MySpace is sending traffic to Alice. And when Alice acknowledges back, well, that goes back up to MySpace. But, and this is the great part, you know, Alice has a sniffer. And Alice is actually tunneling all those acknowledgements over an encrypted XGTPS stream. That's right, I'm doing TCPX over JavaScript. Not constantly. Kinda. I'm actually tunneling TCPX over JavaScript. Rock. So, why am I so eager to do this? Check out this level of evil here. You know, the goal is to identify the applications being used on the network. Some of these devices can go much further. Those from a company like Nares, for instance, can look inside all traffic from a specific IP address, pick out the HTTP traffic, drill further down, reassemble emails as they're typed out by the user. These guys are so eager. They're so eager to spy on you, they can't even wait for you to finish writing the email. They're like watching you as you go. What kind of creepy shit is this? Oh, I'm so messing with these guys. Now I can go ahead. They want to do deep packet inspection. I can pretend to be any site on the internet providing any content I want. And there's a real open question. Do I get to exploit them? I'm sending traffic to my client. I have no idea who's in the middle. Hey, if you're deeply inspected, and you're inspecting my traffic, and you have no right to, I'm not sure you have the right not to get exploited. I'm just saying. So, you know, if any of you are with one of these companies, I recommend inspecting this. Deeply. So, some conclusions. And then it looks like I'll have time to show off my little toy. Um... DNS rebinding is threatening the boundaries of networks. Your Linksys routers, your corporate networks, pretty much full TCP and partial UDP connectivity is getting exposed. This is not good. We have to do something about this. And you know what? A lot of people really are working very, very hard on fixing this. Beyond that, though, the web... Look, I love the web. The web was built for all resources that were publicly available. That was the idea. That was the model. We really need to have some better thinking in terms of how we handle private resources. Stuff that, you know, I can access, but you can't. The web really wasn't built for access control. And we need it. Because we're putting a crap ton of private stuff on websites. Beyond that, because of the spread of these provider-in-the-middle attacks, everyone running a website that depends on advertising, expect in a year or two that you're going to have to try to find some way to encrypt all your traffic. It sucks. It's horrible. In fact, SSL really isn't built to be able to do it right. But guess what? If you don't, other people's ads are going up instead of yours. And finally, people who are messing with my traffic, I mess back. So, that's the big stuff I've got. Now the fun little toy, because I got time. So, how did all this happen in the first place? You know? I sit down, I relax, put some music on. I may kind of, sort of, when I build stuff, get totally and utterly distracted. It's happened before. It'll happen again. I end up writing some completely random crap and then finding out, like, a month later, oh, that's why I built that. So, last year, I go ahead and I give this talk about dot plots. They're a way of visualizing data similarity. And I get back this two-line piece of feedback that had almost as much punctuation as text. It's like, dot plots, what the f... Well, thank you. Do you like it? Do you hate it? So, they're a mechanism for visually analyzing similarity across a data set. You know, go check out last year's talk for details. So, I thought I'd go ahead and port it to Winamp. I figured it'd be pretty. I mean, you know, I originally got the idea, if you look at music, it's very structural. There's very much repeats. There's things that go back and forth. I'm listening to music. I like pretty pictures. I think I'll like listening to music that generates pretty pictures. Cool. I figured it'd be nice to have something that I'd never be showing at Black Hat. Now, DEF CON, of course, because it's cool, but, you know, make something that the security geeks over there don't need to know. And I actually got, and this is what I was showing at the beginning of my talk, I actually got something that really generated very nice patterns out of arbitrary, arbitrary music. What I do is I take the spectrum and I compare it vertically and compare it horizontally. And it turns out I get these vertical lines that form when I have a beat. I mean, it's actual visual beat analysis. And just to show that it's actually accurate, when I speed up the beat, the lines shrink in on each other. When I slow it down, they get farther and farther away. Sweet. This is exactly what I wanted. This is cool. So, the images are based on spectral similarity. How similar is what I'm hearing now to what I've heard for the last n seconds? So, really dumb little method. Don't try this at home. But the idea was bass would be red, mid-range would be green, treble would be blue. And if you actually look at various instruments, various timbers of sound, they actually have different layouts in terms of how much relatively they're using of each. Well, that means you get different colors for different songs and different segments of songs. Now, our auditory system is almost certainly doing this kind of analysis. The idea is you compare what you're hearing now to what you've heard for the last couple of seconds. I just did it really, really badly. But I still got pretty pictures. See? That's pretty. And it's actually directly responsive. So, what we end up ending up with is two things. First, we get a visual hash of auditory segments based on the relative similarity and dissimilarity of bass, mid-range, and treble. We also end up with these vertical lines forming whenever the same signal is repeated. If it takes a long time to be repeated, you get a long distance in the line. If it takes a short time, they really, really bunch up. So, if you have a drum beat that's . . . You get these lines that are just vertical. It's just like right next to each other. So, there's a trade-off in terms of blurring. Wow, that is really blurry. I'm sorry. The trade-off in blurring is this. If you blur more, you end up seeing more of the underlying structure of the audio. You see the repeats better. If you blur less, you get a much higher accuracy in terms of being able to detect when one section ends and another begins. Of course, that's what I was doing last year. I was trying to fuzz files by finding out when one thing ended and one thing began. So, why was this here? Why did I present this back to Black Hat? So, I'm doing web research, right? Well, my buddy, Zane Lackey, who I think is . . . He's totally in the room. Someone get this man a beer. All right. So, I'm doing web research. This is really not what I normally do. And we go out for beers, because, you know, this is Zane's specialty, and I'm always happy to see Zane when he comes to Seattle. Seattle is also known, by the way, DEF CON North. We all go out for beers. And I'm like, oh, dude. So, I'm working on this really cool thing. It makes pictures from sounds, and he's like, oh, yeah, for, like, audio captchas. It was just supposed to be for pretty pictures. But that's a great idea, dude. So, I'm, like, silent for a minute. I end up going straight home and start looking into this. Now, audio captchas. What are audio captchas? Captcha is a completely automated public Turing test to tell computers and humans apart. There are lots and lots of websites that really have a problem with bots. And the idea is they want to know that a human is there. So, I get this email from someone about, you know, the fact that I'm doing captcha research. And I say, well, what are you doing with captchas? Check this quote out. Captcha is quite annoying. I use a few programs to send auto messages and to steal friends from other pages. Now, they had a way around the captcha system for a while, but not anymore. I don't know. I got five different accounts. I have 300 people a day. And I'm sitting there typing 250 captcha codes a day on this damn thing. Captchas exist to piss this guy off. That is the purpose of a captcha. So, the general idea is to use the human's superior ability to segment things, segment data to differentiate humans and machines. Image captchas use text. Audio captchas use audio. And they both put it over noise. So, it turns out audio is much, much easier to hack. You have a couple million neurons coming from your visual system. You got about 35,000 coming from your auditory system. This is why audio compresses so much better than video. So, I go ahead and I take this real-world captcha. So, you're not going to be able to see it, unfortunately, because it's too dark. But eventually, right where the mouse is, there's a repeat of the number eight. And there's actually a red line. Go ahead and grab the slides. You see this big blob at eight. You just heard nine? All right, nine. Okay, check this out. There was a nine repeated at the end. You see right near that mouse, that big white blob? Oh, yeah, WinAM's totally picking out the captcha. Turns out all the noise they put in, yeah, that's fine and great. But, you know, you're saying the same things in the same ways. And this method actually totally busts it. So, recommendations for better captchas, guys, don't, oh, man, don't make speech much louder than the noise. It's like, quiet, quiet, quiet, quiet, quiet. Big thing you're supposed to pay attention to, quiet, quiet, quiet, quiet. Don't do that. You know, humans do recognize more than just numbers. It would be nice if you use more than just numbers. Use sentences, use more than even words in isolation, because we're really good at parsing out sentences in a context. And finally, humans are intelligent, well, some of them. Ask them simple questions they might be able to answer. So, those are my toys, that's what I got, done.