Thank you for coming to this session, titled Owning Bad Guys and Mafia Using JavaScript Botnets. I hope you enjoy the topic. But before starting, I would like to introduce myself and my country. I work in a small company called I64 in Spain. I'm also Microsoft MVP in enterprise security. And I live in Spain. Do you know Spain? Have you been to Spain any time in your life? If not, you have to go and visit our country. This is Madrid, the city in which I live. As you can see, it's the city that never sleeps, but it's smaller than New York. And there are a lot of big places in Spain that you have to visit. This is the Sacred Family in Barcelona, one of the most beautiful churches in the world, as you can see. And, of course, there are other places that you might like to visit. This is Ibiza, a small island in which I'm going to stay tomorrow. So if you want to rest and discover a different Spain, it's very close to you. It's in Europe, just crossing the ocean. And, of course, you are a brave man. You can visit other cities with other parties. This is Pamplona. How many of you have been running bottles any time in your life? There is only one rule. If you drink, don't run. That's the only rule. The rest is easy. You only need to run faster than the bull. It's very easy to do it. And, of course, if you like another party, we've got something special. This is the Tomatina. It's a battlefield with tomatoes, one day long, one day length. I'm not sure the history about this party, but you only need to throw tomatoes. That's all. It's quite interesting. Well, we are Spaniards, you know. Well, let's start with today's topic. Today's topic is quite simple. It's let's create a botnet. That's all. But from the beginning, we got a lot of problems with it. I guess that many of you have been thinking about creating a botnet any time in your life. How many of you have been thinking about it, about creating a botnet? How many of you did it? I did it. Well, the idea of creating a botnet is quite interesting. But, of course, as you, I'm lazy. I'm from Spain, so it's normal. So we are lazy. This is a nice picture. I would like to show you this picture. Let me use Zoom. I would like to show you this picture because for sure it's for Spanish people. They need a power supplier. They need a power supplier. And they are using flip flops to connect it through the swimming pool. It's incredible. This is more or less like we used to do the things in Spain. So that's the idea of creating the botnet. We wanted to create the botnet, but we were lazy. We haven't money. You know it. We haven't zero days. We aren't the FBI of the NSA, so we cannot intercept for free the communications. And, of course, we are not the FBI of the NSA. So we cannot do it. We are the FBI of Google, Apple, or Microsoft that are running all the devices around the world. And, you know, we are Spaniards, so we need to do something different from the beginning. So the idea of creating the botnet, it was quite simple. We thought, okay, let them be infect. Let's do something that allows bot to be infect for themselves. So the only thing that we wanted is that they wanted to be infect. Quite simple. In the end, if you think about this topic, it's very useful. And the malware industry has been using it around the last five or ten years with rogue antivirus and with social engineering tricks. So why not to do a botnet doing the same trick? So the idea of creating the botnet is just to create a man in the middle attack. There are so many man in the middle attacks that can be used in different scenarios. Of course, if we are in a network, there are different types of attacks. But the idea is to use a we can use something like ARP spoofing or we can use row DHCP in IPv4 or IPv6 network. Man in the middle attacks in IPv6 networks. We are going to publish a new tool, a new FOCA which is the evil FOCA to perform man in the middle attacks in IPv6 network just pointing and click. Quite simple. And of course if you are able to manage the DNS you can do the man in the middle attack. But it's quite complicated if you are thinking about internet because you have to deal with a lot of providers, internet providers and networks so it's difficult to use an internet. One of the most used in the internet several years ago is the man in the browser in which an add-on is installed in the browser, an add-on like a browser helper object in internet explorer and a lot of examples of the man in the middle attacks. We got a lot of malware having used this trick. We got a lot of malware from Russian, especially from Russian, using this trick. This is very useful and it works so well that they need special files to configure the Trojan to attack all different banks. This is a very ancient Trojan, banking Trojan using an XML file to configure the man in the browser to control all different web pages from different banks. Quite simple and it works very well. But we needed to call in something and deal with antivirus system, managing detection programs so we decided that it was very complicated for us and we needed something easier. So we talk about the man in the top or JavaScript in the middle. The idea is quite simple. If you are able to run a JavaScript in one tab you can do a lot of things. You can access to the code, you can modify the HTML, you can access to the form fields, you can manage even the not supposed to be managed cookies like HTTP only cooking using different tricks and so on. In fact, there are very well known project which is the browser exploitation framework project that allows you to do a lot of things just installing on a small piece of JavaScript code in a in a browser. So the idea is just to do a cache poisoning. The problem is that we need to configure this on the Internet and it's quite complicated if you want to infect a lot of bots on the network. So we were thinking about how to do it easy and we did this. So the idea is how to create a JavaScript from scratch and it's quite simple. First of all, we thought about the turn out but the idea with turn out is quite simple. If you are the last one on the line, you will be able to access to all content. You will be able to intercept all communications. The problem when we try to create the rogue turn out is that they are using some security test to discover who is modifying the answer of the DNS or who is hiding some special files and so on. as you can see. So we thought, well, it's too complicated. We need to detect when they are sending the test and creating a section for the test. No. Too difficult. We are Spanish. The next thing that we did is just to create a proxy. To create a proxy is quite simple because a proxy is not a big infrastructure like the Tor network in which all are connected. A proxy server is just a standalone server that people decide to connect to. So the idea is that if you read all the manuals on the Internet about how to be anonymous, the first thing is connect to any proxy server on the Internet. So we thought, hey, it is very interesting because it's a man in the middle schema. So if we are a proxy server on the Internet and people decide to connect to the Internet through our proxy server, we will be able to collect all data and infect all browsers. So we did it. The first thing that we need to do is just to rent a server on the Internet. Of course, you have to take care about what kind of server are you going to use. Don't use any Pirate Bay server, not even in Amazon. Remember what happened with the WikiLeaks. Not in Mega Blob. It's better if you select any country in which there are no laws. So we were renting servers on Iraq, Afghanistan, and Kazakhstan, Spain. . Then... Sorry. Once you install... you rent the server, you only need to configure something which is very simple. Apache Web Server and SquidProxy. And the idea is that with this server, we were going to infect all JavaScript files with one small piece of code. Two lines only. So when the user user connect to our proxy server, we go to the website, we go to the response page, okay, and the response page has a JavaScript file, then we retrieve the original JavaScript and then we added only two lines to load the payload. A new payload. We didn't want to use any payload very well known on the Internet like beef, so we just code in two lines and install that two lines in all JavaScript files that were across our proxy server. So in the end, only need to do this. First of all, we created a rewrite program to add that lines of code, so we need to configure this option in a squid proxy and then we added the non-expiration policy in Apache because once we infect a JavaScript file in the web browser, we want it to be there forever. Then the code that we needed to create is just this. It's a Perl script, as you can see, and the only thing that we are doing is we retrieve the file with using W get, we copy it into our file system and then we add it or pass a JavaScript file and then we add it to the web browser. So we send the JavaScript to the JavaScript. And then of course we send the JavaScript, the new JavaScript to the client using a print. It's a very small piece of code. It's full of common injection vulnerabilities, but it works. The JavaScript is just this. It's a small piece of code and we are just connecting to the control panel and the only check that we do is just that we are running only one instance of the payload in every tab. So simple. And of Wen want wanted to do anything but to good people. So we created a special advert in advice on the web page of our servers and saying following. Following proxy server is being used for a security risk all JavaScript files will be in fact and all your data will be collected. If you want to be safe don't use this proxy server. You know that. Don't send sensitive infrared its inform you. So what we want to do here we just go toinho are here, but we're going to work after all, you continue to die on your own wrist. So we published this. So if you don't want it to lose your passwords, if you don't want it to be fed, don't use our proxy. That's quite simple. It's a good security policy. No, no. Actually, in the Army, you got the same security policies. The following site is for temporary loading and unloading. On your own wrist. This is a web page from the Army. So it's the same security policy. So it's legal. So the next thing that we need to do is just to make our proxy server public. So we copy our IP address and publish the IP address on a proxy server list, as you can see. And then just let the internet do its magic. And as you can see, in a few days, we got 1,110 different results about our IP address because all proxy server leads are copying themselves. So if you're to publish your IP address on one proxy server list, they're copying the same IP address towards proxy server list. Which is funny because in one hour, in one day, you can have a lot of bots. So the next thing that we do is just to create a small piece of payload. So the first one is just cookie-stealing. We're running our JavaScript inside. We didn't want it to deal with HTTPS connection. We didn't want it to be technical, but we don't want it to be in our own code. We deal with secure cookies. We didn't want it to deal with HTTP only cookies. So we just copied the normal cookies, the unsecured cookies and sent the cookies to our control panel just using a get. Then we created a small payload to grab all form fields. The idea is that we hook the submit function copying all the information in the fields and send the fields value to our control panel and that's all. Just enjoy. Doing this in one day we were able to get 5,000 bots, which is not bad. Not creating any special polymorphic malware, not doing just publishing one IP address on the Internet. We are from Spain, you know? So the question is, who the hell is using this kind of services on the Internet? How many of you are using this kind of services on the Internet? If you read all manuals, if you want to be anonymous, use anonymous proxy server. If you want to be more anonymous, use more than one anonymous proxy server, which is cool because you can be fed for more than one proxy server. So, and the idea is that the kind of people who is using that services is, of course, bad people. All the things that we were able to collect were bad people doing bad things. So, of course, the first thing that we discovered is the Nigerian scammers. We collect all information, of course we collect also user name and password. But we advertise them so it's all legal. So we want, once we got the password we get into the mail boxes of those people. And this is one of my favorites. There were a lot of people doing this. This is one of my favorites. As you can see the email name is, the alias is Royal Hotel England and hotmail.co.uk. So this is the email. And that guy was creating a spam campaign trying to scam people with VISA. The idea is they were, he was offering to the victims a special VISA to get a job in the UK. Of course this is the email. He was asking for money. 275 pounds. And he was asking for money and a lot of people were suspicious. Saying this is a scam. This is a scam. This is a scam. This is a scam. And they were saying, okay, I respect you kind information but show me the money. Show me the job before. Show me the job and then I send the money. Of course, if the guy was suspicious, the scammer wasn't continuing with the scam. But others weren't so suspicious. So in the end they were sending all the information needed to create the VISA. As you can see, passport, application form, my resume. Passport, passport, passport. High quality picture for the passport in the UK. Fingertips as you can see. And so on. A lot of people sending. This is the easiest way of identity theft that I've seen in my life. For sure if you got all this information you probably can't create your own mule for to use in malware, in banking malware. So quite simple. Another one which is one of my favorites is this guy. Well have you seen this girl? This is a profile in a social network for having a flint and that kind of things. How do you look to that girl? How many of you really think that that girl needs to search for a boy on the internet? Well, it was very suspicious for us at the beginning. So we decided to collect the user name and password of this profile. And analyze what she was doing. And in the end as you can see, this ancient queen here is searching for a relationship and dating. She's from Texas. and it's 30. But she has another profile in another network. In this case she is from New Zealand. It's 31 and it's Aries and so on. And in another profile she lives in Virginia. Any person from Virginia who has seen this girl? And of course the most wonderful is that in other profiles she looks completely different. She is from Germany. So in the end we decide to get into the, into that guy's e-mail box and we were reading the information that was in the e-mail box and she was starting there. Well, that guy of course is not a girl. It's a boy. He was collecting chats of people who were in contact with that profile. So that profiles are for phishing victims. And this is one of my favorite chats in which KK Bill is the girl, is supposed to be the girl. And Fiat 176 is the victim. Hello, sweetie. Hello, my sweet mouse. I think we need a name. . The second one is nice. How are you doing? . Well, in the chat, in the chat you can see, I'm sorry. In the chat they are discussing the details of their love. And the details is are 70, 100 Europe that needs to be sent in a chain for the naked picture. I don't know what kind of picture are these. And the point is that this boy, this predator is a multitasking scammer. So he's chatting with different people at the same time. And he also fails. And in the middle of the chat he has started to chat in German. So we were inside the e-mail box. And it's quite nice because he has all the victims very well classified in his e-mail box. And there is a folder with all the chats in which he is working right now. And we were searching for mails asking for money through Western Union. And as you can see, there was 158 messages asking for money from Western Union. So quite simple. And the e-mail manager asked me that the other city and country is not possible. Now what can we do? Of course, she is asking for money that needs to be transferred to a different country in which it's supposed to be leaving that fake profile. And she gets angry. Fucking stop playing games on me. I gave you right address. Well, you can imagine the rest of the e-mails. Another of the scammers in that test that we did was someone very weird because he was doing something strange with dogs. We weren't sure about what he was doing with dogs and why he needed to be using a proxy server on the Internet, an anonymous proxy server on the Internet. So we decided to use the user name and password to get into the e-mail box. And we found that the e-mail was not working. And we discovered something very hard. We discovered a picture. Please, this is a warning. If you are not, if you love animals, please don't see this picture because this is the picture. He was selling this fake jersey because in the end he was selling the same jersey around the world. So it's the most. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . we were about to send this IP address to column police because this guy is not normal. Also people trying to be anonymous, a lot of people trying to be anonymous and the first thing that they were doing was just to test if they were anonymous. The problem is that if you are using a proxy server you are anonymous to the end page but not to the proxy server so the proxy server can track you any time. It's quite simple. So okay you are anonymous. We don't know that you are from the states. Okay your IP address is this and we know the real IP address. So it's quite simple. A lot of cases of people doing the same trying to be anonymous. This is the work case we discovered. It's a guy trying to make out money of reading blog posts. It's supposed to be a business. You read the blog post of anyone around the world and you will be paid for it. And after one month he was able to earn 24 bucks. So I'm not sure that it is so good business right now. Of course we discovered a lot of problems. We discovered a lot of problems. We discovered a lot of problems. We discovered a A lot of people hacking doing defacing and so on. And this is one of our favorites. You can see in the control panel we got the local files in the website that have been hacked. This is a WebCell and they are of this WebCell, of course we connected to the site to the website and it was it was it has the deface you can see you can see the hacker. It was anonymous but you had the email address. I don't understand this very well. But the problem is that this hacker was using a web cell and the web cell was hacked with a JavaScript. Do you know? Probably you know that there are a lot of web cells on the Internet with a small piece of JavaScript that are copying your web cell and you are trojanized by this web cell. This web cell was trojanized and of course it was trojanized by a JavaScript file so when the JavaScript file crossed through our proxy server, we fed that JavaScript and then we owned the web cell of the hacker. So in the end, the hacker who was hacking was hacked. So I don't understand. Also one of our favorite things is that once you are using a proxy server, you are using a web cell. If you disconnect from the proxy server but you don't erase your cache, you will be in fact for the rest of the time. Because the JavaScript is on your cache. So the idea is that we discovered that some Intranet applications were using JavaScript from the Internet. So we were able to discover to infect that JavaScript and then we infect the Intranet application. In this case, this is a guy from Mexico. He wanted to browse for some form on the Internet and then disconnect from the proxy server. But he was in fact, as you can see, this is an internal server. We were unable to connect to it. But there is an ERP application with data and of course a lot of information of the user and the password and so on. But we couldn't connect to that Intranet because it's not public on the Internet. And of course, form. A lot of form. People searching for form. Form is the business. Believe me. Not hacking. Form, form, form. Even we were, we were discovering this. This is a very nice story in which in a church, in a church, in a Catholic church was discovered this painting from monks since seven centuries before. They were painting peanuts. It's true. It's true. It's true. It's true. It's true. It's true. It's true. It's true. It's true. It's true. It's true. So we were collecting URLs and we discovered a lot of URLs on forms. Of course a lot of user names and passwords that we've been selling on the Internet of course. And but the most, the most, the most weird page is Chat to Rate. Believe me, you never watch that website. Chat to Rate is completely different. So we were collecting URLs and we discovered a lot of URLs on So in the end, once we got the JavaScript bundles, once we got the bots in fact with JavaScript, you can create a special payload. And of course, if you are connecting through a proxy server, probably you won't connect to your banking system or you are not going to connect to your social profile or you are not going to connect to your intranet or your personal website or whatever. But if you don't claim your cache, you are in fact, if someone forced you to load a JavaScript file which is in the webpage that you are going to visit after being used in the proxy server, then you will be hacked. So in this example, we got LinkedIn.com and as you can see, there are some scripts that are load in LinkedIn website. So if you are using the proxy server, then we can do this. So if you are using the proxy server, then we can create a special payload forcing you to load these JavaScript files. Then these JavaScript files will be in fact, once you disconnect and connect to LinkedIn, our payload will be executed. It's so simple. So we can create a special target attacks to several websites collecting passwords of people who were using a proxy server before on the Internet. It's quite simple. So you only need to select the target. Whatever, bank, social network, intranet, analyze the files that are going to be loaded by this website and forced to load this file when the guy, when the victim is connected to the proxy server. It's quite simple. So I wanted to do a demo in real, but I would like to show you the control panel, how it looks like. Because we, of course, we, we, we, we, we, we, we, we, we, we, we, we turn off proxy server in the Internet time ago, but for BlackHat and DefCon, I think I create a new control panel, but I didn't publish this proxy server on the Internet, but after delivering the talk in BlackHat, I don't know why, someone published on the Internet. So we configured this proxy only for ten parallel connections, only for ten parallel connections, and now, right now, this morning I'm going to show you the overview, the bots. We view zombies, old zombies, and as you can see, if we search for the date, 28, which is today, we started to receive a lot of bots from today, from different countries, a lot from the States, Brazil, whatever. And we got a lot of information right now, collect from them. We didn't want to do it. We didn't publish the IP address, believe me. But the demo that I would like to show you is more or less this. I wanted to do the demo with the IP address, the IP address, the IP address, the IP address, the IP address, the IP address, the IP address, the IP address, the IP address, the IP address, the IP address, the IP interested in this. Let me show the Web site, which is members. This is California creating a union link. As you can see, this Web site is perfect for a target attack because this one HTTP has an HTTP website in which there is an dachtein code to said mixture Thompson wh 보� to check his website. But we can inject a JavaScript file very easily in the HTTP website, hook the form and collect the username and password from this website. So the only thing that we need to do in our control panel is analyze the target and select one file. In this example, I select members, CCUL.org, scripts, JTAG.JavaScript, as you can see. And then in our control panel, create some special payload. So we go to the control panel. And you can see we got preset attacks in which you can configure what is interesting for you. And in the California credit union league, the only thing that we need to do is to force to download this file. So the guy who is using our proxy server that is watching POD. And he's in fact will be downloading this file to the cache. He will be watching POD, hacking website, whatever. But at the same time, he will be downloading this JavaScript file for the target attacks. So then when he was disconnect, when he was ‑‑ when he will be disconnect, in this case, select not to be connect anymore. Okay. So the JavaScript file which is in the cache will be in fact with our payload because we downloaded before and this file is not out of date. So the browser will be using. So in the end, after the guy connect to the website sending the information, that form will be hooked and we are going to be able to retrieve all the data. So we can run our control panel and send this data in our control panel. It's so simple, so easy to do, and very profitable. So some thoughts about our JavaScript botnets. In this example, we didn't worry at all about doing something special with the江 connection. We didn't worry about per cache object using the E tag or using special tricks. Hopefully, we don't need to go through that or use the force the inspiration of the object that are previously in the cache. And we didn't want it to use, to do something with the HTTPS connection because we didn't want it to rise any alerts. So we, and of course we didn't have any flame digital certificate and Moxie was very busy tweeting so we cannot contact within to create the special digital certificate. And the idea, the good point of it is that we did it only in one day. So in one day we were able to configure the proxy server, configure the Apache, publish the IP address, create the JavaScript and collect all this information. So if we were able to do this in only one day, the problem is how many of you think that governments, intelligence services, bad guys aren't able to do this? Aren't doing the same on the internet? The question is, how many of you think that only one of those proxy servers on the internet is secure? Only one. How many of you think that only one of those proxy servers is secure? No one? Secure. I don't think so. Secure. No. That is not going to infect you. Or collect your data. The one you run. It's not going to infect you. It's not an anonymous proxy server. It's yours. It's completely different. So in the end, using a proxy server on the internet is a very bad idea. But we got thousands and thousands and thousands of webpages on the internet saying people, if you want to be anonymous, use a proxy server on the internet. So we are going to have this problem a long time and a long time and a long time. So don't use it. So sound protection. Of course, this is a man in the middle schema. And it's a man in the middle schema in which you decide to be hacked because you configured your web browser to use that man in the middle. That proxy server. So you have to think twice if it's worth it to be using that proxy server. And of course, the problem is with Tor networks. But right now, we got more news about fake Tor networks. Tor nodes or rogue Tor networks. And so it's not a good idea to use or notes on the internet than fake or rogue proxy server on the internet. And I don't know why. And of course, after using this kind of services, if you need to do this for whatever reason you have, take care and clean all the information that you don't love from the internet. Take special care with that machine. If it's possible, use a new virtual machine and burn it out after using. Throw it to the trash, whatever you want. And of course, VPNs are not a silver bullet because in this case we were able to discover a lot of people connecting to a personal VPN to be outside of the network in which they were connecting. And then from the VPN connect to a proxy server and in the end it's possible to infect the client in any case. So take care of it. And that's all. Tomorrow I'm going to be delivering a new talk in Skype talks. Thank you very much.