So I'm Dennis Grime here today to talk about resilient botnet command and control with Tor. I came up with this title while working on the CFP at the very end of the deadline and yeah, it's probably a bit dry. So I decided I should probably rename this talk to something a little more fun. So here's the new title screen. I think it's the point across about Tor. I'll take that as a compliment for my wonderful Photoshop skills. So who am I? I'm Dennis Brown, like I said. I'm a security researcher for tenable network solutions, which if anybody asks me if they've been asking all week, I'll just say I write Nessus plug-ins. It doesn't really matter what I do. I spoke a few times at Torcon. I spoke yesterday here at DEF CON about something about as far from this as I can remember. And I'm going to talk a little bit about this topic as you can get. So this is a nice change if you can follow me around. Thanks for being a groupie. I'm also part of a Rhode Island DEF CON group, DC401. Anyone here from Rhode Island? Yes. That's all of us. So that's what I am. What I'm not in the disclaimer there is I'm not affiliated with the Tor project at all. I want to make that clear up front. I have nothing really to do with them at all. In fact, I really want to say that I love Tor a lot. I'm not a fan of Tor. I'm not a fan of Tor. I'm not a fan of Tor. I'm not a fan of Tor. People might be thinking, oh, we shouldn't be doing bad things with it. I agree. It's a really great tool. Most of the people that use it really aren't using it for bad purposes either. I don't know if any of you follow the stuff going on, like people trying to get websites from China, Chinese trying to block Tor access and stuff like that. I know last year when I was following the election going on in Iran, it was wonderful seeing people using Tor and other proxies to get the word out and get all kinds of information that's going on in the western world at least. So I really do love Tor. I don't want people to really think that I'm just trying to use it for my own evil purposes. Because I'm really not. I'm trying to make us aware that we're not doing it for evil. But just like any good tool, it can be abused. Just like anything else, anonymity is great for us. It's great for people who need it, for people who are oppressed. But it's also good for people who want to do bad things. So it's how it is. So here's a little overview of what we'll be talking about today, or I'll be talking about today. We're focusing on botnet. We're going to talk a little bit more about what we're going to talk about today. We're going to talk about command and control, specifically command and control, but a few other factors around it as well because there's a lot of interesting things we can do with this. I'll be doing a few case studies or a case study using Zeus or Zbot or whatever you may know it as. And talk about a few theoretical models inspired by some of the other big bots and worms and whatnot that we've seen over the last few years. I'm going to talk about a few techniques, too, to use Tor to anonymize your servers. Because that's really what this is all about. How many people here are actually familiar with hidden services with Tor? It's a lot of fun. That's what I expected, actually. It seems to be one of those features that just more people really need to know about. So you should learn about it. You'll learn all about it here. And the goal of this is actually to keep your servers up and keep your botnets alive. Because I'm sure we're all terrible people and have botnets and whatnot. So we're going to talk about the ways this is good, the ways this is bad, strengths, weaknesses, all stuff like that. So you may be asking yourself, well, why is this important to talk about? It sounds like it's just something terrible people shouldn't be doing or it's awesome and I'm going to go home and do it myself. There's been a lot of discussion over the years in various forms in the research community about people being a little worried that some malware might actually be using Tor. I know there's been several discussions I've been a part of that people are like, wow, if it really did that, this could be terrible. We would never be able to detect the traffic. I don't know if anything like this actually exists. If anyone does, I'd love to hear about it. I don't know how much research has been done either. I looked around and I didn't see much. So I'm hoping to shine a light on it here. There's a lot more work to be done in this space than I'm presenting today. And it's really just a lot of work to be done in this space. So I'm going to just rave for the picking in my opinion. And what's great or terrible about it is there's a big potential for this devastating impact on networks and computers as we see them today. The technology for this is Tor. It's free to download. Anybody can get it. Anybody can implement it however they want. It's very easy. I mean, I'm sure we've all used it at one point or another and know how easy it is to use Tor. And it's really minimal effort and you get great anonymity with it. As great as Tor is and I know there's a lot of people who use Tor for all sorts of purposes every day. But it's anything you can do, you can do anything. If you want to and I've never heard of anyone actually having a problem with it unless they did something wrong themselves. And we're going to talk a bit about some safeguards that can be taken to detect this activity. And these have varying levels of complexity depending on the techniques you use, the approach you take and how you actually implement it all from end to end. So let's get on with some fun stuff here. Thank you Spider-Man. So I don't know about anybody here actually have a botnet, anybody? Yes, thank you over there. If there's any feds, I'll go over it that way. So I'm sure we all have though, for real. But it sucks when your botnet gets taken down, right? Isn't that the worst thing that can happen, really? You spend so much, it really comes down to time and money that you put into it to get it together and actually make it real and be able to make some money off of it. As far as spending time on it, you have to spend a lot of time planning this. This isn't something you just spin up overnight and you want to have. I'm just going to drop my malware in a bunch of boxes and collect data. You have to spend a lot of time planning it, figuring out who you need to talk to for what services you need, how you're going to implement it all and how you're not going to get caught. Setting up the servers themselves can take quite a bit of time. If you're buying some hosting from a bulletproof provider somewhere in Eastern Europe, you'll have to talk with them. If you don't speak the language, that's another hurdle you have to get over and try to figure out how you're going to get the services from them and how you're going to get what you need on the servers they give you. If you're doing another method, say you're compromising boxes after scanning for SSH passwords, you're going to have to figure out how you set it up and not get caught that way, too, so that's another method you could take to actually have a server to put your botnet on. Building the bot itself can be a whole lot of time. If you're coding it from scratch, that could take weeks, months, years to do it just right. If you're buying it, well, you're still going to have to figure out how to use it and how to deploy it. That's not the easiest thing in the world. We'll see one that you can actually just buy in a little bit here. Then there's other things, like, quote, unquote, encrypting it so AVs don't pick it up, so you have a different binary every day so you can evade all kinds of detection, binding it, whatever else you want to do with it to make it undetectable or load other malware on it, like fake antivirus to make some good scratch that way. And then spreading. Spreading through BitTorrent is a great way to get your malware out there initially if you make some cool hack for whatever, for modern morpher or whatever, I don't know. Or then that's one approach you can take. That takes a while for it to see if you're going to be able to do it. So it's a big-time investment there. Or if you go, say, you want to do a drive-by-download attack, you go do some SQL injection against some server, see what sticks and doesn't, well, it takes time for that to happen, time for it to get queued up in a search engine, and ultimately that's a lot of time you're waiting for it to actually impact to the point where you have a botnet of any kind of size that's of interest. If you're doing spear phishing or any kind of spam campaign to spread it, too, that's more time you're spending. And if you're not spending time, you're spending money. All these things are services you can buy. Like buying spam services, buying drive-by-downloaders, buying drive-by-download services, just saying, hey, I have some malware here, I'd like to get it distributed to 10,000 hosts. Okay, well, pay me however much money that costs these days and I'll get it out there for you. Next thing you know, some guy, some sketchy guy has it done for you and you have a little botnet of your own. So each one of these things here, it's a lot of money. And you don't want to lose that monetary investment, even worse than losing the time investment in a lot of ways, because then that's just a waste of everybody's time. And when you don't have a botnet at all, if it's actually gotten taken down, well, then you've just lost all your income. It's not good. If you're using that to do spamming, sell spamming services, lease it out to other people who want to do these kind of activities, well, then if you're shut down, then you're not making money and that's no good at all. Although it actually is really good if you're on the defensive side, which is what I actually am. So how do they get taken down? There's a variety of ways. If you have a VGPD pairing, it seems to be the best way to get taken down. That's the ones that seem to be the most effective and more or less. Some of the big examples, McCullough in 2008 was taken down by a bunch of people. They were really big in spamming. Actually, there was a short period where there was a big decrease in spam after McCullough was taken down while everybody was rushing to find new places to host their spamming. And they were also the host for the main command and control server for the AS Prox botnet, which once that was taken down, that botnet never really recovered quite the same. They tried to come back a few times. But not like the good old days of 2008. And then TRIAC was a big one this year. TRIAC was a big one this year. These guys were interesting because they kept going down and coming back up and having this cat and mouse game between people trying to take them down and new hosting upstream providers that just said, yeah, come on, we'll host your stuff. We don't really know what you have. They were hosting a whole lot of Zeus command and control servers. I think it was something like, I forget the exact number. It was somewhere in the hundreds, I think, which is a pretty big distribution of Zeus command and control servers. So that was interesting to see how that went off. Another way, too, if you're just using some host, you know, a PHP prompt or something, or if you're using some free web hosting, I know like almost all the HTTP botnets just use a PHP MySQL interface, their command and control. There's a lot of free web hosting now, like 110MB.com comes to mind, where they actually provide you PHP and MySQL. And a lot of people recommend just, hey, hop on there, get it set up, get it started, and then if you have something good, make some money and buy some real hosting somewhere along the lines. You see a lot of people actually starting out with that stuff. And every so often, the people who are either running the servers that you may have gotten into or running the free hosting providers will clean up sometimes, hopefully. And you may just lose your botnet that way if that's your only place you're hosting it at. It's good to have redundant sites like you would with anything, and these guys know that, too. Having DNS revoked is another great way to take it down. I'm sure we've all read about Microsoft earlier this year pretty much neutering the Walladeck spam botnet where they had to get a court order to remove, I think it was 277 domains that was being used with it. And then since it got down, I don't know if it's come back or not, but that was a great win for them to really stop that one right in its tracks. So that can be kind of hard to do, though, depending on how the registrar wants to work with you. If they're not too friendly, if they're not good to work with, then that might be almost impossible to get them taken down, especially if they're the ones focusing on providing services to people doing this kind of stuff. And also, that also would include things like no IP and other dynamic DNS hosters. Those guys can be good to work with, too, because they can just go and remove the entries they have. So if you have that mess, if you come across a botnet using them, I encourage you to go and get that done. So that's kind of what I would do. Talk to the people providing the DNS there and get it removed. There's always a case some jerk goes and takes it over. That happens. It gets taken down that way. It's valid. And then there's other cases where the IP of your command and control server just gets banned or blocked or something like that. I see this also would include things like if your ISP shuts down your cable modem and you might think to yourself, well, that's awfully stupid. Why don't you host your botnet on your cable modem at home or your Fios router or something. And then, you know, if you have a lot of people that do that, anybody go to this site, hack forums on any frequent basis, anybody like this site, I hope not. That is a pile of shit, that place. Absolutely disgusting. They post up interesting things once in a while. Earlier this year there was someone who posted the Twitter botnet command and control thing on there that made a lot of press. Bloggers posted about it. And it was terrible. And that's really the best thing you get from here. And I love this one page right here. I have an excerpt of. I'm going to show you this. I'm going to show you this. Visit the URL at the bottom for a good laugh, actually. This is instructions on how to set up the Medias Delphi DDoS client, which is pretty much what it sounds like. It's a DDoS botnet tool that you can just go make your botnet with. And part of the tutorial here says this is going to be based off of a Linksys router. So if you don't have a Linksys, go to portforward.com and look for your router. So clearly these are people who are underskilled, but if they actually follow this and no one pays attention, then they can do some good damage. But hopefully they don't catch on to better ways to do that. So these guys are terrible. So this is what I think about people actually hosting off using that site and everything. Absolute failure. I said my pen isn't a goat. That's not too funny, right? So we have all these ways I can get taken down. That's no good. What can we do about this? Well, let's see what we can do with Tor. So I mentioned hidden services earlier. I'm going to talk a little bit more here. So what is a hidden service? Well, they've been in Tor since 2004. And what they do is allow a user to run a server anonymously. When you do this through Tor, you get a domain with a .onion TLD. And the domain itself is just a randomly generated hash. There's more to it than that. But it's essentially a hash.onion is what you would see. And that would be the URL for your server. And these are only routable through Tor. So if you try to go to it directly without Tor, obviously it won't resolve. If you go through Tor and it's not going to use an HTTP proxy or some other ways, then you'll actually have it resolve. You'll be able to connect to the server just fine. Now, what's sweet about this is it works pretty much anywhere you can run Tor. So if you have a box that's natted behind something behind a firewall, somewhere where it just can't be accessed from the Internet directly, you can spin this up and actually get right through it because it goes directly through Tor. This means there's no need to expose anything to the network. If you have a web server on a box, you don't need to open any ports or anything or have any, even locally on the network, you can block it off completely. It doesn't care. It's home running just on the same system. And this is great because we can use this to our advantage to stay hidden. But there are a few catches with this. A lot of the web command and control panels are kind of poorly written. A lot of them are just PHP applications. And we all know there's not many problems with PHP. So there's a bit of research done a couple months ago. I actually don't have notes on who did it. But it was about ‑‑ they actually found several vulnerabilities in many of the web control panels for ‑‑ I think there were ‑‑ I don't know. I don't know if there's any problems with the web exploitation toolkits. I don't know if Eleanor was one of them, but things of that nature. So if you're hosting something like that on a hidden service here, be careful because you may expose your IP inadvertently or if somebody can drop like a C99 shell on there and then you're really screwed. One thing I like to do when I'm doing things about my hidden services is make sure my host box itself is behind a Tor transparent proxy. So if somebody does do something where they try to expose my IP, hopefully they're just going to get some Tor exit notes somewhere. But that's a whole other discussion. I encourage you to check that out, too, if this is interesting to you. So hidden services, I'm not going to do them justice for how I could explain them. The Tor guys have this stuff, have excellent, excellent documentation on hidden services. So I really encourage you to go to the Tor project website. The URL is up there, but it's really easy to find if you search for it. And check it out. They have great documentation both on how it actually works in implementation and how to configure it. I'll give my two or three line explanation of it, which probably is incorrect, but I would encourage you to read that instead and don't let me get into it. But essentially when you start a hidden service that advertises to the Tor network and uses a public key in order to communicate with relays, the first relay it communicates with will be this induction point to the network. Essentially what that means is if somebody wants to get to your box, they have to get to him ultimately to get to your hidden service. And if anybody connects to the Tor network, they're going to go through and say, hey, I'm looking for this .onion domain here. Ultimately someone will say, oh, just talk to this host here. This is where you want to go. So that's a really good explanation. But hopefully that gives you an idea of how this all kind of works. Not really kind of. So just to show you how simple this is to set up, I have a couple lines from the Tor RC sample they provide that shows you all it takes to set up a hidden service. There's two parts. There's a hidden service directory, which is important because that's where it gives you the actual host name for your new hidden service server. And the private key so people know to communicate with it, be able to trust it. So that's a really good explanation for how to trust it and be able to use it ultimately. And then the other line is the hidden service port. This is very simple. It's just like creating a firewall rule for many different firewalls out there. You provide the port you want to run on. In this case they're using 80. So I can pretty much assume it's a web server. And the web server itself on the system is running on local host port 5222. Once you just put those in your Tor RC file, restart Tor, and then everything will work just fine. There's one paper I want to mention called locating hidden services by, I'm going to butcher their names, Overlier and Syverson. I'm sorry. I butchered them. I really recommend checking out this paper. It's a very good paper that they did a few years ago regarding introducing malicious Tor nodes into the network to try to actually expose the hidden services or the servers running hidden services directly. It's a pretty long paper. I would actually encourage you checking it out if you plan on doing it. It's a pretty long paper. I would encourage you checking it out. It's a pretty long paper. I would encourage you checking it out if you plan on doing it. It's a pretty long paper. I would encourage you checking it out. It's It's a pretty long paper. It's a few years old, so I'm not sure if it's 100% accurate. I think it's still worth a look because it's probably not far from where we are today. If anyone knows me and wants to correct me, please do, because I don't have looked at that too much at all. So I'm going to change gears here for a little bit. Okay. So I love this series. The last thing you need to do is make a image because it pretty much sums up how I feel about when you combine Tor and Zeus. If you can't see it too well, that's a skyscraper sized Chuck Norris fighting an equally huge Mr. T with the caption of God never intended for these two to meet. So just to give you a little background in case you're not familiar with Zeus or ZBOT or WNS poem or whatever your AV company decides to call it, it truly is the number one crimeware tool kit in use today. Actually I'll go to my next slide early. Danchev made this great tweet the other day or last month actually saying that there's a monoculture in the cybercrime ecosystem thanks to Zeus and he's very much right. Everything you see is Zeus and if it's not Zeus it's probably just goo face or one of the other big ones and then a whole bunch of random stuff. If you look at the volume of Zeus out there it's just absolutely ridiculous. And the important part about it is it isn't a single crimeware tool kit that has a single botnet in itself. It's a tool kit that's used by many people whether they purchase it directly from the Zeus authors, whether they found a leaked or stolen version that they're using which is very popular. But everybody's setting up their own servers themselves, their own command and control servers and making their own bots on their own and distributing these however they see fit. So often times when I read about a new Zeus campaign, it's probably a whole new group doing it. It's really hard to attribute who's doing what with the different Zeus campaigns going on. It's really hard to do their own botnet so that we can figure out what's going on out there because there's so many of them. But I would say that outside of the few big ones we've heard of, like the never botnet earlier this year which is just one organization's Zeus campaign and some of the other big ones whose names I don't really recall right now, there's probably a lot more people doing it than it sounds like. So I would really pay attention to that when you're reading the news and be aware that there's more than just one botnet out there called Zeus. But what it is is it's primarily focused on stealing banking info. It can steal anything you want. Whenever I demo it I have it stealing a sock puppet hotmail account which works just fine. You can configure it to steal from any website. But pretty much everybody who uses it is trying to steal banking information. And it's really easy to configure. Anybody who is familiar with HTML really can customize it to do whatever they want. They have these things called web injects. What it does is intercepts the HTML being rendered. You can say I see the bank of America username and password. Throw in a field for the debit card number and the CVV so I can get that too so they can log in. And it really just takes that data. It looks seamless on the page and reports back to the user. They do a lot of updates to make sure this stuff keeps working and works well. And it really does. A lot of data is stolen through Zeus every day. So to get back to more of how we're going to be using this, here's a sample configuration file. This is a sample configuration file. This is a sample configuration file from a version of Zeus 1242. It's a little older now but it's still pretty relevant. There's four lines here that are of interest to us. They're the URL, config, loader and server. This is how you would normally set it up for a normal Zeus configuration with the default parameters. I'm using the domain of bad guy Walmart.com because that's where everybody goes to buy their malware and tool kits and whatnot. And then we have a couple things in there. The config.bin is the configuration file where the device is using the user interface. You can see the bot will go update itself and get more information for what it's supposed to do. And gate.php is the actual command and control page where bots will check in and let the command and control server know I'm alive, here I am, here's my information, here's some data, stuff like that. So where does Tor come in? Let's get back to where we're supposed to be with this. Zoo is on its own and doesn't support proxies. We can't just say, oh, just go to the .onion domain and hit our hidden service. That doesn't work at all. And Zoo only allows for regular URLs. Pretty much anything you can hit normally with your web browser is what it's looking for. It doesn't have any kind of proxy support, not the Windows proxy or anything. So we need a little intermediary solution here. And there is one that is free and works pretty well. It's called tor2web at tor2web.com. What this is, it's not affiliated with the Tor project at all. It's a third-party tool put up by some individuals whose names I've neglected to include on the slide. They're at the bottom of the web page if you want to check it out. And what it is, is it's a web page that will redirect requests made to tor2web.com with the right .onion hash. And it'll send it along through Tor themselves and return you the results, just like any other proxy. And they also provide scripts so you can set one up on your own. So if you say, well, I like tor2web, but I don't trust them, I'm going to stand up my own and do all this myself. It's pretty easy to do. It's just a couple configuration options. Privoxy, Squid, Tor, obviously. And one script they provide. And that's about it. So what we're going to be using this is we're going to be doing the command and control over tor2web. So what we want to do in the Zeus configuration we just saw a couple slides ago is configure the bot to connect to that URL there. So what you'll see is the first part of it is the hash from the .onion domain, .tor2web.com. So that would be, if that's the right hash, that would be your command and control server. So what will happen is the bot will connect to tor2web. Because it just sees it as a regular URL. And then be directed through them to the hidden service at the .onion domain, which is our command and control server. Very simple and very effective. So as I mentioned, here's the main script they have. And all it really does is reform its request to Squid saying, hey, where it says tor2web.com, make that .onion and go through tor. And then when it gets the results, it returns it right back to you. Really simple. The configuration for it is really hardly more than this script alone. So very nice. So I'm going to attempt a live demo of how this works. I've been fighting with this all day today, so I'm not too confident that it will actually work. So we'll pretend it does if it fails. I just want to tell you about the setup I'll be using. I have Zeus1241. I think that's the right version. Which is from about mid-2009, give or take. It's an older version now, but it's one that's been leaked. And it's easy to find on the internet. So you can just go and find a copy of it and make your own botnet. That's nice and convenient. For the command and control server, I'm just using a regular Ubuntu server setup with the LAMP package installed. I'll be running a hidden service on port 80, nothing too special, just like any other web server. For the host I'll be building the Zeus binary on and executing I'll be using Windows XP SP2. I'll just go through the configuration files on there. And if this all happens, we'll log into the control panel and see a bot that has gone through tor, through tor2web to get there. So I expect this to fail. But we'll see. So here's that. Okay, I have to get on the network first. This is where I've been having problems all day. As I've been discussing from the network, I've been having big problems getting everything to work right. So bear with me for a moment here. This is really exciting. If I don't connect in a short time, we'll just pretend it all worked. In the meantime, I'll show you the configuration file. So this is the configuration file we hopefully will be using. Is that okay? That's probably a bit big. All right. So here we have here the same thing we saw before with the config and the server. But what we have here is simply just putting in the tor2web URL. Nothing too fancy. Nothing that exciting. But it's effective. And am I connecting at all? So what I've done earlier is I've actually built the right version. This is the Zeus builder for version 1242. It was off by one. The current versions look very similar. You can order this if you haven't seen it before. This is what they're paying four grand for. This and the web control panel. It has a nice thing, too, where if you actually have Zeus installed on the system, which they consider spyware, you can click a button and remove it right from the system. But I'm clean, fortunately. And this is the builder. Very easy. You just click build config, and that builds the config file that we saw in the configuration file. Just load that up onto the Zeus command and control server. I've done that ahead of time. But it needs that to know where it is. It doesn't even have to be on the same site that you're actually hosting the control panel on. It just has to be available somewhere for it to download. So you can set up, say, another hidden service on another box somewhere and put your config file there. As long as you have the right URLs, it will know where to go to pick it up. And then when you build the loader, this actually builds the executable itself. Oh, I'm on the network. Let's see if you can do this. So as you see here, we have the ‑‑ it's probably really hard to read. But we have the URL config and the URL comp IP where we have the Toyota web URLs we saw before. So it knows where it's going. And let me see if I can get the rest of this working. So we'll restart Tor and hopefully this will all just work. So I'm going to execute the bot now. If we can confirm where the builder says, oh, we have version 1242 installed. Fancy that. We'll go into Firefox. Let's see if we can get to the control panel. If we do, then there's probably a good chance this worked. If we don't, then it will. So we'll give this a moment. So it is ultimately going through Tor, so it isn't the fastest in the world. Tor has gotten a lot better recently if you haven't used it much. You're still getting a performance overhead. But really the way I look at it is that's a small price to pay for actual anonymity. And definitely worthwhile. This will probably work best if you're using a smaller botnet. Maybe a couple hundred hosts. But if you have a much larger one, this probably won't work out too great where you have a single host hosting all your bots. So we'll give that a moment and see if that works. Probably not. Actually, we'll just come back to that later. We'll move on. So I'm sure that will fail when we go back to it. But let's assume it did work for now. So there's that. There's strengths and weaknesses to this approach. The strengths are, like I said, it hides the command and control server. The only way you're going to find that out is if you can actually use some sort of attack like presented in the paper I referenced earlier. Or have some way to get into the server itself and make it expose its IP. Which that's going to be pretty hard to do, I think. It will be really hard to track down as a result. You won't know where you're looking for it. So with this being the case, hopefully the command and control server is virtually immune to being taken down. Now the weaknesses, I'm sure you've all thought about this ahead of time. It's really easy to filter this traffic. If you have any kind of HTTP filter or even block the IPs they're hosting it at, you're not going to be able to use this method. This is going to be really easy to get to take it out. And also, trust, like I mentioned. You don't know what they're logging at. You don't know if they're logging anything. I would hope they're not, by the way they're presenting their service. But you don't know that. So you probably don't want someone knowing where all of the bots in your botnet are coming from. Because that may lead to them being taken down pretty easily. And running your own Tor web proxy is definitely a problem. It's not really hard to do. But you need to have some place to run it. If I had some bullet proof hosting somewhere and I wanted to do this, that's probably where I'd consider running it. And probably not anywhere else. Because I'd still have to give it a domain or at least have an IP to point at. And it's still a single point of failure. It could be taken down. And then you're back to square one. So really quick, I'm just going to see if that worked. And no. Oh well. So what you would have seen if this worked was the Zeus control panel saying we have one bot. But we'll just pretend that's not the case. Just apologize for that. It works much better when I'm on a more stable network. But with this technique, I want to rate this as I'm happy with it. I think it's a good solution, especially if you're using a toolkit where you can't really control what's going on. But I'm not going to let you know I'm happy. It's okay. It's not a great solution. You can do much better than that if you try. So when I was first playing around with this, the next thing that popped into my head was, well, what if I use the Windows proxy settings? That'll be pretty easy. So I'm going to put Tor onto the system in Polipo or whatever you want to use, Provoxy. And pretty much drop it on like you would any other piece of malware. Like along with my fake antivirus, I'll just drop Tor on there and run it however I need it to be run. And then just set the Windows configuration to use a proxy. We have the registry keys right there. You just set a proxy enable to one. Set your proxy server and the rate port. And you're good to go. The problem with this is this is going to be very obvious to the user. The first time they go to Google, they're probably going to end up at the Czech Google or the German Google. And they're going to be like, oh, that's not working. They're going to be like, I don't understand this language. That's not good. Call up their ISP. Something's wrong. That would be terrible. You'll be found in no time. So this idea I just tabled really quick. Do not want at all. So what's the best solution here? Well, the best solution is to actually do some work and build proxy support right into your bot. I don't know any bots today or any malware in general that actually supports using proxies. If you know of any, I'd love to know it. Any toolkits especially. But you need to have some way to resolve the onion domains so they can connect directly to the hidden service. There's a few ways you can resolve the onion domains, actually. We would have to load Tor like we saw in the previous example. And, yeah, you could load for proxy or if you wanted to. But Tor provides a functionality called map address, which is a, I don't know if it's still considered an experimental option in Tor. But it wasn't on the documentation I saw. But you can put into your config file the option map address. Give it a local address. Local IP like 10.0.0.10. And the onion URL you want it to go to. And then you can just reference that local IP and go to it directly. So you don't need to have any kind of middle man to actually resolve the dot onion domains for you. So this is really great. So nice functionality to have. Especially since we're probably going to be accessing a limited amount of dot onion domains as it is anyways. So what we'll have to do in order to make our bots do this is add in at least SOX5 support. Or I guess you could use SOX4A if you really wanted to. And that will be a bit of work. It's not trivial, but it's not too hard to add in. So the bot authors will have to step up their game a bit and actually provide this kind of support into their bots. So here's what I like about this. The traffic is going directly from the host to the destination in Tor. There's no middle man like we saw with Tor the web. There's nothing you have to worry about there. It's going to go straight from your browser to the Tor proxy. To the rendezvous point. To the hidden service. And right to the web server itself. You're not using exit nodes. You're not involving anything else where your data could be sniffed. So it's going to be very hard for IDS to pick this up. And this works for more than just HTTP. Where Tor the web was really just for web-based bots. This will work for IRC. This will work for pretty much any protocol you can think of. If you want to roll your own custom command and control protocol, this will work just fine. And I think this would be very hard to stop. I was trying to come up with what the options for this would be. And I really only came up with two. Won't it be just to block Tor traffic? Like we see some countries trying to do. And I don't think that will actually work too well with this. I just don't see... There will be a lot of rules being in place. A lot of people trying to block Tor. And I just don't see people wanting to do that. And then the other would be considering Tor to be a virus. I actually ran the Tor binary through VirusTor. To see if anybody was doing this about a month ago. And no one was. So that's good. Because it isn't a virus. But I wouldn't be shocked at the result of that if some people are now. I haven't checked since then. But I just don't see either one of those happening. I don't see any kind of scale to have any kind of impact. Where a bot that would still be reachable. Boss would be able to check in with their command and control server. Now I do see some weaknesses with this too. It's going to require code to be added to bots. So say take Zeus for example. They're not just going to be able to plug it in right away. They're going to have to probably build it in as a new feature request. For a new version. And do it that way. And this isn't really accessible to people who are buying it today either. If you're just buying the kit. You have no idea how to code most likely. Or if you do. It's not in C or whatever language. It's not coded in. And like I said earlier. You're going to have to load Tor in the system and run it. Where that's not hard to do. It's still another step that will have to be taken in order for it to actually work. So it's another thing you have to worry about. If you're not loading the malware on yourself. You're paying someone to do it. Well you're going to have to bundle things up nicely. And see if they will do it for you properly. And then probably the biggest weakness with this. Would be if you're looking for any kind of anomalies in your network. Or looking for traffic changes. Because while you won't be able to see the actual command and control traffic itself. You're probably going to notice some. Bandwidth utilization increases on servers. That are actually doing it and what not. So that's probably a. That would probably be the best way to pick it up. I don't know how many people are actually doing this today. I know a lot of large corporations are. And a lot of them aren't. So it's probably a hit or miss way to check it out. And some of the changes if you're doing. Let's just say using a hidden service for a spear phishing campaign. And you're using a service inside some network. That you don't actually have access to. It might be such low volume. You would never really get picked up. So that could be a problem. This is my favorite image. Where it's just complete overjoyed Pokemon. Hugging and crying. They're so happy. So I would say if you try to take this approach. You'll have a very low risk of being taken down. Probably close to none. Unless people are just extremely attentive to their own networks. So that's how much I love it. That's us hugging in happiness. So one thing I didn't want to get into too much here. But it still is worth mentioning. Our private Tor networks. Setting up a private Tor network. It's a bit of an involved process right now. Having to set up your own directory authority. And a whole lot of other stuff. But it's great if you're really paranoid. And want to stay off the public Tor network. If you're afraid someone somewhere might figure out what you're doing. The nice thing about this too. Is it can actually be significantly faster than the public Tor network as well. You can track the host you're infecting. Looking for how their bandwidth is. You can just do simple checks. Maybe some of those speed tests even. You can find out how good a connection is. And then you can just say. Now if you're going to be one of my relays. And keep your network nice and performing really well. As a result of that. And also blocking a private network will be significantly harder. There's no list of exit nodes that will be published. There's nothing that people will know. Unless they actually go and investigate the network themselves. So it will be significantly harder to take down. I don't see how a smaller network like this. Unless somebody went after it directly. And really paid a lot of attention to what you're doing. Would actually be able to take it down. So I'm going to change gears a little bit here again. And talk a little bit about. Some other features that hidden services give us. That actually makes this a really. Nice way to manage your command and control server. So as we mentioned. Much earlier. Tor uses public keys to communicate. To let it know where. To let the Tor network know how to get to the server. When it does that. It creates a private key on the server. As well as the host name for the dot onion domain. And puts that on the system. That the hidden service is running on. So what's nice about this is. These are just files in the system. You can take these and move these wherever you want. And make it so. If this server actually goes down for some reason. You can redistribute it to another. And another nice thing too. Is you can generate a lot of these keys up front. If you run a script and just say. Hey keep clearing out that directory. And keep restarting Tor. It will just keep creating new keys for you. Until you have as many as you like. So would this be the case. What does this gain us. As far as keeping our servers up. Well it gives us a great amount of resilience. Because we have that one hash. That was the hidden service dot onion domain itself. So what we could do with this. Is easily move this from one server to another. We could just copy the files. Move it from the hidden service directory on one server to another. Restart Tor. And now we have the bots don't know any difference. But they're still communicating with a new server. So that's pretty nice. This allows us to keep our botnet up and running. Much much longer than we would otherwise. And while there's a chance that if we move it. And if we move it frequently. We might lose some data that was captured. That we never actually recovered. From one host that we moved from. And that's a really small price to pay. In order to keep the bots phoning home. And actually communicating with you. And another nice thing too. Would be to issue multiple onion domains. For your command and control. Or presumably set up multiple command and control servers. In order for Tor to connect back to it. And not have to worry if one gets taken down. And isn't able to reach it that day. This also could be a nice misdirection technique. Where you could give the appearance. We saw something like this with the ASprox botnet. Like I mentioned earlier. Where every few days or so. They would swap in a new domain for their command and control. And age older ones out. Because the older ones. If they weren't taken down by the registrars themselves. Sometimes they were taken over. Sometimes they just weren't functional anymore. I don't know if the people running the botnet. Actually took them down themselves or not. But they aged really quickly. And the older ones were pretty worthless after a couple weeks. So we can do a similar thing here. Where we can lead people along. And then every few days. Put in a new dead onion domain. And inform the bots. Here's where you're connecting now. And since we can generate as many as we want. We don't have any limitations. Like dealing with registrars or anything. We can just generate tons and tons of these. Roll them all out. Maybe only use a couple. But then people have to watch them all. And be aware of what's going on. Similar to how we saw configure work. Where it would have the randomly generated domains every day. And only a couple of them would be registered. So we talked about having your bots running Tor themselves. In the best case scenario. So if we have Tor on there. We could do a lot more interesting stuff. Like running hidden services locally. If you're familiar with Zeus's back connect model. This allows people to connect back to an effective Zeus host. Over RDP. Remote desktop. VNC. You can even run a web server if you wanted to. And have it behind a hidden service on the affected box. What's nice with this. Is you can have it do a whole lot of things. With the Zeus back connect model. They use that to connect to a host that's been affected. In order to make use of certificates in the browser for online banking. So what they do. Is they'll have people log into a remote desktop on a host. And say okay. Now I can log into your bank account. If I have your username and password. Then it really doesn't matter. Your bank is going to accept me as it is. And also another nice thing you can do. Is actually use this to distribute updates for your botnet. If every host you have infected is a web server. And hidden behind a hidden service. You can just say okay. Here's the names of the hidden services that have the updates. We're going to have you connect out to these guys. Get your update. And with that update we'll have more hosts that are doing it. Providing updates for tomorrow or the next update. Whenever that may be. So it's a nice way you can actually model your botnet. Around Tor itself. And use the hidden services to your advantage. And ultimately like I mentioned earlier. Nats have no concern here. If you have a host infected behind a router. Or a firewall or whatever. If it's talking on Tor it doesn't matter. It can do this. So a few other thoughts. Since we're all running Tor. How would it be to turn them. How would it be nicer to turn them all into relays. This is just something to pose out there. To see what people think. It doesn't increase bandwidth in Tor overall. Especially if you have a pretty sizeable botnet. I don't know if it would be worth it or not. But it could be pretty interesting to see. And this could have really positive effects for your botnet. If you can actually increase the speed of Tor. In any significant way. That would be an awfully large botnet. But that could be a neat project to do. If you actually have that kind of resource available. And on the other side. How about turning them all into exit nodes. I thought about this for quite a while. This actually makes sense. It could be cool if you have a majority of Tor exit nodes. And actually be able to control traffic going through it. Or sniff the traffic going through. Like we saw a few years ago. With the people finding embassy emails and other documents. By sniffing Tor exit nodes. But it's probably not a good idea. As enticing as that may be. For what you may learn. You'll be exposing the identities of your bots. So I would really recommend against that. You don't want them popping up on the Tor exit node list. And having a lot of attention being drawn to you as a result. Especially if they all start to go up. With say a drive by download campaign. That really takes off one day. Your botnet increases by a couple thousand hosts. And it just happens to be a couple thousand exit nodes. That stand up that day. It would be pretty obvious. I don't think that's a very good idea. As a conclusion here. As we almost saw with the live demo. It's pretty trivial to get existing HTTP bots. Working with Tor. Yeah there's a risk to it. But if you're really desperate. And you really want to keep the host. The command and control server hidden. This is a pretty good option. It's a pretty easy one to set up too. If you're able to get Tor up and running on your server. And it's possible to get a lot more protection easily. If you actually have the source to the bots. By adding in SOC support. Which is really a nice alternative to have. This of course isn't really something everybody's going to do. But if you can do it. It would be really nice to have. So you can protect yourselves. Keeping a command and control server up. Is easier if you do this hopefully. Having it anonymous would mean you're less of a target. Or if you are a target. They're going to have less of a chance of taking you down. And actually controlling bots with a hidden service. Like we talked about with the back connect stuff. Would be pretty beneficial. This would be something that I think a lot of bot authors out there. Would be interested in providing. For really no additional cost. But if you do exist. It might involve looking at your network. And looking at your data more than before. Or a little differently than before. And it's probably not going to be easy to find this stuff. Finding the Tor to web stuff will be easy. But finding by using a SOC proxy. Probably won't be. So I would actually advise you to check things out. Keep your eye open for this stuff. And if you actually find anything. Let's talk about it. Let's see what happens. And try to find out how people are actually doing this stuff. So that's all I have here. I'll be happy to do a Q&A. I don't know if we have much time left here. I'll be in the room across the hall definitely. And if you want to contact me otherwise. There's my contact info. And that's all I've got.