Now, I hope that you have a good time at DEF CON. So, this talk is called Hack Any Website. This is a very sexy title. This explains why there are so many people in the room. Actually, it's more about man-in-the-middle attack. So, first I will give you an overview of this attack. Then, I've prepared a few demos to show you what it's possible to do with this attack. After that, I will give you some general analysis and I will explain to you how it works. Then, I follow up with some technical analysis and I will show you the code to be able to reproduce this attack. Then, I will give you some defense mechanism and then I will conclude. So, what is the man-in-the-middle attack? The problem is today, servers are more and more well-protected, but the clients are not. So, the idea is the following. You have a client, you have a server, and between them, you have the man-in-the-middle. You have a communication between the client and the server. Let's say that the client sends a request to the server. The man-in-the-middle will intercept this request. It's possible to modify this request. The server will respond. And once again, the man-in-the-middle will intercept this response. And once again, it's possible to modify the response. So, this is a very generic man-in-the-middle attack. And I will show you how it's possible to do it. With Internet Explorer. So, I've prepared a few demos for you. As the wireless connection does not work very well, I did it yesterday in my hotel room. And I will be able to show you what I did. So, first, I will start with iNotes. So, you probably know iNotes. This is a webmail interface to access mail when you're running Lotus Domino. So, I will launch the demo. So, this is a very basic computer running Windows 2000 with Internet Explorer. I've started Internet Explorer. I will type in the address bar the URL to access the webmail interface. So, I access the login page. I type the username. I type my password. I will login. So, very standard, the homepage of the iNotes web access. I will click on the mail menu. I will choose inbox. And once again, this is very standard. I have the list view with all my email in my list box. I will right click on one of these emails. And as you can see, you have a very nice pop-up menu. And actually, this is a... It's too fast. I will just go back. A little. So, you have a nice DHTML pop-up menu. And this DHTML menu, you have some feature like open. So, you can open an email. You can move an email to another folder. You can remove an email from the folder. So, this is very standard. I choose the open feature. And the email is open. So, everything is fine. No problem at this moment. So, now let's try the second demo. Which is the same except that there is somebody between the client and the server which will attack the communication and modify what happens. So, let me show you with a graph. So, you have the client which sends a request to the corporate server. The corporate server sends back the response. And it will modify the response. And actually, I will switch the open and the remove feature. So, the open and remove feature that you have saw in the pop-up menu will be switched. So, what will happen? When the user will try to open his email, he will send the request, I want to remove the email. So, definitely, the email will be deleted on the server. And then, the corporate server will send back the release view, obviously, without the email. So, let me show you how it works. Very easy. I launch, once again, the demo. So, same stuff. I launch Internet Explorer. I type the URL. The user experience is exactly the same except that somebody is intercepting what happens between the client and the server. So, I type my username and my password. I login through this page. Okay. I reach the home page of Internet Explorer. The iNotes web access. I choose the inbox from the mail menu. Once again, I right-click on one of the emails. And then, take a look. I choose open. But actually, it removes the email from the inbox. Once again, I do it for another one. I choose open. Same stuff. It will delete the email. So, it's pretty funny to change those features. Okay. So, I have a second demo. And I think that it's even better than the first one. It's about the CNN web page. So, let's do it again. I will start the demo. And this time, the computer is free of the attack. So, I just want to type www.cnn.com. In the address bar of Internet Explorer. And I will reach the CNN web page, home page. I did this yesterday night. So, let me explain what I will do. Once again, you have a request between the client and the media website, which is CNN. CNN will send back the HTML page. And this HTML page will be intercepted by the man in the middle. So, what the man in the middle will get, this is the standard source of this HTML page. And the man in the middle will search for a specific tag. It's a little bit up here. This tag, actually, if you take a look at the source of the HTML page of the home page of CNN, this is the tag to see that you are in the middle of the page with the main title. And as you remember, it was the title about the doctor of Saddam Hussein. So, you can see it there. So, what will happen? The man in the middle will request something from the malicious server because I want to change the content of the home page. So, I do a request to the malicious web server. Obviously, I get a response from this server. And then I send back to the client the answer that has been modified. So, let me show you what you will get. So, I launch my second CNN demo. So, this time, the man in the middle will intercept the communication. I will type the CNN URL. URL in the address space bar. And as you can see, this is a little bit different. So, if you have any information about DEF CON, I think that you have to report to the DEF CON website. Okay. So, let me explain to you how it works and how it's possible to do this. And you will see that this is very, very easy to be able to intercept the content from a website. So, is it new? No. Actually, I have to go back in the past. And it was a war between Internet Explorer and Netscape. And if you remember, there was the release of version 4 in the same week of both Internet Explorer and Netscape. By the way, I have some PC card. And I'm supposed to give it away right now. So, I will ask a question. And the first one who will answer the question will win the PC card. In which year was release version 4 of Internet Explorer? 97! Okay. Actually, there is a second one. But this is for the end. There will be another question. So, big competition between Internet Explorer and Netscape in 1997. And Internet Explorer introduced a concept which is a BHO. The Brother Helper Object. And actually, it was a very good initiative from Microsoft. This is a way to... Open the browser structure. And you can access the browser structure through a DLL. So, this is the purpose of the BHO. And it's a great feature. When you, for instance, when you download a PDF file through Internet Explorer, the PDF file is displayed with a BHO. And it's also the same with a Google toolbar. The Google toolbar is using a BHO. The problem of the BHO is that you can change the structure of the HTML page inside Internet Explorer. But you have absolutely no security around this feature. I mean, Microsoft consider probably that Windows was secure enough. And then, BHO is totally silent. So, you can fully modify the structure of the HTML page without any warning for the user. And basically, this is what I did for both the iNotes and the CNN web page. So, definitely... It requires Internet Explorer 4.0 or later. But if you take a look at the Google site guest, we show you all the Google requests on the web. It's more than 90% of the market. So, definitely, it's not a big deal. And definitely, what you have to do, you have to create a DLL. You have to execute a code to be pushed, to push this DLL into the Internet Explorer process. The good point is that this is a very generic attack that leads to a lot of malicious scenarios, as I just showed you. So, the good point is that you do not need any hardware. It's just software. You have to develop this DLL and to run this DLL on the client. Another good point is that you do not have to modify the server. So, this is what is very, very good because if I had to change the CNN server, it would be probably very, very difficult. Moreover, this attack uses a feature developed by Internet Explorer. It's developed by Microsoft. So, definitely, Microsoft gives you all the tools to develop such attack. And last, this DLL actually cannot be detected by antivirus. So, this is a very standard DLL with no specific signature, nothing very specific. So, it's very easy. You just need to push this DLL and it will not be detected by antivirus. Last, you can personalize this attack, and this is what I did for the CNN web page. I established another connection with a malicious server to get the new content, and I reproduced the content for the client. So, let me give you some technical analysis to show you how you can develop this BHO, this attack. So, actually, BHO, this is a come-in-process DLL. And once you have registered this DLL, it will be automatically loaded by Internet Explorer. So, it means that the next time you start Internet Explorer, the DLL will be loaded in the process. And then, at this moment, Internet Explorer will check all the DLL and it will pass an unknown pointer to your DLL. So, this is the way you will be able to modify all the structure of the HTML page. So, how can you do that? So, this is pretty obvious. You have just to define a set-side function, and in this function, you have to call the manage connection where you will advise Internet Explorer that you want to get back the HTML structure. So, we will pass, actually, a flag advice to tell Internet Explorer that you are interested to get everything. Once you have done this, you have to connect your BHO to the structure, to the browser. So, you can do this with the find-connection-point function, and you will get a pointer to a come-printer, and then you have just to call the advise function, which, as you can see, is this parameter, and you will be able to get all the event of the container. So, any event that will be fired in Internet Explorer will be catched by your DLL. So, you have many events that you can intercept. So, the first event is DSP ID document complete. So, it means that when the page is downloaded and will be displayed on the Internet Explorer, this event will be fired. So, you will be able to get the full content of the HTML page and to modify any tag you want, and then to ask Internet Explorer to render the page. So, this is what I use for the CNN web page. I capture this event, I modify the page, and then Internet Explorer displays the new content. You have some other pretty interesting events, like the Navigate complete event, the Before Navigate, and the new window. The Before Navigate is pretty interesting because it's fired before you send a request to the server. So, I mean, when you type a URL, or when you want to click on an hyperlink, this event will be fired, so you will be able to get the full URL with all the arguments that have been sent by the client before it reaches the server. So, you can get the full URL. You have more than 20 events that you can intercept, and if you want to take a look, you have to go to the xdisp.h header file, which you can find in the SDK. So, let me give you an example with the document complete. So, once you intercept this event, you will be able to get the document structure of the HTML page. So, this is the function getDocument. So, this is the document, and from this document, you will be able to get the body. So, it means that the body that you can see in the HTML page, so, I mean, from this tag, basically to the end, will be reflected in this structure. And then, you can pass all this structure and modify any tag you want, and once you have done this modification, this new page will be displayed by Internet Explorer. The same way, if you want to get the location, I mean the URL, you can do it through the getLocation URL, the URL function. So, what you have to do to install your component. Actually, this is very easy. You have just to register the DLL, and you have to create a key in HKEY local machine, software, Microsoft, Windows, current version, Explorer, browser helper object, with the GUID of your DLL. And that's all. Once you have done this, the next time Internet Explorer will be launched, it will automatically load your BHO. So, how to defend? First, do not use Internet Explorer. If you want to still use Internet Explorer, you have many, many options. The first one is to disable or some of the BHOs. So, you can do it very simply. Just go through the registry, to the keys that I've just show you before, this key, and just remove all the keys, and then, all the BHO will not be loaded the next time. The problem is that it's pretty painful, because sometimes, the BHO are pretty useful, and this is the case for the Acrobat plugin, or for the Google toolbar. Another solution would be for Microsoft to improve in the coming release of Internet Explorer the support of BHO. First, I'm very, very surprised that there is no warning that the BHO has modified the web page. So, when I have modified the CNN web page, I get absolutely no warning that something has modified what I've downloaded from the website. And I hope that in the next release, there will be a kind of warning to let the users that something happened on the inside the Internet Explorer. Otherwise, they can also create a tag, something like disabled BHO, so for a given web page, you are sure to disable all the BHO of the page. Okay, so before the conclusion, I'm going to give the second PC card. So, to your mind, which privilege is required to install a BHO? Power user, power user. So, definitely, what I just wanted to show you is that using the most standard feature of Microsoft Internet Explorer, it was possible to develop an attack, and this is a very flexible attack. It's fully selective and fully personalizable. So, definitely, you should not trust what you see. Another point is that you have, if you take a look at Google, you have a lot of BHO watchers, and this is more executable to be able to list all the BHOs that are installed on your computer. So, definitely, I recommend that you are using such tools to know all the BHOs that are installed on your PC, and I'm pretty sure that you will be amazed by what you will discover. So, this presentation and the code can be downloaded from the DEF CON website. You have a clear BHO, and you can do whatever you want to do with it. And definitely, if you have any questions, you can contact me by email. So, definitely, have fun with BHO. Thank you.